Compare commits

...
42 Commits
Author SHA1 Message Date
Kornel Lesiński 021950a5b2 Less alarming error message 2016-12-10 11:59:47 +00:00
Kornel 2ff0da4f15 Merge pull request #881 from zorgiepoo/separate-validation
Separate validation
2016-12-04 13:35:07 +00:00
Kornel Lesiński 945968a0ef Reminder 2016-12-04 12:19:25 +00:00
Kornel Lesiński 1e4f126f7e Podspec version bump 2016-12-04 12:18:11 +00:00
Kornel Lesiński f47115d81f Version bump 2016-12-04 12:14:24 +00:00
Kornel Lesiński 49781561f3 Cocoapods fudge 2016-12-04 12:10:27 +00:00
Zorg 1587dd1dc3 Refactor pre & post update validation into its own class 2016-12-03 15:37:00 -05:00
Zorg c0b9eaaa0e s/requiresValidationBeforUnarchiving/unsafeIfArchiveIsNotValidated/ 2016-12-03 11:06:10 -05:00
Kornel 91ac90ffcf Merge pull request #928 from sparkle-project/script
Fix #926
2016-12-03 00:05:09 +00:00
Kornel Lesiński 8375922755 Fix #926 2016-12-02 21:10:37 +00:00
Kornel 9dec304f64 Merge pull request #919 from sparkle-project/tag
Don't append hash to versions of builds with a tag
2016-12-01 20:16:43 +00:00
Kornel 8acd915b7b Merge branch 'master' into tag 2016-11-12 23:44:03 +00:00
Kornel Lesiński eb36100388 Allow 2.x 2016-11-12 17:14:56 +00:00
Kornel Lesiński fb22a01a08 Don't append hash to versions of builds with a tag 2016-11-12 14:22:42 +00:00
Zorg 9a32766aeb Merge branch 'master' into separate-validation 2016-11-11 23:35:28 -05:00
Kornel fc468771c1 Merge pull request #916 from zorgiepoo/swift-xcconfig
Move swift and other build settings into xcconfig files
2016-11-11 23:09:15 +00:00
Zorg 42dbf94738 Move swift and other build settings into xcconfig files 2016-11-10 15:51:30 -05:00
Kornel 86a0ca3883 Merge pull request #914 from sparkle-project/appiconname
Rename Sparkle.icns to be consistent with ASSETCATALOG_COMPILER_APPICON_NAME
2016-11-09 22:46:27 +00:00
Kornel Lesiński ddb53f330d Rename Sparkle.icns to be consistent with ASSETCATALOG_COMPILER_APPICON_NAME 2016-11-09 21:45:03 +00:00
Kornel 9dbaae64f1 Merge pull request #908 from sparkle-project/icon
Use optimized icon for Autoupdate.app
2016-11-01 22:56:27 +00:00
Kornel Lesiński d2f4687333 Specify requirements 2016-11-01 21:52:23 +00:00
Kornel Lesiński 143045d673 Use optimized icon for Autoupdate.app
#803
2016-11-01 00:44:54 +00:00
Kornel d67351cb62 Merge pull request #906 from vslavik/stable-byte-counts
Fix flickering download progress status text
2016-10-31 13:06:40 +00:00
Václav Slavík 07d2897250 Fix flickering download progress status text
Fix status text during download (e.g. "10MB of 22MB") so that it no
longer distractingly jumps around and flickers. This was caused by two
things:

1. Flicker on macOS >= 10.8 due to the use of NSByteCountFormatter's
   default mode which isn't optimized for stable display and is not
   suitable for rapidly updated values.

2. Smaller movements of text on macOS >= 10.11 due to the use of San
   Francisco font's default variant, where digits don't have fixed
   width.

Fixed by using monospacedDigitSystemFontOfSize for the text field and
enabling NSByteCountFormatter's zeroPadsFractionDigits mode.
2016-10-31 11:13:15 +01:00
Jake Petroules 625c942561 Update references to MaxCDN to StackPath
The latter acquired the former and requested this change.
2016-10-04 17:56:44 -07:00
Kornel bb299d075b Merge pull request #884 from sparkle-project/xcode8
Xcode8
2016-09-16 11:02:53 +01:00
Kornel 73229f84f7 Merge pull request #889 from zorgiepoo/swift3
Swift 3
2016-09-16 11:02:10 +01:00
Zorg 8152516b7f Remove coveralls
Coveralls hasn't worked properly in months since Swift code started being used, and it's causing a build failure at the moment.
2016-09-14 23:14:41 -04:00
Zorg 96baf2b2ce Update travis to use Xcode 8 2016-09-14 23:05:45 -04:00
Zorg ed5dca3423 Update unit tests to Swift 3 2016-09-14 23:05:05 -04:00
Kornel 3a5c620b60 Merge pull request #886 from zorgiepoo/debug-warning
Warn a developer if they're using a debug version of Sparkle
2016-09-06 17:03:40 +01:00
Kornel 23ae527b96 Merge pull request #885 from zorgiepoo/docs
Add more documentation to SUUpdater.h
2016-09-05 11:50:00 +01:00
Zorg 2268f96759 Add more documentation to SUUpdater.h 2016-09-04 22:11:29 -04:00
Zorg 898e063b4f Remove unnecessary 'return;' 2016-09-04 18:38:08 -04:00
Zorg e8f88bf0f1 Merge branch 'master' into separate-validation 2016-09-04 18:37:14 -04:00
Kornel Lesiński a3407a2dbf Xcode 8 config 2016-09-04 17:04:54 +01:00
Kornel Lesiński 88933a1e65 Unused 2016-09-04 17:04:54 +01:00
Kornel Lesiński c3d8e4bbc5 Changelog 2016-09-04 17:02:56 +01:00
Zorg 5b2ce958bd Merge branch 'master' into separate-validation 2016-09-03 23:27:16 -04:00
Zorg e28c62244a Re-show download status if we attempt a 2nd download
This fixes a bug where the status would stay at "Extracting update" after validation from the 1st delta patch failed, and it continued on to a full download.
2016-09-01 23:19:58 -04:00
Zorg fec76fee12 Validate binary delta patches before unarchiving
Also keep package and bundle validation separate.
2016-09-01 23:14:26 -04:00
Zorg 6437e0448a Warn a developer if they're using a debug version of Sparkle
Due to different values for min/default update check intervals, production apps should not use a debug version of Sparkle
2016-06-24 20:13:17 -04:00
43 changed files with 768 additions and 420 deletions

No files matched your search

+1 -3
View File
@@ -1,7 +1,5 @@
language: objective-c
osx_image: xcode7
osx_image: xcode8
before_install:
- brew update
- brew install macmade/tap/xcode-coveralls
script: make ci
after_success: xcode-coveralls --exclude /Applications --exclude Tests --exclude Vendor build/Build/Intermediates/Sparkle.build/Coverage/Sparkle.build/Objects-normal/x86_64
+2
View File
@@ -23,6 +23,8 @@
* Removed SUEnableAutomaticChecksKeyOld and SUCheckAtStartup constants (Eitot)
* Updated Sparkle framework headers to use modules if modules are available (B. Kevin Hardman)
* Fixed warnings, fixed uses of SULocalizedString (Jerry Krinock)
* Improved signing verifier to take any host and s/application/bundle/ (Zorg)
* Improved Spotlight updates after delta extraction (Zorg)
# 1.14.0 (Mar 11, 2016)
+4 -1
View File
@@ -17,7 +17,7 @@ SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME = 0
SPARKLE_VERSION_MAJOR = 1
SPARKLE_VERSION_MINOR = 15
SPARKLE_VERSION_PATCH = 0
SPARKLE_VERSION_PATCH = 1
SPARKLE_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH)
CURRENT_PROJECT_VERSION = $(SPARKLE_VERSION)
@@ -36,8 +36,11 @@ GCC_PREPROCESSOR_DEFINITIONS_COMMON = SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NA
CLANG_ENABLE_OBJC_ARC = YES
GCC_ENABLE_PASCAL_STRINGS = NO
GCC_NO_COMMON_BLOCKS = YES;
COMBINE_HIDPI_IMAGES = NO;
// Enable warnings
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES
CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES
CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES
+1
View File
@@ -0,0 +1 @@
SWIFT_VERSION = 3.0
+1
View File
@@ -0,0 +1 @@
SWIFT_OPTIMIZATION_LEVEL = -Onone
@@ -0,0 +1 @@
SWIFT_OPTIMIZATION_LEVEL = -Ofast
+2
View File
@@ -1,5 +1,7 @@
// UI Test only
#include "ConfigSwift.xcconfig"
INFOPLIST_FILE = UITests/UITests-Info.plist
WRAPPER_EXTENSION = xctest
MACOSX_DEPLOYMENT_TARGET = 10.11
@@ -1 +1,2 @@
#include "ConfigUITest.xcconfig"
#include "ConfigSwiftDebug.xcconfig"
@@ -1 +1,2 @@
#include "ConfigUITest.xcconfig"
#include "ConfigSwiftRelease.xcconfig"
+2
View File
@@ -1,5 +1,7 @@
// Unit Test only
#include "ConfigSwift.xcconfig"
INFOPLIST_FILE = Tests/SparkleTests-Info.plist
WRAPPER_EXTENSION = xctest
OTHER_CFLAGS = $(inherited) -iframework"$(DEVELOPER_FRAMEWORKS_DIR)" -iframework"$(PLATFORM_DIR)/Developer/Library/Frameworks"
@@ -1 +1,2 @@
#include "ConfigUnitTest.xcconfig"
#include "ConfigSwiftDebug.xcconfig"
@@ -1 +1,2 @@
#include "ConfigUnitTest.xcconfig"
#include "ConfigSwiftRelease.xcconfig"
+11 -5
View File
@@ -13,14 +13,20 @@ if [ -z "$SRCROOT" ] || \
exit 1
fi
# Get the current Git master hash
version=$(cd "$SRCROOT" ; git show-ref --abbrev heads/master | awk '{print $1}')
if [ -z "$version" ] ; then
echo "$0: Can't find a Git hash!" 1>&2
version="$CURRENT_PROJECT_VERSION"
# Get version in format 1.x.x-commits-hash
gitversion=$( cd "$SRCROOT"; git describe --tags --match '[12].*' || true )
if [ -z "$gitversion" ] ; then
echo "$0: Can't find a Git hash!" 1>&2
exit 0
fi
version="$CURRENT_PROJECT_VERSION git-$version"
# remove everything before the first "-" to keep the hash part only
versionsuffix=${gitversion#*-};
if [ "$versionsuffix" != "$gitversion" ]; then
version="$version $versionsuffix"
fi
# and use it to set the CFBundleShortVersionString value
export PATH="$PATH:/usr/libexec"
+1 -1
View File
@@ -14,7 +14,7 @@ release:
xcodebuild -scheme Distribution -configuration Release -derivedDataPath "$(BUILDDIR)" build
open -R "$(BUILDDIR)/Build/Products/Release/Sparkle-"*.tar.bz2
cat Sparkle.podspec
@echo "Don't forget to update CocoaPods!"
@echo "Don't forget to update CocoaPods! pod trunk push"
build:
xcodebuild clean build
+24
View File
@@ -0,0 +1,24 @@
# To update the icon run make -f Makefile-icon
# Requires:
# autoconf, automake, libtool, pkg-config, pngquant
ICONDIR=./Resources/Images.xcassets/AppIcon.appiconset
OPTIMIZEDICONS=$(ICONDIR)/optimized_16x16.png $(ICONDIR)/optimized_32x32.png $(ICONDIR)/optimized_128x128.png $(ICONDIR)/optimized_512x512.png
DESTICON=Resources/AppIcon.icns
all: $(DESTICON)
libicns:
git clone https://github.com/pornel/libicns.git
libicns/Makefile: libicns
( cd libicns && autoreconf -vif && ./configure )
libicns/icnsutils/png2icns: libicns/Makefile
( cd libicns && make -j8 )
optimized_%.png: icon_%.png
pngquant -s1 -f -o $@ $<
$(DESTICON): libicns/icnsutils/png2icns $(OPTIMIZEDICONS)
./libicns/icnsutils/png2icns $@ $(OPTIMIZEDICONS)
+2 -2
View File
@@ -1,4 +1,4 @@
# Sparkle [![Build Status](https://travis-ci.org/sparkle-project/Sparkle.svg?branch=master)](https://travis-ci.org/sparkle-project/Sparkle) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![CocoaPods](https://img.shields.io/cocoapods/v/Sparkle.svg?maxAge=2592000)]() <a href="https://www.maxcdn.com/?utm_source=sparkle-github&amp;utm_medium=badge&amp;utm_campaign=readme"><img src="https://img.shields.io/badge/sponsored%20by-MaxCDN-orange.svg" alt="sponsored by: MaxCDN"></a>
# Sparkle [![Build Status](https://travis-ci.org/sparkle-project/Sparkle.svg?branch=master)](https://travis-ci.org/sparkle-project/Sparkle) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![CocoaPods](https://img.shields.io/cocoapods/v/Sparkle.svg?maxAge=2592000)]() <a href="https://www.stackpath.com/?utm_source=sparkle-github&amp;utm_medium=badge&amp;utm_campaign=readme"><img src="https://img.shields.io/badge/sponsored%20by-StackPath-orange.svg" alt="sponsored by: StackPath"></a>
An easy-to-use software update framework for Cocoa developers.
@@ -54,4 +54,4 @@ We pledge to have an open and welcoming environment. See our [Code of Conduct](C
## Project Sponsor
[MaxCDN](https://www.maxcdn.com/?utm_source=sparkle-github&utm_medium=link&utm_campaign=readme-footer)
[StackPath](https://www.stackpath.com/?utm_source=sparkle-github&utm_medium=link&utm_campaign=readme-footer)
Binary file not shown.
+6 -5
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Sparkle"
s.version = "1.15.0"
s.version = "1.15.1"
s.summary = "A software update framework for macOS"
s.description = "Sparkle is an easy-to-use software update framework for Cocoa developers."
s.homepage = "http://sparkle-project.org"
@@ -11,15 +11,16 @@ Pod::Spec.new do |s|
:file => 'LICENSE'
}
s.authors = {
'Andy Matuschak' => 'andy@andymatuschak.org',
'Kornel Lesiński' => 'pornel@pornel.net',
'C.W. Betts' => 'computers57@hotmail.com',
'Jake Petroules' => 'jake.petroules@petroules.com',
'Mayur Pawashe' => 'zorgiepoo@gmail.com',
'Kornel Lesiński' => 'pornel@pornel.net',
'Jake Petroules' => 'jake.petroules@petroules.com',
'C.W. Betts' => 'computers57@hotmail.com',
'Andy Matuschak' => 'andy@andymatuschak.org',
}
s.platform = :osx, '10.7'
s.source = { :http => "https://github.com/sparkle-project/Sparkle/releases/download/#{s.version}/Sparkle-#{s.version}.tar.bz2" }
s.source_files = 'Sparkle.framework/Versions/A/Headers/*.h'
s.public_header_files = 'Sparkle.framework/Versions/A/Headers/*.h'
s.vendored_frameworks = 'Sparkle.framework'
+21 -13
View File
@@ -26,7 +26,6 @@
/* Begin PBXBuildFile section */
1420DF50196247F900203BB0 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1420DF4F196247F900203BB0 /* Images.xcassets */; };
1420DF51196247F900203BB0 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1420DF4F196247F900203BB0 /* Images.xcassets */; };
142E0E0019A6954400E4312B /* Sparkle.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* Sparkle.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
142E0E0219A6A14700E4312B /* Sparkle.framework in Copy Files */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* Sparkle.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
142E0E0419A6A26F00E4312B /* Autoupdate.app in CopyFiles */ = {isa = PBXBuildFile; fileRef = 55C14BB7136EEF1500649790 /* Autoupdate.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
@@ -78,6 +77,7 @@
5AD0FA7F1C73F2E2004BCEFF /* testappcast.xml in Resources */ = {isa = PBXBuildFile; fileRef = 5AD0FA7E1C73F2E2004BCEFF /* testappcast.xml */; };
5AE459001C34118500E3BB47 /* SUUpdaterTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 14950074195FDF5900BC5B5B /* SUUpdaterTest.m */; };
5AE459021C34118500E3BB47 /* SUVersionComparisonTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 61227A150DB548B800AB99EA /* SUVersionComparisonTest.m */; };
5AE7E1111DC81AD3009C2C12 /* AppIcon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 5AE7E10E1DC81ACA009C2C12 /* AppIcon.icns */; };
5AF6C74F1AEA46D10014A3AB /* test.sparkle_guided.pkg in Resources */ = {isa = PBXBuildFile; fileRef = 5AF6C74E1AEA46D10014A3AB /* test.sparkle_guided.pkg */; };
5AF6C7541AEA49840014A3AB /* SUInstallerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 5AF6C74C1AEA40760014A3AB /* SUInstallerTest.m */; };
5AF9DC3C1981DBEE001EA135 /* SUDSAVerifierTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 5AF9DC3B1981DBEE001EA135 /* SUDSAVerifierTest.m */; };
@@ -167,7 +167,6 @@
61F83F720DBFE140006FDD30 /* SUBasicUpdateDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 61F83F700DBFE137006FDD30 /* SUBasicUpdateDriver.m */; };
61F83F740DBFE141006FDD30 /* SUBasicUpdateDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 61F83F6F0DBFE137006FDD30 /* SUBasicUpdateDriver.h */; settings = {ATTRIBUTES = (); }; };
61FA52880E2D9EA400EF58AD /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* Sparkle.framework */; settings = {ATTRIBUTES = (Required, ); }; };
720B16441C66433D006985FB /* UITests-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 720B16421C66433D006985FB /* UITests-Info.plist */; };
720B16451C66433D006985FB /* SUTestApplicationTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 720B16431C66433D006985FB /* SUTestApplicationTest.swift */; };
7210C7681B9A9A1500EB90AC /* SUUnarchiverTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7210C7671B9A9A1500EB90AC /* SUUnarchiverTest.swift */; };
721BC2111D1DFF05002BC71E /* SUFileOperationConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 722954C31D04E66F00ECF9CA /* SUFileOperationConstants.m */; };
@@ -206,6 +205,8 @@
7275F9C11B5F1F2900B1D19E /* SUFileManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 7275F9BF1B5F1F2900B1D19E /* SUFileManager.h */; };
7275F9C21B5F1F2900B1D19E /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */; };
7275F9C31B5F1F2900B1D19E /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */; };
729924731DF3478A00DBCDF5 /* SUUpdateValidator.h in Headers */ = {isa = PBXBuildFile; fileRef = 729924711DF3478A00DBCDF5 /* SUUpdateValidator.h */; };
729924741DF3478A00DBCDF5 /* SUUpdateValidator.m in Sources */ = {isa = PBXBuildFile; fileRef = 729924721DF3478A00DBCDF5 /* SUUpdateValidator.m */; };
72A4A2401BB6567D00E7820D /* SUFileManagerTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 72A4A23F1BB6567D00E7820D /* SUFileManagerTest.swift */; };
72AC6B261B9AAC8800F62325 /* SparkleTestCodeSignApp.tar.gz in Resources */ = {isa = PBXBuildFile; fileRef = 72AC6B251B9AAC8800F62325 /* SparkleTestCodeSignApp.tar.gz */; };
72AC6B281B9AAD6700F62325 /* SparkleTestCodeSignApp.tar in Resources */ = {isa = PBXBuildFile; fileRef = 72AC6B271B9AAD6700F62325 /* SparkleTestCodeSignApp.tar */; };
@@ -538,6 +539,7 @@
55E6F33219EC9F6C00005E76 /* SUErrors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUErrors.h; sourceTree = "<group>"; };
5AA4DCD01C73E5510078F128 /* SUAppcastTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SUAppcastTest.swift; sourceTree = "<group>"; };
5AD0FA7E1C73F2E2004BCEFF /* testappcast.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = testappcast.xml; sourceTree = "<group>"; };
5AE7E10E1DC81ACA009C2C12 /* AppIcon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = AppIcon.icns; sourceTree = "<group>"; };
5AEF45D9189D1CC90030D7DC /* tr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = tr; path = tr.lproj/Sparkle.strings; sourceTree = "<group>"; };
5AF6C74C1AEA40760014A3AB /* SUInstallerTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUInstallerTest.m; sourceTree = "<group>"; };
5AF6C74E1AEA46D10014A3AB /* test.sparkle_guided.pkg */ = {isa = PBXFileReference; lastKnownFileType = file; path = test.sparkle_guided.pkg; sourceTree = "<group>"; };
@@ -678,6 +680,9 @@
722954C21D04E66F00ECF9CA /* SUFileOperationConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUFileOperationConstants.h; sourceTree = "<group>"; };
722954C31D04E66F00ECF9CA /* SUFileOperationConstants.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUFileOperationConstants.m; sourceTree = "<group>"; };
722954C81D04E89500ECF9CA /* ConfigFileop.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigFileop.xcconfig; sourceTree = "<group>"; };
722FB7471DD51331001D40CE /* ConfigSwift.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigSwift.xcconfig; sourceTree = "<group>"; };
722FB7481DD51350001D40CE /* ConfigSwiftDebug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigSwiftDebug.xcconfig; sourceTree = "<group>"; };
722FB7491DD51350001D40CE /* ConfigSwiftRelease.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigSwiftRelease.xcconfig; sourceTree = "<group>"; };
723A920D1D722438004A9DED /* SUSpotlightImporterTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SUSpotlightImporterTest.swift; sourceTree = "<group>"; };
723B252B1CEAB3A600909873 /* bscommon.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bscommon.c; sourceTree = "<group>"; };
723B252C1CEAB3A600909873 /* bscommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bscommon.h; sourceTree = "<group>"; };
@@ -688,6 +693,8 @@
726F2CE41BC9C33D001971A4 /* SUOperatingSystem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUOperatingSystem.m; sourceTree = "<group>"; };
7275F9BF1B5F1F2900B1D19E /* SUFileManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUFileManager.h; sourceTree = "<group>"; };
7275F9C01B5F1F2900B1D19E /* SUFileManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUFileManager.m; sourceTree = "<group>"; };
729924711DF3478A00DBCDF5 /* SUUpdateValidator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUUpdateValidator.h; sourceTree = "<group>"; };
729924721DF3478A00DBCDF5 /* SUUpdateValidator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUUpdateValidator.m; sourceTree = "<group>"; };
729F10FD1C65A9B500DFCCC5 /* ConfigUITest.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigUITest.xcconfig; sourceTree = "<group>"; };
729F10FE1C65A9B500DFCCC5 /* ConfigUITestCoverage.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigUITestCoverage.xcconfig; sourceTree = "<group>"; };
729F10FF1C65A9B500DFCCC5 /* ConfigUITestDebug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigUITestDebug.xcconfig; sourceTree = "<group>"; };
@@ -925,6 +932,7 @@
1420DF4F196247F900203BB0 /* Images.xcassets */,
14732BBC1960EFB500593899 /* README.markdown */,
14732BB91960EEEE00593899 /* SampleAppcast.xml */,
5AE7E10E1DC81ACA009C2C12 /* AppIcon.icns */,
615AE3CF0D64DC40001CA7BD /* SUModelTranslation.plist */,
);
path = Resources;
@@ -1131,6 +1139,8 @@
61CFB2C10E384958007A1735 /* Support */ = {
isa = PBXGroup;
children = (
729924711DF3478A00DBCDF5 /* SUUpdateValidator.h */,
729924721DF3478A00DBCDF5 /* SUUpdateValidator.m */,
61B078CC15A5FB6100600039 /* SUCodeSigningVerifier.h */,
61B078CD15A5FB6100600039 /* SUCodeSigningVerifier.m */,
61299A2D09CA2DAB00B7442F /* SUDSAVerifier.h */,
@@ -1221,6 +1231,9 @@
729F10FE1C65A9B500DFCCC5 /* ConfigUITestCoverage.xcconfig */,
729F10FF1C65A9B500DFCCC5 /* ConfigUITestDebug.xcconfig */,
729F11001C65A9B500DFCCC5 /* ConfigUITestRelease.xcconfig */,
722FB7471DD51331001D40CE /* ConfigSwift.xcconfig */,
722FB7481DD51350001D40CE /* ConfigSwiftDebug.xcconfig */,
722FB7491DD51350001D40CE /* ConfigSwiftRelease.xcconfig */,
14732BC91960F70A00593899 /* make-release-package.sh */,
14652F7919A93E5F00959E44 /* set-git-version-info.sh */,
146EC84E19A68CF8004A50C5 /* Sparkle.podspec */,
@@ -1253,6 +1266,7 @@
7275F9C11B5F1F2900B1D19E /* SUFileManager.h in Headers */,
767B61AC1972D488004E0C3C /* SUGuidedPackageInstaller.h in Headers */,
61EF67590E25C5B400F754E0 /* SUHost.h in Headers */,
729924731DF3478A00DBCDF5 /* SUUpdateValidator.h in Headers */,
723B25301CEAB3A600909873 /* bscommon.h in Headers */,
618FA5010DAE88B40026945C /* SUInstaller.h in Headers */,
55C14F06136EF6DB00649790 /* SULog.h in Headers */,
@@ -1461,10 +1475,11 @@
attributes = {
CLASSPREFIX = SU;
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0720;
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = "Sparkle Project";
TargetAttributes = {
612279D80DB5470200AB99EA = {
LastSwiftMigration = 0800;
TestTargetID = 8DC2EF4F0486A6940098B216;
};
722954B31D04ADAF00ECF9CA = {
@@ -1472,6 +1487,7 @@
};
726B2B5C1C645FC900388755 = {
CreatedOnToolsVersion = 7.2.1;
LastSwiftMigration = 0800;
TestTargetID = 61B5F90109C4CEE200B25A18;
};
};
@@ -1572,7 +1588,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
1420DF51196247F900203BB0 /* Images.xcassets in Resources */,
5AE7E1111DC81AD3009C2C12 /* AppIcon.icns in Resources */,
55C14FC7136F05E100649790 /* Sparkle.strings in Resources */,
55C14BD9136EF00C00649790 /* SUStatus.xib in Resources */,
);
@@ -1597,7 +1613,6 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
720B16441C66433D006985FB /* UITests-Info.plist in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1807,6 +1822,7 @@
61EF67560E25B58D00F754E0 /* SUHost.m in Sources */,
618FA5020DAE88B40026945C /* SUInstaller.m in Sources */,
55C14F07136EF6DB00649790 /* SULog.m in Sources */,
729924741DF3478A00DBCDF5 /* SUUpdateValidator.m in Sources */,
723B252D1CEAB3A600909873 /* bscommon.c in Sources */,
726F2CE61BC9C33D001971A4 /* SUOperatingSystem.m in Sources */,
618FA5230DAE8E8A0026945C /* SUPackageInstaller.m in Sources */,
@@ -2312,9 +2328,6 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 729F10FF1C65A9B500DFCCC5 /* ConfigUITestDebug.xcconfig */;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
};
@@ -2322,9 +2335,6 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 729F10FE1C65A9B500DFCCC5 /* ConfigUITestCoverage.xcconfig */;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Coverage;
};
@@ -2332,8 +2342,6 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 729F11001C65A9B500DFCCC5 /* ConfigUITestRelease.xcconfig */;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
};
name = Release;
};
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0710"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0710"
LastUpgradeVersion = "0800"
version = "2.0">
<BuildAction
parallelizeBuildables = "YES"
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0720"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
+2
View File
@@ -28,5 +28,7 @@
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>CFBundleIconFile</key>
<string>${ASSETCATALOG_COMPILER_APPICON_NAME}.icns</string>
</dict>
</plist>
+33 -105
View File
@@ -10,16 +10,14 @@
#import "SUHost.h"
#import "SUOperatingSystem.h"
#import "SUDSAVerifier.h"
#import "SUInstaller.h"
#import "SUStandardVersionComparator.h"
#import "SUUnarchiver.h"
#import "SUConstants.h"
#import "SULog.h"
#import "SUBinaryDeltaCommon.h"
#import "SUCodeSigningVerifier.h"
#import "SUUpdater_Private.h"
#import "SUFileManager.h"
#import "SUUpdateValidator.h"
@interface SUBasicUpdateDriver ()
@@ -31,6 +29,8 @@
@property (copy) NSString *tempDir;
@property (copy) NSString *relaunchPath;
@property (nonatomic) SUUpdateValidator *updateValidator;
@end
@implementation SUBasicUpdateDriver
@@ -43,6 +43,8 @@
@synthesize tempDir;
@synthesize relaunchPath;
@synthesize updateValidator = _updateValidator;
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)aHost
{
[super checkForUpdatesAtURL:URL host:aHost];
@@ -274,98 +276,6 @@
[self.download setDestination:self.downloadPath allowOverwrite:YES];
}
/**
* If the update is a package, then it must be signed using DSA. No other verification is done.
*
* If the update is a bundle, then it must meet any one of:
*
* * old and new DSA public keys are the same and valid (it allows change of Code Signing identity), or
*
* * old and new Code Signing identity are the same and valid
*
*/
- (BOOL)validateUpdateForHost:(SUHost *)host downloadedToPath:(NSString *)downloadedPath extractedToPath:(NSString *)extractedPath DSASignature:(NSString *)DSASignature
{
BOOL isPackage = NO;
NSString *installSourcePath = [SUInstaller installSourcePathInUpdateFolder:extractedPath forHost:self.host isPackage:&isPackage isGuided:NULL];
if (installSourcePath == nil) {
SULog(@"No suitable install is found in the update. The update will be rejected.");
return NO;
}
NSString *publicDSAKey = host.publicDSAKey;
// Modern packages are not distributed as bundles and are code signed differently than regular applications
if (isPackage) {
if (nil == publicDSAKey) {
SULog(@"The existing app bundle does not have a DSA key, so it can't verify installer packages.");
}
BOOL packageValidated = [SUDSAVerifier validatePath:downloadedPath withEncodedDSASignature:DSASignature withPublicDSAKey:publicDSAKey];
if (!packageValidated) {
SULog(@"DSA signature validation of the package failed. The update contains an installer package, and valid DSA signatures are mandatory for all installer packages. The update will be rejected. Sign the installer with a valid DSA key or use an .app bundle update instead.");
}
return packageValidated;
}
NSBundle *newBundle = [NSBundle bundleWithPath:installSourcePath];
if (newBundle == nil) {
SULog(@"No suitable bundle is found in the update. The update will be rejected.");
return NO;
}
SUHost *newHost = [[SUHost alloc] initWithBundle:newBundle];
NSString *newPublicDSAKey = newHost.publicDSAKey;
// Downgrade in DSA security should not be possible
if (publicDSAKey != nil && newPublicDSAKey == nil) {
SULog(@"A public DSA key is found in the old bundle but no public DSA key is found in the new update. For security reasons, the update will be rejected.");
return NO;
}
BOOL dsaKeysMatch = (publicDSAKey == nil || newPublicDSAKey == nil) ? NO : [publicDSAKey isEqualToString:newPublicDSAKey];
// If the new DSA key differs from the old, then this check is not a security measure, because the new key is not trusted.
// In that case, the check ensures that the app author has correctly used DSA keys, so that the app will be updateable in the next version.
// However if the new and old DSA keys are the same, then this is a security measure.
if (newPublicDSAKey != nil) {
if (![SUDSAVerifier validatePath:downloadedPath withEncodedDSASignature:DSASignature withPublicDSAKey:newPublicDSAKey]) {
SULog(@"DSA signature validation failed. The update has a public DSA key and is signed with a DSA key, but the %@ doesn't match the signature. The update will be rejected.",
dsaKeysMatch ? @"public key" : @"new public key shipped with the update");
return NO;
}
}
BOOL updateIsCodeSigned = [SUCodeSigningVerifier bundleAtURLIsCodeSigned:newHost.bundle.bundleURL];
if (dsaKeysMatch) {
NSError *error = nil;
if (updateIsCodeSigned && ![SUCodeSigningVerifier codeSignatureIsValidAtBundleURL:newHost.bundle.bundleURL error:&error]) {
SULog(@"The update archive has a valid DSA signature, but the app is also signed with Code Signing, which is corrupted: %@. The update will be rejected.", error);
return NO;
}
} else {
BOOL hostIsCodeSigned = [SUCodeSigningVerifier bundleAtURLIsCodeSigned:host.bundle.bundleURL];
NSString *dsaStatus = newPublicDSAKey ? @"has a new DSA key that doesn't match the previous one" : (publicDSAKey ? @"removes the DSA key" : @"isn't signed with a DSA key");
if (!hostIsCodeSigned || !updateIsCodeSigned) {
NSString *acsStatus = !hostIsCodeSigned ? @"old app hasn't been signed with app Code Signing" : @"new app isn't signed with app Code Signing";
SULog(@"The update archive %@, and the %@. At least one method of signature verification must be valid. The update will be rejected.", dsaStatus, acsStatus);
return NO;
}
NSError *error = nil;
if (![SUCodeSigningVerifier codeSignatureAtBundleURL:host.bundle.bundleURL matchesSignatureAtBundleURL:newHost.bundle.bundleURL error:&error]) {
SULog(@"The update archive %@, and the app is signed with a new Code Signing identity that doesn't match code signing of the original app: %@. At least one method of signature verification must be valid. The update will be rejected.", dsaStatus, error);
return NO;
}
}
return YES;
}
- (void)downloadDidFinish:(NSURLDownload *)__unused d
{
assert(self.updateItem);
@@ -407,13 +317,27 @@
- (void)extractUpdate
{
SUUnarchiver *unarchiver = [SUUnarchiver unarchiverForPath:self.downloadPath updatingHostBundlePath:self.host.bundlePath withPassword:self.updater.decryptionPassword];
BOOL success;
if (!unarchiver) {
SULog(@"Error: No valid unarchiver for %@!", self.downloadPath);
[self unarchiverDidFail:nil];
return;
success = NO;
} else {
// Currently unsafe archives are the only case where we can prevalidate before extraction, but that could change in the future
BOOL needsPrevalidation = [[unarchiver class] unsafeIfArchiveIsNotValidated];
self.updateValidator = [[SUUpdateValidator alloc] initWithDownloadPath:self.downloadPath dsaSignature:self.updateItem.DSASignature host:self.host performingPrevalidation:needsPrevalidation];
success = self.updateValidator.canValidate;
}
if (!success) {
[self unarchiverDidFail:nil];
} else {
unarchiver.delegate = self;
[unarchiver start];
}
unarchiver.delegate = self;
[unarchiver start];
}
- (void)failedToApplyDeltaUpdate
@@ -434,6 +358,9 @@
- (void)unarchiverDidFail:(SUUnarchiver *)__unused ua
{
// No longer needed
self.updateValidator = nil;
if ([self.updateItem isDeltaUpdate]) {
[self failedToApplyDeltaUpdate];
return;
@@ -476,13 +403,14 @@
- (void)installWithToolAndRelaunch:(BOOL)relaunch displayingUserInterface:(BOOL)showUI
{
assert(self.updateItem);
if (![self validateUpdateForHost:self.host downloadedToPath:self.downloadPath extractedToPath:self.tempDir DSASignature:self.updateItem.DSASignature])
{
assert(self.updateValidator);
BOOL validationCheckSuccess = [self.updateValidator validateWithUpdateDirectory:self.tempDir];
if (!validationCheckSuccess) {
NSDictionary *userInfo = @{
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil),
NSLocalizedFailureReasonErrorKey: SULocalizedString(@"The update is improperly signed.", nil),
};
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil),
NSLocalizedFailureReasonErrorKey: SULocalizedString(@"The update is improperly signed.", nil),
};
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUSignatureError userInfo:userInfo]];
return;
}
+5
View File
@@ -21,6 +21,11 @@
return [[path pathExtension] isEqualToString:@"delta"];
}
+ (BOOL)unsafeIfArchiveIsNotValidated
{
return YES;
}
// According to https://developer.apple.com/library/mac/documentation/Carbon/Conceptual/MDImporters/Concepts/Troubleshooting.html
// We should make sure mdimporter bundles have an up to date time in the event they were delta updated.
// We used to invoke mdimport on the bundle but this is not a very good approach.
+5
View File
@@ -18,6 +18,11 @@
return [[path pathExtension] isEqualToString:@"dmg"];
}
+ (BOOL)unsafeIfArchiveIsNotValidated
{
return NO;
}
// Called on a non-main thread.
- (void)extractDMG
{
+5
View File
@@ -41,6 +41,11 @@
return NULL;
}
+ (BOOL)unsafeIfArchiveIsNotValidated
{
return NO;
}
- (void)start
{
[NSThread detachNewThreadSelector:[[self class] selectorConformingToTypeOfPath:self.archivePath] toTarget:self withObject:nil];
+1 -1
View File
@@ -164,7 +164,7 @@
// Prevent malicious downgrades
if (!allowDowngrades) {
if ([comparator compareVersion:[host version] toVersion:[[NSBundle bundleWithPath:path] objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey]] == NSOrderedDescending) {
NSString *errorMessage = [NSString stringWithFormat:@"Sparkle Updater: Possible attack in progress! Attempting to \"upgrade\" from %@ to %@. Aborting update.", [host version], [[NSBundle bundleWithPath:path] objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey]];
NSString *errorMessage = [NSString stringWithFormat:@"For security reasons, updates that downgrade version of the application are not allowed. Refusing to downgrade app from version %@ to %@. Aborting update.", [host version], [[NSBundle bundleWithPath:path] objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey]];
NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUDowngradeError userInfo:@{ NSLocalizedDescriptionKey: errorMessage }];
[self finishInstallationToPath:installationPath withResult:NO error:error completionHandler:completionHandler];
return;
+1
View File
@@ -10,6 +10,7 @@
<connections>
<outlet property="actionButton" destination="12" id="34"/>
<outlet property="progressBar" destination="11" id="49"/>
<outlet property="statusTextField" destination="16" id="MiZ-Tn-yVg"/>
<outlet property="window" destination="5" id="25"/>
</connections>
</customObject>
+1
View File
@@ -15,6 +15,7 @@
@interface SUStatusController : SUWindowController
@property (weak) IBOutlet NSButton *actionButton;
@property (weak) IBOutlet NSProgressIndicator *progressBar;
@property (weak) IBOutlet NSTextField *statusTextField;
@property (copy) NSString *statusText;
@property double progressValue;
+9
View File
@@ -11,6 +11,7 @@
#import "SUAppcast.h"
#import "SUAppcastItem.h"
#import "SUVersionComparisonProtocol.h"
#import "SUOperatingSystem.h"
#import "SUStatusController.h"
#import "SUHost.h"
@@ -28,6 +29,7 @@
@synthesize host;
@synthesize actionButton;
@synthesize progressBar;
@synthesize statusTextField;
- (instancetype)initWithHost:(SUHost *)aHost
{
@@ -51,6 +53,13 @@
[[self window] center];
[[self window] setFrameAutosaveName:@"SUStatusFrame"];
[self.progressBar setUsesThreadedAnimation:YES];
if ([SUOperatingSystem isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){10, 11, 0}]) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpartial-availability"
[self.statusTextField setFont:[NSFont monospacedDigitSystemFontOfSize:0 weight:NSFontWeightRegular]];
#pragma clang diagnostic pop
}
}
- (NSString *)windowTitle
+22 -6
View File
@@ -115,10 +115,6 @@
[self.host setObject:nil forUserDefaultsKey:SUSkippedVersionKey];
switch (choice) {
case SUInstallUpdateChoice:
self.statusController = [[SUStatusController alloc] initWithHost:self.host];
[self.statusController beginActionWithTitle:SULocalizedString(@"Downloading update...", @"Take care not to overflow the status window.") maxProgressValue:0.0 statusText:nil];
[self.statusController setButtonTitle:SULocalizedString(@"Cancel", nil) target:self action:@selector(cancelDownload:) isDefault:NO];
[self.statusController showWindow:self];
[self downloadUpdate];
break;
@@ -138,6 +134,25 @@
}
}
- (void)downloadUpdate
{
BOOL createdStatusController = NO;
if (self.statusController == nil) {
self.statusController = [[SUStatusController alloc] initWithHost:self.host];
createdStatusController = YES;
}
[self.statusController beginActionWithTitle:SULocalizedString(@"Downloading update...", @"Take care not to overflow the status window.") maxProgressValue:0.0 statusText:nil];
[self.statusController setButtonTitle:SULocalizedString(@"Cancel", nil) target:self action:@selector(cancelDownload:) isDefault:NO];
[self.statusController setButtonEnabled:YES];
if (createdStatusController) {
[self.statusController showWindow:self];
}
[super downloadUpdate];
}
- (void)download:(NSURLDownload *)__unused download didReceiveResponse:(NSURLResponse *)response
{
[self.statusController setMaxProgressValue:[response expectedContentLength]];
@@ -167,8 +182,9 @@
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpartial-availability"
return [NSByteCountFormatter stringFromByteCount:value
countStyle:NSByteCountFormatterCountStyleFile];
NSByteCountFormatter *formatter = [[NSByteCountFormatter alloc] init];
[formatter setZeroPadsFractionDigits:YES];
return [formatter stringFromByteCount:value];
#pragma clang diagnostic pop
}
+3
View File
@@ -23,7 +23,10 @@
+ (SUUnarchiver *)unarchiverForPath:(NSString *)path updatingHostBundlePath:(NSString *)host withPassword:(NSString *)decryptionPassword;
+ (BOOL)unsafeIfArchiveIsNotValidated;
- (void)start;
@end
@protocol SUUnarchiverDelegate <NSObject>
+5
View File
@@ -55,6 +55,11 @@
return NO;
}
+ (BOOL)unsafeIfArchiveIsNotValidated
{
return NO;
}
- (void)notifyDelegateOfProgress:(double)progress
{
if ([self.delegate respondsToSelector:@selector(unarchiver:extractedProgress:)]) {
+25
View File
@@ -0,0 +1,25 @@
//
// SUUpdateValidator.h
// Sparkle
//
// Created by Mayur Pawashe on 12/3/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import <Foundation/Foundation.h>
@class SUHost;
@interface SUUpdateValidator : NSObject
// Pass YES to performingPrevalidation if archive validation must be done immediately, before extraction
- (instancetype)initWithDownloadPath:(NSString *)downloadPath dsaSignature:(NSString *)dsaSignature host:(SUHost *)host performingPrevalidation:(BOOL)performingPrevalidation;
// Indicates whether we can perform (post) validation later
@property (nonatomic, readonly) BOOL canValidate;
// precondition: validation must be possible (see -canValidate)
// This is "post" validation, after an archive has been extracted
- (BOOL)validateWithUpdateDirectory:(NSString *)updateDirectory;
@end
+192
View File
@@ -0,0 +1,192 @@
//
// SUUpdateValidator.m
// Sparkle
//
// Created by Mayur Pawashe on 12/3/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import "SUUpdateValidator.h"
#import "SUDSAVerifier.h"
#import "SUCodeSigningVerifier.h"
#import "SUInstaller.h"
#import "SUHost.h"
#import "SULog.h"
@interface SUUpdateValidator ()
@property (nonatomic, readonly) SUHost *host;
@property (nonatomic, readonly) BOOL prevalidatedDsaSignature;
@property (nonatomic, readonly) NSString *dsaSignature;
@property (nonatomic, readonly) NSString *downloadPath;
@end
@implementation SUUpdateValidator
@synthesize host = _host;
@synthesize canValidate = _canValidate;
@synthesize prevalidatedDsaSignature = _prevalidatedDsaSignature;
@synthesize dsaSignature = _dsaSignature;
@synthesize downloadPath = _downloadPath;
- (instancetype)initWithDownloadPath:(NSString *)downloadPath dsaSignature:(NSString *)dsaSignature host:(SUHost *)host performingPrevalidation:(BOOL)performingPrevalidation
{
self = [super init];
if (self != nil) {
BOOL canValidate;
BOOL prevalidatedDsaSignature;
if (performingPrevalidation) {
NSString *publicDSAKey = host.publicDSAKey;
if (publicDSAKey == nil) {
prevalidatedDsaSignature = NO;
SULog(@"Failed to validate update before unarchiving because no DSA key was found");
} else if (dsaSignature == nil) {
prevalidatedDsaSignature = NO;
SULog(@"Failed to validate update before unarchiving because no DSA signature was found");
} else {
prevalidatedDsaSignature = [SUDSAVerifier validatePath:downloadPath withEncodedDSASignature:dsaSignature withPublicDSAKey:publicDSAKey];
if (!prevalidatedDsaSignature) {
SULog(@"DSA signature validation before unarchiving failed for update %@", downloadPath);
}
}
canValidate = prevalidatedDsaSignature;
} else {
prevalidatedDsaSignature = NO;
canValidate = YES;
}
_canValidate = canValidate;
_prevalidatedDsaSignature = prevalidatedDsaSignature;
_downloadPath = [downloadPath copy];
_dsaSignature = [dsaSignature copy];
_host = host;
}
return self;
}
- (BOOL)validateWithUpdateDirectory:(NSString *)updateDirectory
{
assert(self.canValidate);
NSString *DSASignature = self.dsaSignature;
NSString *publicDSAKey = self.host.publicDSAKey;
NSString *downloadPath = self.downloadPath;
SUHost *host = self.host;
BOOL prevalidatedDsaSignature = self.prevalidatedDsaSignature;
BOOL validationCheckSuccess;
BOOL isPackage = NO;
// install source could point to a new bundle or a package
NSString *installSource = [SUInstaller installSourcePathInUpdateFolder:updateDirectory forHost:host isPackage:&isPackage isGuided:NULL];
if (installSource == nil) {
SULog(@"No suitable install is found in the update. The update will be rejected.");
validationCheckSuccess = NO;
} else {
NSURL *installSourceURL = [NSURL fileURLWithPath:installSource];
if (!prevalidatedDsaSignature) {
// Check to see if we have a package or bundle to validate
if (isPackage) {
// For package type updates, all we do is check if the DSA signature is valid
validationCheckSuccess = [SUDSAVerifier validatePath:downloadPath withEncodedDSASignature:DSASignature withPublicDSAKey:publicDSAKey];
if (!validationCheckSuccess) {
SULog(@"DSA signature validation of the package failed. The update contains an installer package, and valid DSA signatures are mandatory for all installer packages. The update will be rejected. Sign the installer with a valid DSA key or use an .app bundle update instead.");
}
} else {
// For application bundle updates, we check both the DSA and Apple code signing signatures
validationCheckSuccess = [self validateUpdateForHost:host downloadedToPath:downloadPath newBundleURL:installSourceURL DSASignature:DSASignature];
}
} else if (isPackage) {
// We shouldn't get here because we don't validate packages before extracting them currently
SULog(@"Error: not expecting to find package after being required to validate update before extraction");
validationCheckSuccess = NO;
} else {
// Because we already validated the DSA signature, this is just a consistency check to see
// if the developer signed their application properly with their Apple ID
// Currently, this case only gets hit for binary delta updates
NSError *error = nil;
if ([SUCodeSigningVerifier bundleAtURLIsCodeSigned:installSourceURL] && ![SUCodeSigningVerifier codeSignatureIsValidAtBundleURL:installSourceURL error:&error]) {
SULog(@"Failed to validate apple code sign signature on bundle after archive validation with error: %@", error);
validationCheckSuccess = NO;
} else {
validationCheckSuccess = YES;
}
}
}
return validationCheckSuccess;
}
/**
* If the update is a bundle, then it must meet any one of:
*
* * old and new DSA public keys are the same and valid (it allows change of Code Signing identity), or
*
* * old and new Code Signing identity are the same and valid
*
*/
- (BOOL)validateUpdateForHost:(SUHost *)host downloadedToPath:(NSString *)downloadedPath newBundleURL:(NSURL *)newBundleURL DSASignature:(NSString *)DSASignature
{
NSBundle *newBundle = [NSBundle bundleWithURL:newBundleURL];
if (newBundle == nil) {
SULog(@"No suitable bundle is found in the update. The update will be rejected.");
return NO;
}
NSString *publicDSAKey = host.publicDSAKey;
SUHost *newHost = [[SUHost alloc] initWithBundle:newBundle];
NSString *newPublicDSAKey = newHost.publicDSAKey;
// Downgrade in DSA security should not be possible
if (publicDSAKey != nil && newPublicDSAKey == nil) {
SULog(@"A public DSA key is found in the old bundle but no public DSA key is found in the new update. For security reasons, the update will be rejected.");
return NO;
}
BOOL dsaKeysMatch = (publicDSAKey == nil || newPublicDSAKey == nil) ? NO : [publicDSAKey isEqualToString:newPublicDSAKey];
// If the new DSA key differs from the old, then this check is not a security measure, because the new key is not trusted.
// In that case, the check ensures that the app author has correctly used DSA keys, so that the app will be updateable in the next version.
// However if the new and old DSA keys are the same, then this is a security measure.
if (newPublicDSAKey != nil) {
if (![SUDSAVerifier validatePath:downloadedPath withEncodedDSASignature:DSASignature withPublicDSAKey:newPublicDSAKey]) {
SULog(@"DSA signature validation failed. The update has a public DSA key and is signed with a DSA key, but the %@ doesn't match the signature. The update will be rejected.",
dsaKeysMatch ? @"public key" : @"new public key shipped with the update");
return NO;
}
}
BOOL updateIsCodeSigned = [SUCodeSigningVerifier bundleAtURLIsCodeSigned:newHost.bundle.bundleURL];
if (dsaKeysMatch) {
NSError *error = nil;
if (updateIsCodeSigned && ![SUCodeSigningVerifier codeSignatureIsValidAtBundleURL:newHost.bundle.bundleURL error:&error]) {
SULog(@"The update archive has a valid DSA signature, but the app is also signed with Code Signing, which is corrupted: %@. The update will be rejected.", error);
return NO;
}
} else {
BOOL hostIsCodeSigned = [SUCodeSigningVerifier bundleAtURLIsCodeSigned:host.bundle.bundleURL];
NSString *dsaStatus = newPublicDSAKey ? @"has a new DSA key that doesn't match the previous one" : (publicDSAKey ? @"removes the DSA key" : @"isn't signed with a DSA key");
if (!hostIsCodeSigned || !updateIsCodeSigned) {
NSString *acsStatus = !hostIsCodeSigned ? @"old app hasn't been signed with app Code Signing" : @"new app isn't signed with app Code Signing";
SULog(@"The update archive %@, and the %@. At least one method of signature verification must be valid. The update will be rejected.", dsaStatus, acsStatus);
return NO;
}
NSError *error = nil;
if (![SUCodeSigningVerifier codeSignatureAtBundleURL:host.bundle.bundleURL matchesSignatureAtBundleURL:newHost.bundle.bundleURL error:&error]) {
SULog(@"The update archive %@, and the app is signed with a new Code Signing identity that doesn't match code signing of the original app: %@. At least one method of signature verification must be valid. The update will be rejected.", dsaStatus, error);
return NO;
}
}
return YES;
}
@end
+136 -47
View File
@@ -32,62 +32,148 @@ SU_EXPORT @interface SUUpdater : NSObject
@property (unsafe_unretained) IBOutlet id<SUUpdaterDelegate> delegate;
/*!
The shared updater for the main bundle.
This is equivalent to passing [NSBundle mainBundle] to SUUpdater::updaterForBundle:
*/
+ (SUUpdater *)sharedUpdater;
/*!
The shared updater for a specified bundle.
If an updater has already been initialized for the provided bundle, that shared instance will be returned.
*/
+ (SUUpdater *)updaterForBundle:(NSBundle *)bundle;
/*!
Designated initializer for SUUpdater.
If an updater has already been initialized for the provided bundle, that shared instance will be returned.
*/
- (instancetype)initForBundle:(NSBundle *)bundle;
@property (readonly, strong) NSBundle *hostBundle;
@property (strong, readonly) NSBundle *sparkleBundle;
@property BOOL automaticallyChecksForUpdates;
@property NSTimeInterval updateCheckInterval;
/*!
* The URL of the appcast used to download update information.
*
* This property must be called on the main thread.
*/
@property (copy) NSURL *feedURL;
Explicitly checks for updates and displays a progress dialog while doing so.
@property (nonatomic, copy) NSString *userAgentString;
This method is meant for a main menu item.
Connect any menu item to this action in Interface Builder,
and Sparkle will check for updates and report back its findings verbosely
when it is invoked.
@property (copy) NSDictionary *httpHeaders;
@property BOOL sendsSystemProfile;
@property BOOL automaticallyDownloadsUpdates;
@property (nonatomic, copy) NSString *decryptionPassword;
/*!
Explicitly checks for updates and displays a progress dialog while doing so.
This method is meant for a main menu item.
Connect any menu item to this action in Interface Builder,
and Sparkle will check for updates and report back its findings verbosely
when it is invoked.
This will find updates that the user has opted into skipping.
*/
- (IBAction)checkForUpdates:(id)sender;
/*!
The menu item validation used for the -checkForUpdates: action
The menu item validation used for the -checkForUpdates: action
*/
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem;
/*!
Checks for updates, but does not display any UI unless an update is found.
Checks for updates, but does not display any UI unless an update is found.
This is meant for programmatically initating a check for updates. That is,
it will display no UI unless it actually finds an update, in which case it
proceeds as usual.
This is meant for programmatically initating a check for updates. That is,
it will display no UI unless it actually finds an update, in which case it
proceeds as usual.
If the fully automated updating is turned on, however, this will invoke that
behavior, and if an update is found, it will be downloaded and prepped for
installation.
If automatic downloading of updates it turned on and allowed, however,
this will invoke that behavior, and if an update is found, it will be downloaded
in the background silently and will be prepped for installation.
This will not find updates that the user has opted into skipping.
*/
- (void)checkForUpdatesInBackground;
/*!
A property indicating whether or not to check for updates automatically.
Setting this property will persist in the host bundle's user defaults.
The update schedule cycle will be reset in a short delay after the property's new value is set.
This is to allow reverting this property without kicking off a schedule change immediately
*/
@property BOOL automaticallyChecksForUpdates;
/*!
A property indicating whether or not updates can be automatically downloaded in the background.
Note that automatic downloading of updates can be disallowed by the developer
or by the user's system if silent updates cannot be done (eg: if they require authentication).
In this case, -automaticallyDownloadsUpdates will return NO regardless of how this property is set.
Setting this property will persist in the host bundle's user defaults.
*/
@property BOOL automaticallyDownloadsUpdates;
/*!
A property indicating the current automatic update check interval.
Setting this property will persist in the host bundle's user defaults.
The update schedule cycle will be reset in a short delay after the property's new value is set.
This is to allow reverting this property without kicking off a schedule change immediately
*/
@property NSTimeInterval updateCheckInterval;
/*!
Begins a "probing" check for updates which will not actually offer to
update to that version.
However, the delegate methods
SUUpdaterDelegate::updater:didFindValidUpdate: and
SUUpdaterDelegate::updaterDidNotFindUpdate: will be called,
so you can use that information in your UI.
Updates that have been skipped by the user will not be found.
*/
- (void)checkForUpdateInformation;
/*!
The URL of the appcast used to download update information.
Setting this property will persist in the host bundle's user defaults.
If you don't want persistence, you may want to consider instead implementing
SUUpdaterDelegate::feedURLStringForUpdater: or SUUpdaterDelegate::feedParametersForUpdater:sendingSystemProfile:
This property must be called on the main thread.
*/
@property (copy) NSURL *feedURL;
/*!
The host bundle that is being updated.
*/
@property (readonly, strong) NSBundle *hostBundle;
/*!
The bundle this class (SUUpdater) is loaded into.
*/
@property (strong, readonly) NSBundle *sparkleBundle;
/*!
The user agent used when checking for updates.
The default implementation can be overrided.
*/
@property (nonatomic, copy) NSString *userAgentString;
/*!
The HTTP headers used when checking for updates.
The keys of this dictionary are HTTP header fields (NSString) and values are corresponding values (NSString)
*/
@property (copy) NSDictionary *httpHeaders;
/*!
A property indicating whether or not the user's system profile information is sent when checking for updates.
Setting this property will persist in the host bundle's user defaults.
*/
@property BOOL sendsSystemProfile;
/*!
A property indicating the decryption password used for extracting updates shipped as Apple Disk Images (dmg)
*/
@property (nonatomic, copy) NSString *decryptionPassword;
/*!
Checks for updates and, if available, immediately downloads and installs them.
A progress dialog is shown but the user will never be prompted to read the
@@ -95,6 +181,9 @@ SU_EXPORT @interface SUUpdater : NSObject
You may want to respond to the userDidCancelDownload delegate method in case
the user clicks the "Cancel" button while the update is downloading.
If you are writing a UI-less background application, you probably want to instead use
SUUpdaterDelegate::updater:willInstallUpdateOnQuit:immediateInstallationInvocation:
*/
- (void)installUpdatesIfAvailable;
@@ -105,17 +194,6 @@ SU_EXPORT @interface SUUpdater : NSObject
*/
@property (readonly, copy) NSDate *lastUpdateCheckDate;
/*!
Begins a "probing" check for updates which will not actually offer to
update to that version.
However, the delegate methods
SUUpdaterDelegate::updater:didFindValidUpdate: and
SUUpdaterDelegate::updaterDidNotFindUpdate: will be called,
so you can use that information in your UI.
*/
- (void)checkForUpdateInformation;
/*!
Appropriately schedules or cancels the update checking timer according to
the preferences for time interval and automatic checks.
@@ -125,6 +203,12 @@ SU_EXPORT @interface SUUpdater : NSObject
*/
- (void)resetUpdateCycle;
/*!
A property indicating whether or not an update is in progress.
Note this property is not indicative of whether or not user initiated updates can be performed.
Use SUUpdater::validateMenuItem: for that instead.
*/
@property (readonly) BOOL updateInProgress;
@end
@@ -181,6 +265,9 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
Override this to dynamically specify the entire URL.
An alternative may be to use SUUpdaterDelegate::feedParametersForUpdater:sendingSystemProfile:
and let the server handle what kind of feed to provide.
\param updater The SUUpdater instance.
*/
- (NSString *)feedURLStringForUpdater:(SUUpdater *)updater;
@@ -347,6 +434,8 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
/*!
Called when an update is scheduled to be silently installed on quit.
This is after an update has been automatically downloaded in the background.
(i.e. SUUpdater::automaticallyDownloadsUpdates is YES)
\param updater The SUUpdater instance.
\param item The appcast item corresponding to the update that is proposed to be installed.
+9
View File
@@ -59,6 +59,15 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
static NSMutableDictionary *sharedUpdaters = nil;
static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaultsObservationContext";
#ifdef DEBUG
+ (void)load
{
// Debug builds have different configurations for update check intervals
// We're using NSLog instead of SULog here because we don't want to start Sparkle's logger here
NSLog(@"WARNING: This is running a Debug build of Sparkle; don't use this in production!");
}
#endif
+ (SUUpdater *)sharedUpdater
{
return [self updaterForBundle:[NSBundle mainBundle]];
+9 -9
View File
@@ -13,12 +13,12 @@ class SUAppcastTest: XCTestCase {
func testParseAppcast() {
let appcast = SUAppcast();
let testFile = NSBundle(forClass: SUAppcastTest.self).pathForResource("testappcast", ofType: "xml")!;
let testFileUrl = NSURL(fileURLWithPath: testFile);
let testFile = Bundle(for: SUAppcastTest.self).path(forResource: "testappcast", ofType: "xml")!;
let testFileUrl = URL(fileURLWithPath: testFile);
XCTAssertNotNil(testFileUrl);
do {
let items = try appcast.parseAppcastItemsFromXMLFile(testFileUrl) as! [SUAppcastItem];
let items = try appcast.parseAppcastItems(fromXMLFile: testFileUrl) as! [SUAppcastItem];
XCTAssertEqual(4, items.count);
@@ -41,20 +41,20 @@ class SUAppcastTest: XCTestCase {
// Test best appcast item & a delta update item
var deltaItem: SUAppcastItem? = nil
let bestAppcastItem = SUBasicUpdateDriver.bestItemFromAppcastItems(items, getDeltaItem: &deltaItem, withHostVersion: "1.0", comparator: SUStandardVersionComparator.defaultComparator())
let bestAppcastItem = SUBasicUpdateDriver.bestItem(fromAppcastItems: items, getDeltaItem: &deltaItem, withHostVersion: "1.0", comparator: SUStandardVersionComparator.default())
XCTAssertEqual(bestAppcastItem, items[1])
XCTAssertEqual(deltaItem!.fileURL.lastPathComponent, "3.0_from_1.0.patch")
// Test latest delta update item available
var latestDeltaItem: SUAppcastItem? = nil
SUBasicUpdateDriver.bestItemFromAppcastItems(items, getDeltaItem: &latestDeltaItem, withHostVersion: "2.0", comparator: SUStandardVersionComparator.defaultComparator())
SUBasicUpdateDriver.bestItem(fromAppcastItems: items, getDeltaItem: &latestDeltaItem, withHostVersion: "2.0", comparator: SUStandardVersionComparator.default())
XCTAssertEqual(latestDeltaItem!.fileURL.lastPathComponent, "3.0_from_2.0.patch")
// Test a delta item that does not exist
var nonexistantDeltaItem: SUAppcastItem? = nil
SUBasicUpdateDriver.bestItemFromAppcastItems(items, getDeltaItem: &nonexistantDeltaItem, withHostVersion: "2.1", comparator: SUStandardVersionComparator.defaultComparator())
SUBasicUpdateDriver.bestItem(fromAppcastItems: items, getDeltaItem: &nonexistantDeltaItem, withHostVersion: "2.1", comparator: SUStandardVersionComparator.default())
XCTAssertNil(nonexistantDeltaItem)
} catch let err as NSError {
@@ -65,12 +65,12 @@ class SUAppcastTest: XCTestCase {
func testNamespaces() {
let appcast = SUAppcast();
let testFile = NSBundle(forClass: SUAppcastTest.self).pathForResource("testnamespaces", ofType: "xml")!;
let testFileUrl = NSURL(fileURLWithPath: testFile);
let testFile = Bundle(for: SUAppcastTest.self).path(forResource: "testnamespaces", ofType: "xml")!;
let testFileUrl = URL(fileURLWithPath: testFile);
XCTAssertNotNil(testFileUrl);
do {
let items = try appcast.parseAppcastItemsFromXMLFile(testFileUrl) as! [SUAppcastItem];
let items = try appcast.parseAppcastItems(fromXMLFile: testFileUrl) as! [SUAppcastItem];
XCTAssertEqual(2, items.count);
+162 -162
View File
@@ -10,180 +10,180 @@ import XCTest
class SUFileManagerTest: XCTestCase
{
func makeTempFiles(testBlock: (SUFileManager, NSURL, NSURL, NSURL, NSURL, NSURL, NSURL) -> Void)
func makeTempFiles(_ testBlock: (SUFileManager, URL, URL, URL, URL, URL, URL) -> Void)
{
let fileManager = SUFileManager.defaultManager()
let fileManager = SUFileManager.default()
let tempDirectoryURL = try! fileManager.makeTemporaryDirectoryWithPreferredName("Sparkle Unit Test Data", appropriateForDirectoryURL: NSURL(fileURLWithPath: NSHomeDirectory()))
let tempDirectoryURL = try! fileManager?.makeTemporaryDirectory(withPreferredName: "Sparkle Unit Test Data", appropriateForDirectoryURL: URL(fileURLWithPath: NSHomeDirectory()))
defer {
try! fileManager.removeItemAtURL(tempDirectoryURL)
try! fileManager?.removeItem(at: tempDirectoryURL)
}
let ordinaryFileURL = tempDirectoryURL.URLByAppendingPathComponent("a file written by sparkles unit tests")
try! "foo".dataUsingEncoding(NSUTF8StringEncoding)!.writeToURL(ordinaryFileURL, options: .DataWritingAtomic)
let ordinaryFileURL = tempDirectoryURL?.appendingPathComponent("a file written by sparkles unit tests")
try! "foo".data(using: String.Encoding.utf8)!.write(to: ordinaryFileURL!, options: .atomic)
let directoryURL = tempDirectoryURL.URLByAppendingPathComponent("a directory written by sparkles unit tests")
try! NSFileManager.defaultManager().createDirectoryAtURL(directoryURL, withIntermediateDirectories: false, attributes: nil)
let directoryURL = tempDirectoryURL?.appendingPathComponent("a directory written by sparkles unit tests")
try! FileManager.default.createDirectory(at: directoryURL!, withIntermediateDirectories: false, attributes: nil)
let fileInDirectoryURL = directoryURL.URLByAppendingPathComponent("a file inside a directory written by sparkles unit tests")
try! "bar baz".dataUsingEncoding(NSUTF8StringEncoding)!.writeToURL(fileInDirectoryURL, options: .DataWritingAtomic)
let fileInDirectoryURL = directoryURL?.appendingPathComponent("a file inside a directory written by sparkles unit tests")
try! "bar baz".data(using: String.Encoding.utf8)!.write(to: fileInDirectoryURL!, options: .atomic)
let validSymlinkURL = tempDirectoryURL.URLByAppendingPathComponent("symlink test")
try! NSFileManager.defaultManager().createSymbolicLinkAtURL(validSymlinkURL, withDestinationURL: directoryURL)
let validSymlinkURL = tempDirectoryURL?.appendingPathComponent("symlink test")
try! FileManager.default.createSymbolicLink(at: validSymlinkURL!, withDestinationURL: directoryURL!)
let invalidSymlinkURL = tempDirectoryURL.URLByAppendingPathComponent("symlink test 2")
try! NSFileManager.defaultManager().createSymbolicLinkAtURL(invalidSymlinkURL, withDestinationURL: tempDirectoryURL.URLByAppendingPathComponent("does not exist"))
let invalidSymlinkURL = tempDirectoryURL?.appendingPathComponent("symlink test 2")
try! FileManager.default.createSymbolicLink(at: invalidSymlinkURL!, withDestinationURL: (tempDirectoryURL?.appendingPathComponent("does not exist"))!)
testBlock(fileManager, tempDirectoryURL, ordinaryFileURL, directoryURL, fileInDirectoryURL, validSymlinkURL, invalidSymlinkURL)
testBlock(fileManager!, tempDirectoryURL!, ordinaryFileURL!, directoryURL!, fileInDirectoryURL!, validSymlinkURL!, invalidSymlinkURL!)
}
func testMoveFiles()
{
makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL, validSymlinkURL, invalidSymlinkURL in
XCTAssertNil(try? fileManager.moveItemAtURL(ordinaryFileURL, toURL: directoryURL))
XCTAssertNil(try? fileManager.moveItemAtURL(ordinaryFileURL, toURL: directoryURL.URLByAppendingPathComponent("foo").URLByAppendingPathComponent("bar")))
XCTAssertNil(try? fileManager.moveItemAtURL(rootURL.URLByAppendingPathComponent("does not exist"), toURL: directoryURL))
XCTAssertNil(try? fileManager.moveItem(at: ordinaryFileURL, to: directoryURL))
XCTAssertNil(try? fileManager.moveItem(at: ordinaryFileURL, to: directoryURL.appendingPathComponent("foo").appendingPathComponent("bar")))
XCTAssertNil(try? fileManager.moveItem(at: rootURL.appendingPathComponent("does not exist"), to: directoryURL))
let newFileURL = (ordinaryFileURL.URLByDeletingLastPathComponent?.URLByAppendingPathComponent("new file"))!
try! fileManager.moveItemAtURL(ordinaryFileURL, toURL: newFileURL)
XCTAssertFalse(fileManager._itemExistsAtURL(ordinaryFileURL))
XCTAssertTrue(fileManager._itemExistsAtURL(newFileURL))
let newFileURL = (ordinaryFileURL.deletingLastPathComponent().appendingPathComponent("new file"))
try! fileManager.moveItem(at: ordinaryFileURL, to: newFileURL)
XCTAssertFalse(fileManager._itemExists(at: ordinaryFileURL))
XCTAssertTrue(fileManager._itemExists(at: newFileURL))
let newValidSymlinkURL = (ordinaryFileURL.URLByDeletingLastPathComponent?.URLByAppendingPathComponent("new symlink"))!
try! fileManager.moveItemAtURL(validSymlinkURL, toURL: newValidSymlinkURL)
XCTAssertFalse(fileManager._itemExistsAtURL(validSymlinkURL))
XCTAssertTrue(fileManager._itemExistsAtURL(newValidSymlinkURL))
XCTAssertTrue(fileManager._itemExistsAtURL(directoryURL))
let newValidSymlinkURL = (ordinaryFileURL.deletingLastPathComponent().appendingPathComponent("new symlink"))
try! fileManager.moveItem(at: validSymlinkURL, to: newValidSymlinkURL)
XCTAssertFalse(fileManager._itemExists(at: validSymlinkURL))
XCTAssertTrue(fileManager._itemExists(at: newValidSymlinkURL))
XCTAssertTrue(fileManager._itemExists(at: directoryURL))
let newInvalidSymlinkURL = (ordinaryFileURL.URLByDeletingLastPathComponent?.URLByAppendingPathComponent("new invalid symlink"))!
try! fileManager.moveItemAtURL(invalidSymlinkURL, toURL: newInvalidSymlinkURL)
XCTAssertFalse(fileManager._itemExistsAtURL(invalidSymlinkURL))
XCTAssertTrue(fileManager._itemExistsAtURL(newValidSymlinkURL))
let newInvalidSymlinkURL = (ordinaryFileURL.deletingLastPathComponent().appendingPathComponent("new invalid symlink"))
try! fileManager.moveItem(at: invalidSymlinkURL, to: newInvalidSymlinkURL)
XCTAssertFalse(fileManager._itemExists(at: invalidSymlinkURL))
XCTAssertTrue(fileManager._itemExists(at: newValidSymlinkURL))
let newDirectoryURL = (ordinaryFileURL.URLByDeletingLastPathComponent?.URLByAppendingPathComponent("new directory"))!
try! fileManager.moveItemAtURL(directoryURL, toURL: newDirectoryURL)
XCTAssertFalse(fileManager._itemExistsAtURL(directoryURL))
XCTAssertTrue(fileManager._itemExistsAtURL(newDirectoryURL))
XCTAssertFalse(fileManager._itemExistsAtURL(fileInDirectoryURL))
XCTAssertTrue(fileManager._itemExistsAtURL(newDirectoryURL.URLByAppendingPathComponent(fileInDirectoryURL.lastPathComponent!)))
let newDirectoryURL = (ordinaryFileURL.deletingLastPathComponent().appendingPathComponent("new directory"))
try! fileManager.moveItem(at: directoryURL, to: newDirectoryURL)
XCTAssertFalse(fileManager._itemExists(at: directoryURL))
XCTAssertTrue(fileManager._itemExists(at: newDirectoryURL))
XCTAssertFalse(fileManager._itemExists(at: fileInDirectoryURL))
XCTAssertTrue(fileManager._itemExists(at: newDirectoryURL.appendingPathComponent(fileInDirectoryURL.lastPathComponent)))
}
}
func testMoveFilesToTrash()
{
makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL, validSymlinkURL, invalidSymlinkURL in
XCTAssertNil(try? fileManager.moveItemAtURLToTrash(rootURL.URLByAppendingPathComponent("does not exist")))
XCTAssertNil(try? fileManager.moveItemAtURL(toTrash: rootURL.appendingPathComponent("does not exist")))
let trashURL = try! NSFileManager.defaultManager().URLForDirectory(.TrashDirectory, inDomain: .UserDomainMask, appropriateForURL: nil, create: false)
let trashURL = try! FileManager.default.url(for: .trashDirectory, in: .userDomainMask, appropriateFor: nil, create: false)
try! fileManager.moveItemAtURLToTrash(ordinaryFileURL)
XCTAssertFalse(fileManager._itemExistsAtURL(ordinaryFileURL))
try! fileManager.moveItemAtURL(toTrash: ordinaryFileURL)
XCTAssertFalse(fileManager._itemExists(at: ordinaryFileURL))
let ordinaryFileTrashURL = trashURL.URLByAppendingPathComponent(ordinaryFileURL.lastPathComponent!)
XCTAssertTrue(fileManager._itemExistsAtURL(ordinaryFileTrashURL))
try! fileManager.removeItemAtURL(ordinaryFileTrashURL)
let ordinaryFileTrashURL = trashURL.appendingPathComponent(ordinaryFileURL.lastPathComponent)
XCTAssertTrue(fileManager._itemExists(at: ordinaryFileTrashURL))
try! fileManager.removeItem(at: ordinaryFileTrashURL)
let validSymlinkTrashURL = trashURL.URLByAppendingPathComponent(validSymlinkURL.lastPathComponent!)
try! fileManager.moveItemAtURLToTrash(validSymlinkURL)
XCTAssertTrue(fileManager._itemExistsAtURL(validSymlinkTrashURL))
XCTAssertTrue(fileManager._itemExistsAtURL(directoryURL))
try! fileManager.removeItemAtURL(validSymlinkTrashURL)
let validSymlinkTrashURL = trashURL.appendingPathComponent(validSymlinkURL.lastPathComponent)
try! fileManager.moveItemAtURL(toTrash: validSymlinkURL)
XCTAssertTrue(fileManager._itemExists(at: validSymlinkTrashURL))
XCTAssertTrue(fileManager._itemExists(at: directoryURL))
try! fileManager.removeItem(at: validSymlinkTrashURL)
try! fileManager.moveItemAtURLToTrash(directoryURL)
XCTAssertFalse(fileManager._itemExistsAtURL(directoryURL))
XCTAssertFalse(fileManager._itemExistsAtURL(fileInDirectoryURL))
try! fileManager.moveItemAtURL(toTrash: directoryURL)
XCTAssertFalse(fileManager._itemExists(at: directoryURL))
XCTAssertFalse(fileManager._itemExists(at: fileInDirectoryURL))
let directoryTrashURL = trashURL.URLByAppendingPathComponent(directoryURL.lastPathComponent!)
XCTAssertTrue(fileManager._itemExistsAtURL(directoryTrashURL))
XCTAssertTrue(fileManager._itemExistsAtURL(directoryTrashURL.URLByAppendingPathComponent(fileInDirectoryURL.lastPathComponent!)))
let directoryTrashURL = trashURL.appendingPathComponent(directoryURL.lastPathComponent)
XCTAssertTrue(fileManager._itemExists(at: directoryTrashURL))
XCTAssertTrue(fileManager._itemExists(at: directoryTrashURL.appendingPathComponent(fileInDirectoryURL.lastPathComponent)))
try! fileManager.removeItemAtURL(directoryTrashURL)
try! fileManager.removeItem(at: directoryTrashURL)
}
}
func testCopyFiles()
{
makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL, validSymlinkURL, invalidSymlinkURL in
XCTAssertNil(try? fileManager.copyItemAtURL(ordinaryFileURL, toURL: directoryURL))
XCTAssertNil(try? fileManager.copyItemAtURL(ordinaryFileURL, toURL: directoryURL.URLByAppendingPathComponent("foo").URLByAppendingPathComponent("bar")))
XCTAssertNil(try? fileManager.copyItemAtURL(rootURL.URLByAppendingPathComponent("does not exist"), toURL: directoryURL))
XCTAssertNil(try? fileManager.copyItem(at: ordinaryFileURL, to: directoryURL))
XCTAssertNil(try? fileManager.copyItem(at: ordinaryFileURL, to: directoryURL.appendingPathComponent("foo").appendingPathComponent("bar")))
XCTAssertNil(try? fileManager.copyItem(at: rootURL.appendingPathComponent("does not exist"), to: directoryURL))
let newFileURL = (ordinaryFileURL.URLByDeletingLastPathComponent?.URLByAppendingPathComponent("new file"))!
try! fileManager.copyItemAtURL(ordinaryFileURL, toURL: newFileURL)
XCTAssertTrue(fileManager._itemExistsAtURL(ordinaryFileURL))
XCTAssertTrue(fileManager._itemExistsAtURL(newFileURL))
let newFileURL = (ordinaryFileURL.deletingLastPathComponent().appendingPathComponent("new file"))
try! fileManager.copyItem(at: ordinaryFileURL, to: newFileURL)
XCTAssertTrue(fileManager._itemExists(at: ordinaryFileURL))
XCTAssertTrue(fileManager._itemExists(at: newFileURL))
let newSymlinkURL = (ordinaryFileURL.URLByDeletingLastPathComponent?.URLByAppendingPathComponent("new symlink file"))!
try! fileManager.copyItemAtURL(invalidSymlinkURL, toURL: newSymlinkURL)
XCTAssertTrue(fileManager._itemExistsAtURL(newSymlinkURL))
let newSymlinkURL = (ordinaryFileURL.deletingLastPathComponent().appendingPathComponent("new symlink file"))
try! fileManager.copyItem(at: invalidSymlinkURL, to: newSymlinkURL)
XCTAssertTrue(fileManager._itemExists(at: newSymlinkURL))
let newDirectoryURL = (ordinaryFileURL.URLByDeletingLastPathComponent?.URLByAppendingPathComponent("new directory"))!
try! fileManager.copyItemAtURL(directoryURL, toURL: newDirectoryURL)
XCTAssertTrue(fileManager._itemExistsAtURL(directoryURL))
XCTAssertTrue(fileManager._itemExistsAtURL(newDirectoryURL))
XCTAssertTrue(fileManager._itemExistsAtURL(fileInDirectoryURL))
XCTAssertTrue(fileManager._itemExistsAtURL(newDirectoryURL.URLByAppendingPathComponent(fileInDirectoryURL.lastPathComponent!)))
let newDirectoryURL = (ordinaryFileURL.deletingLastPathComponent().appendingPathComponent("new directory"))
try! fileManager.copyItem(at: directoryURL, to: newDirectoryURL)
XCTAssertTrue(fileManager._itemExists(at: directoryURL))
XCTAssertTrue(fileManager._itemExists(at: newDirectoryURL))
XCTAssertTrue(fileManager._itemExists(at: fileInDirectoryURL))
XCTAssertTrue(fileManager._itemExists(at: newDirectoryURL.appendingPathComponent(fileInDirectoryURL.lastPathComponent)))
}
}
func testRemoveFiles()
{
makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL, validSymlinkURL, invalidSymlinkURL in
XCTAssertNil(try? fileManager.removeItemAtURL(rootURL.URLByAppendingPathComponent("does not exist")))
XCTAssertNil(try? fileManager.removeItem(at: rootURL.appendingPathComponent("does not exist")))
try! fileManager.removeItemAtURL(ordinaryFileURL)
XCTAssertFalse(fileManager._itemExistsAtURL(ordinaryFileURL))
try! fileManager.removeItem(at: ordinaryFileURL)
XCTAssertFalse(fileManager._itemExists(at: ordinaryFileURL))
try! fileManager.removeItemAtURL(validSymlinkURL)
XCTAssertFalse(fileManager._itemExistsAtURL(validSymlinkURL))
XCTAssertTrue(fileManager._itemExistsAtURL(directoryURL))
try! fileManager.removeItem(at: validSymlinkURL)
XCTAssertFalse(fileManager._itemExists(at: validSymlinkURL))
XCTAssertTrue(fileManager._itemExists(at: directoryURL))
try! fileManager.removeItemAtURL(directoryURL)
XCTAssertFalse(fileManager._itemExistsAtURL(directoryURL))
XCTAssertFalse(fileManager._itemExistsAtURL(fileInDirectoryURL))
try! fileManager.removeItem(at: directoryURL)
XCTAssertFalse(fileManager._itemExists(at: directoryURL))
XCTAssertFalse(fileManager._itemExists(at: fileInDirectoryURL))
}
}
func testReleaseFilesFromQuarantine()
{
makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL, validSymlinkURL, invalidSymlinkURL in
try! fileManager.releaseItemFromQuarantineAtRootURL(ordinaryFileURL)
try! fileManager.releaseItemFromQuarantineAtRootURL(directoryURL)
try! fileManager.releaseItemFromQuarantineAtRootURL(validSymlinkURL)
try! fileManager.releaseItemFromQuarantine(atRootURL: ordinaryFileURL)
try! fileManager.releaseItemFromQuarantine(atRootURL: directoryURL)
try! fileManager.releaseItemFromQuarantine(atRootURL: validSymlinkURL)
let quarantineData = "does not really matter what is here".cStringUsingEncoding(NSUTF8StringEncoding)!
let quarantineData = "does not really matter what is here".cString(using: String.Encoding.utf8)!
let quarantineDataLength = Int(strlen(quarantineData))
XCTAssertEqual(0, setxattr(ordinaryFileURL.path!, SUAppleQuarantineIdentifier, quarantineData, quarantineDataLength, 0, XATTR_CREATE))
XCTAssertGreaterThan(getxattr(ordinaryFileURL.path!, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW), 0)
XCTAssertEqual(0, setxattr(ordinaryFileURL.path, SUAppleQuarantineIdentifier, quarantineData, quarantineDataLength, 0, XATTR_CREATE))
XCTAssertGreaterThan(getxattr(ordinaryFileURL.path, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW), 0)
try! fileManager.releaseItemFromQuarantineAtRootURL(ordinaryFileURL)
XCTAssertEqual(-1, getxattr(ordinaryFileURL.path!, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW))
try! fileManager.releaseItemFromQuarantine(atRootURL: ordinaryFileURL)
XCTAssertEqual(-1, getxattr(ordinaryFileURL.path, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW))
XCTAssertEqual(0, setxattr(directoryURL.path!, SUAppleQuarantineIdentifier, quarantineData, quarantineDataLength, 0, XATTR_CREATE))
XCTAssertGreaterThan(getxattr(directoryURL.path!, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW), 0)
XCTAssertEqual(0, setxattr(directoryURL.path, SUAppleQuarantineIdentifier, quarantineData, quarantineDataLength, 0, XATTR_CREATE))
XCTAssertGreaterThan(getxattr(directoryURL.path, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW), 0)
XCTAssertEqual(0, setxattr(fileInDirectoryURL.path!, SUAppleQuarantineIdentifier, quarantineData, quarantineDataLength, 0, XATTR_CREATE))
XCTAssertGreaterThan(getxattr(fileInDirectoryURL.path!, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW), 0)
XCTAssertEqual(0, setxattr(fileInDirectoryURL.path, SUAppleQuarantineIdentifier, quarantineData, quarantineDataLength, 0, XATTR_CREATE))
XCTAssertGreaterThan(getxattr(fileInDirectoryURL.path, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW), 0)
// Extended attributes can't be set on symbolic links currently
try! fileManager.releaseItemFromQuarantineAtRootURL(validSymlinkURL)
XCTAssertGreaterThan(getxattr(directoryURL.path!, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW), 0)
XCTAssertEqual(-1, getxattr(validSymlinkURL.path!, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW))
try! fileManager.releaseItemFromQuarantine(atRootURL: validSymlinkURL)
XCTAssertGreaterThan(getxattr(directoryURL.path, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW), 0)
XCTAssertEqual(-1, getxattr(validSymlinkURL.path, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW))
try! fileManager.releaseItemFromQuarantineAtRootURL(directoryURL)
try! fileManager.releaseItemFromQuarantine(atRootURL: directoryURL)
XCTAssertEqual(-1, getxattr(directoryURL.path!, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW))
XCTAssertEqual(-1, getxattr(fileInDirectoryURL.path!, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW))
XCTAssertEqual(-1, getxattr(directoryURL.path, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW))
XCTAssertEqual(-1, getxattr(fileInDirectoryURL.path, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW))
}
}
func groupIDAtPath(path: String) -> gid_t
func groupIDAtPath(_ path: String) -> gid_t
{
let attributes = try! NSFileManager.defaultManager().attributesOfItemAtPath(path)
let groupID = attributes[NSFileGroupOwnerAccountID] as! NSNumber
return groupID.unsignedIntValue
let attributes = try! FileManager.default.attributesOfItem(atPath: path)
let groupID = attributes[FileAttributeKey.groupOwnerAccountID] as! NSNumber
return groupID.uint32Value
}
// Only the super user can alter user IDs, so changing user IDs is not tested here
@@ -191,126 +191,126 @@ class SUFileManagerTest: XCTestCase
func testAlterFilesGroupID()
{
makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL, validSymlinkURL, invalidSymlinkURL in
XCTAssertNil(try? fileManager.changeOwnerAndGroupOfItemAtRootURL(ordinaryFileURL, toMatchURL: rootURL.URLByAppendingPathComponent("does not exist")))
XCTAssertNil(try? fileManager.changeOwnerAndGroupOfItem(atRootURL: ordinaryFileURL, toMatch: rootURL.appendingPathComponent("does not exist")))
XCTAssertNil(try? fileManager.changeOwnerAndGroupOfItemAtRootURL(rootURL.URLByAppendingPathComponent("does not exist"), toMatchURL: ordinaryFileURL))
XCTAssertNil(try? fileManager.changeOwnerAndGroupOfItem(atRootURL: rootURL.appendingPathComponent("does not exist"), toMatch: ordinaryFileURL))
let everyoneGroup = getgrnam("everyone")
let everyoneGroupID = everyoneGroup.memory.gr_gid
let everyoneGroupID = everyoneGroup?.pointee.gr_gid
let staffGroup = getgrnam("staff")
let staffGroupID = staffGroup.memory.gr_gid
let staffGroupID = staffGroup?.pointee.gr_gid
XCTAssertNotEqual(staffGroupID, everyoneGroupID)
XCTAssertEqual(staffGroupID, self.groupIDAtPath(ordinaryFileURL.path!))
XCTAssertEqual(staffGroupID, self.groupIDAtPath(directoryURL.path!))
XCTAssertEqual(staffGroupID, self.groupIDAtPath(fileInDirectoryURL.path!))
XCTAssertEqual(staffGroupID, self.groupIDAtPath(validSymlinkURL.path!))
XCTAssertEqual(staffGroupID, self.groupIDAtPath(ordinaryFileURL.path))
XCTAssertEqual(staffGroupID, self.groupIDAtPath(directoryURL.path))
XCTAssertEqual(staffGroupID, self.groupIDAtPath(fileInDirectoryURL.path))
XCTAssertEqual(staffGroupID, self.groupIDAtPath(validSymlinkURL.path))
try! fileManager.changeOwnerAndGroupOfItemAtRootURL(fileInDirectoryURL, toMatchURL: ordinaryFileURL)
try! fileManager.changeOwnerAndGroupOfItemAtRootURL(ordinaryFileURL, toMatchURL: ordinaryFileURL)
try! fileManager.changeOwnerAndGroupOfItemAtRootURL(validSymlinkURL, toMatchURL: ordinaryFileURL)
try! fileManager.changeOwnerAndGroupOfItem(atRootURL: fileInDirectoryURL, toMatch: ordinaryFileURL)
try! fileManager.changeOwnerAndGroupOfItem(atRootURL: ordinaryFileURL, toMatch: ordinaryFileURL)
try! fileManager.changeOwnerAndGroupOfItem(atRootURL: validSymlinkURL, toMatch: ordinaryFileURL)
XCTAssertEqual(staffGroupID, self.groupIDAtPath(ordinaryFileURL.path!))
XCTAssertEqual(staffGroupID, self.groupIDAtPath(directoryURL.path!))
XCTAssertEqual(staffGroupID, self.groupIDAtPath(validSymlinkURL.path!))
XCTAssertEqual(staffGroupID, self.groupIDAtPath(ordinaryFileURL.path))
XCTAssertEqual(staffGroupID, self.groupIDAtPath(directoryURL.path))
XCTAssertEqual(staffGroupID, self.groupIDAtPath(validSymlinkURL.path))
XCTAssertEqual(0, chown(ordinaryFileURL.path!, getuid(), everyoneGroupID))
XCTAssertEqual(everyoneGroupID, self.groupIDAtPath(ordinaryFileURL.path!))
XCTAssertEqual(0, chown(ordinaryFileURL.path, getuid(), everyoneGroupID!))
XCTAssertEqual(everyoneGroupID, self.groupIDAtPath(ordinaryFileURL.path))
try! fileManager.changeOwnerAndGroupOfItemAtRootURL(fileInDirectoryURL, toMatchURL: ordinaryFileURL)
XCTAssertEqual(everyoneGroupID, self.groupIDAtPath(fileInDirectoryURL.path!))
try! fileManager.changeOwnerAndGroupOfItem(atRootURL: fileInDirectoryURL, toMatch: ordinaryFileURL)
XCTAssertEqual(everyoneGroupID, self.groupIDAtPath(fileInDirectoryURL.path))
try! fileManager.changeOwnerAndGroupOfItemAtRootURL(fileInDirectoryURL, toMatchURL: directoryURL)
XCTAssertEqual(staffGroupID, self.groupIDAtPath(fileInDirectoryURL.path!))
try! fileManager.changeOwnerAndGroupOfItem(atRootURL: fileInDirectoryURL, toMatch: directoryURL)
XCTAssertEqual(staffGroupID, self.groupIDAtPath(fileInDirectoryURL.path))
try! fileManager.changeOwnerAndGroupOfItemAtRootURL(validSymlinkURL, toMatchURL: ordinaryFileURL)
XCTAssertEqual(everyoneGroupID, self.groupIDAtPath(validSymlinkURL.path!))
try! fileManager.changeOwnerAndGroupOfItem(atRootURL: validSymlinkURL, toMatch: ordinaryFileURL)
XCTAssertEqual(everyoneGroupID, self.groupIDAtPath(validSymlinkURL.path))
try! fileManager.changeOwnerAndGroupOfItemAtRootURL(directoryURL, toMatchURL: ordinaryFileURL)
XCTAssertEqual(everyoneGroupID, self.groupIDAtPath(directoryURL.path!))
XCTAssertEqual(everyoneGroupID, self.groupIDAtPath(fileInDirectoryURL.path!))
try! fileManager.changeOwnerAndGroupOfItem(atRootURL: directoryURL, toMatch: ordinaryFileURL)
XCTAssertEqual(everyoneGroupID, self.groupIDAtPath(directoryURL.path))
XCTAssertEqual(everyoneGroupID, self.groupIDAtPath(fileInDirectoryURL.path))
}
}
func testUpdateFileModificationTime()
{
makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL, validSymlinkURL, invalidSymlinkURL in
XCTAssertNil(try? fileManager.updateModificationAndAccessTimeOfItemAtURL(rootURL.URLByAppendingPathComponent("does not exist")))
XCTAssertNil(try? fileManager.updateModificationAndAccessTimeOfItem(at: rootURL.appendingPathComponent("does not exist")))
let oldOrdinaryFileAttributes = try! NSFileManager.defaultManager().attributesOfItemAtPath(ordinaryFileURL.path!)
let oldDirectoryAttributes = try! NSFileManager.defaultManager().attributesOfItemAtPath(directoryURL.path!)
let oldValidSymlinkAttributes = try! NSFileManager.defaultManager().attributesOfItemAtPath(validSymlinkURL.path!)
let oldOrdinaryFileAttributes = try! FileManager.default.attributesOfItem(atPath: ordinaryFileURL.path)
let oldDirectoryAttributes = try! FileManager.default.attributesOfItem(atPath: directoryURL.path)
let oldValidSymlinkAttributes = try! FileManager.default.attributesOfItem(atPath: validSymlinkURL.path)
sleep(1); // wait for clock to advance
try! fileManager.updateModificationAndAccessTimeOfItemAtURL(ordinaryFileURL)
try! fileManager.updateModificationAndAccessTimeOfItemAtURL(directoryURL)
try! fileManager.updateModificationAndAccessTimeOfItemAtURL(validSymlinkURL)
try! fileManager.updateModificationAndAccessTimeOfItem(at: ordinaryFileURL)
try! fileManager.updateModificationAndAccessTimeOfItem(at: directoryURL)
try! fileManager.updateModificationAndAccessTimeOfItem(at: validSymlinkURL)
let newOrdinaryFileAttributes = try! NSFileManager.defaultManager().attributesOfItemAtPath(ordinaryFileURL.path!)
XCTAssertGreaterThan((newOrdinaryFileAttributes[NSFileModificationDate] as! NSDate).timeIntervalSinceDate(oldOrdinaryFileAttributes[NSFileModificationDate] as! NSDate), 0)
let newOrdinaryFileAttributes = try! FileManager.default.attributesOfItem(atPath: ordinaryFileURL.path)
XCTAssertGreaterThan((newOrdinaryFileAttributes[FileAttributeKey.modificationDate] as! Date).timeIntervalSince(oldOrdinaryFileAttributes[FileAttributeKey.modificationDate] as! Date), 0)
let newDirectoryAttributes = try! NSFileManager.defaultManager().attributesOfItemAtPath(directoryURL.path!)
XCTAssertGreaterThan((newDirectoryAttributes[NSFileModificationDate] as! NSDate).timeIntervalSinceDate(oldDirectoryAttributes[NSFileModificationDate] as! NSDate), 0)
let newDirectoryAttributes = try! FileManager.default.attributesOfItem(atPath: directoryURL.path)
XCTAssertGreaterThan((newDirectoryAttributes[FileAttributeKey.modificationDate] as! Date).timeIntervalSince(oldDirectoryAttributes[FileAttributeKey.modificationDate] as! Date), 0)
let newSymlinkAttributes = try! NSFileManager.defaultManager().attributesOfItemAtPath(validSymlinkURL.path!)
XCTAssertGreaterThan((newSymlinkAttributes[NSFileModificationDate] as! NSDate).timeIntervalSinceDate(oldValidSymlinkAttributes[NSFileModificationDate] as! NSDate), 0)
let newSymlinkAttributes = try! FileManager.default.attributesOfItem(atPath: validSymlinkURL.path)
XCTAssertGreaterThan((newSymlinkAttributes[FileAttributeKey.modificationDate] as! Date).timeIntervalSince(oldValidSymlinkAttributes[FileAttributeKey.modificationDate] as! Date), 0)
}
}
func testFileExists()
{
makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL, validSymlinkURL, invalidSymlinkURL in
XCTAssertTrue(fileManager._itemExistsAtURL(ordinaryFileURL))
XCTAssertTrue(fileManager._itemExistsAtURL(directoryURL))
XCTAssertFalse(fileManager._itemExistsAtURL(rootURL.URLByAppendingPathComponent("does not exist")))
XCTAssertTrue(fileManager._itemExists(at: ordinaryFileURL))
XCTAssertTrue(fileManager._itemExists(at: directoryURL))
XCTAssertFalse(fileManager._itemExists(at: rootURL.appendingPathComponent("does not exist")))
var isOrdinaryFileDirectory: ObjCBool = false
XCTAssertTrue(fileManager._itemExistsAtURL(ordinaryFileURL, isDirectory: &isOrdinaryFileDirectory) && !isOrdinaryFileDirectory)
XCTAssertTrue(fileManager._itemExists(at: ordinaryFileURL, isDirectory: &isOrdinaryFileDirectory) && !isOrdinaryFileDirectory.boolValue)
var isDirectoryADirectory: ObjCBool = false
XCTAssertTrue(fileManager._itemExistsAtURL(directoryURL, isDirectory: &isDirectoryADirectory) && isDirectoryADirectory)
XCTAssertTrue(fileManager._itemExists(at: directoryURL, isDirectory: &isDirectoryADirectory) && isDirectoryADirectory.boolValue)
XCTAssertFalse(fileManager._itemExistsAtURL(rootURL.URLByAppendingPathComponent("does not exist"), isDirectory: nil))
XCTAssertFalse(fileManager._itemExists(at: rootURL.appendingPathComponent("does not exist"), isDirectory: nil))
XCTAssertTrue(fileManager._itemExistsAtURL(validSymlinkURL))
XCTAssertTrue(fileManager._itemExists(at: validSymlinkURL))
var validSymlinkIsADirectory: ObjCBool = false
XCTAssertTrue(fileManager._itemExistsAtURL(validSymlinkURL, isDirectory: &validSymlinkIsADirectory) && !validSymlinkIsADirectory)
XCTAssertTrue(fileManager._itemExists(at: validSymlinkURL, isDirectory: &validSymlinkIsADirectory) && !validSymlinkIsADirectory.boolValue)
// Symlink should still exist even if it doesn't point to a file that exists
XCTAssertTrue(fileManager._itemExistsAtURL(invalidSymlinkURL))
XCTAssertTrue(fileManager._itemExists(at: invalidSymlinkURL))
var invalidSymlinkIsADirectory: ObjCBool = false
XCTAssertTrue(fileManager._itemExistsAtURL(invalidSymlinkURL, isDirectory: &invalidSymlinkIsADirectory) && !invalidSymlinkIsADirectory)
XCTAssertTrue(fileManager._itemExists(at: invalidSymlinkURL, isDirectory: &invalidSymlinkIsADirectory) && !invalidSymlinkIsADirectory.boolValue)
}
}
func testMakeDirectory()
{
makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL, validSymlinkURL, invalidSymlinkURL in
XCTAssertNil(try? fileManager.makeDirectoryAtURL(ordinaryFileURL))
XCTAssertNil(try? fileManager.makeDirectoryAtURL(directoryURL))
XCTAssertNil(try? fileManager.makeDirectory(at: ordinaryFileURL))
XCTAssertNil(try? fileManager.makeDirectory(at: directoryURL))
XCTAssertNil(try? fileManager.makeDirectoryAtURL(rootURL.URLByAppendingPathComponent("this should").URLByAppendingPathComponent("be a failure")))
XCTAssertNil(try? fileManager.makeDirectory(at: rootURL.appendingPathComponent("this should").appendingPathComponent("be a failure")))
let newDirectoryURL = rootURL.URLByAppendingPathComponent("new test directory")
XCTAssertFalse(fileManager._itemExistsAtURL(newDirectoryURL))
try! fileManager.makeDirectoryAtURL(newDirectoryURL)
let newDirectoryURL = rootURL.appendingPathComponent("new test directory")
XCTAssertFalse(fileManager._itemExists(at: newDirectoryURL))
try! fileManager.makeDirectory(at: newDirectoryURL)
var isDirectory: ObjCBool = false
XCTAssertTrue(fileManager._itemExistsAtURL(newDirectoryURL, isDirectory: &isDirectory))
XCTAssertTrue(fileManager._itemExists(at: newDirectoryURL, isDirectory: &isDirectory))
try! fileManager.removeItemAtURL(directoryURL)
XCTAssertNil(try? fileManager.makeDirectoryAtURL(validSymlinkURL))
try! fileManager.removeItem(at: directoryURL)
XCTAssertNil(try? fileManager.makeDirectory(at: validSymlinkURL))
}
}
func testAcquireBadAuthorization()
{
let fileManager = SUFileManager.defaultManager()
XCTAssertNil(try? fileManager._acquireAuthorization())
let fileManager = SUFileManager.default()
XCTAssertNil(try? fileManager?._acquireAuthorization())
}
}
+28 -28
View File
@@ -12,49 +12,49 @@ class SUSpotlightImporterTest: XCTestCase
{
func testUpdatingSpotlightBundles()
{
let fileManager = SUFileManager.defaultManager()
let tempDirectoryURL = try! fileManager.makeTemporaryDirectoryWithPreferredName("Sparkle Unit Test Data", appropriateForDirectoryURL: NSURL(fileURLWithPath: NSHomeDirectory()))
let fileManager = SUFileManager.default()
let tempDirectoryURL = try! fileManager?.makeTemporaryDirectory(withPreferredName: "Sparkle Unit Test Data", appropriateForDirectoryURL: URL(fileURLWithPath: NSHomeDirectory()))
let bundleDirectory = tempDirectoryURL.URLByAppendingPathComponent("bundle.app")
try! fileManager.makeDirectoryAtURL(bundleDirectory)
let bundleDirectory = tempDirectoryURL?.appendingPathComponent("bundle.app")
try! fileManager?.makeDirectory(at: bundleDirectory)
let innerDirectory = bundleDirectory.URLByAppendingPathComponent("foo")
try! fileManager.makeDirectoryAtURL(innerDirectory)
try! NSData().writeToURL(bundleDirectory.URLByAppendingPathComponent("bar"), options: .AtomicWrite)
let innerDirectory = bundleDirectory?.appendingPathComponent("foo")
try! fileManager?.makeDirectory(at: innerDirectory)
try! Data().write(to: (bundleDirectory?.appendingPathComponent("bar"))!, options: .atomicWrite)
let importerDirectory = innerDirectory.URLByAppendingPathComponent("baz.mdimporter")
let importerDirectory = innerDirectory?.appendingPathComponent("baz.mdimporter")
try! fileManager.makeDirectoryAtURL(importerDirectory)
try! fileManager.makeDirectoryAtURL(innerDirectory.URLByAppendingPathComponent("flag"))
try! fileManager?.makeDirectory(at: importerDirectory)
try! fileManager?.makeDirectory(at: innerDirectory?.appendingPathComponent("flag"))
try! NSData().writeToURL(importerDirectory.URLByAppendingPathComponent("file"), options: .AtomicWrite)
try! Data().write(to: (importerDirectory?.appendingPathComponent("file"))!, options: .atomicWrite)
let oldFooDirectoryAttributes = try! NSFileManager.defaultManager().attributesOfItemAtPath(innerDirectory.path!)
let oldBarFileAttributes = try! NSFileManager.defaultManager().attributesOfItemAtPath(bundleDirectory.URLByAppendingPathComponent("bar").path!)
let oldImporterAttributes = try! NSFileManager.defaultManager().attributesOfItemAtPath(importerDirectory.path!)
let oldFlagAttributes = try! NSFileManager.defaultManager().attributesOfItemAtPath(innerDirectory.URLByAppendingPathComponent("flag").path!)
let oldFileInImporterAttributes = try! NSFileManager.defaultManager().attributesOfItemAtPath(importerDirectory.URLByAppendingPathComponent("file").path!)
let oldFooDirectoryAttributes = try! FileManager.default.attributesOfItem(atPath: innerDirectory!.path)
let oldBarFileAttributes = try! FileManager.default.attributesOfItem(atPath: bundleDirectory!.appendingPathComponent("bar").path)
let oldImporterAttributes = try! FileManager.default.attributesOfItem(atPath: importerDirectory!.path)
let oldFlagAttributes = try! FileManager.default.attributesOfItem(atPath: innerDirectory!.appendingPathComponent("flag").path)
let oldFileInImporterAttributes = try! FileManager.default.attributesOfItem(atPath: importerDirectory!.appendingPathComponent("file").path)
sleep(1) // wait for clock to advance
// Update spotlight bundles
SUBinaryDeltaUnarchiver.updateSpotlightImportersAtBundlePath(bundleDirectory.path!)
SUBinaryDeltaUnarchiver.updateSpotlightImporters(atBundlePath: bundleDirectory!.path)
let newFooDirectoryAttributes = try! NSFileManager.defaultManager().attributesOfItemAtPath(innerDirectory.path!)
XCTAssertEqual((newFooDirectoryAttributes[NSFileModificationDate] as! NSDate).timeIntervalSinceDate(oldFooDirectoryAttributes[NSFileModificationDate] as! NSDate), 0)
let newFooDirectoryAttributes = try! FileManager.default.attributesOfItem(atPath: innerDirectory!.path)
XCTAssertEqual((newFooDirectoryAttributes[FileAttributeKey.modificationDate] as! Date).timeIntervalSince(oldFooDirectoryAttributes[FileAttributeKey.modificationDate] as! Date), 0)
let newBarFileAttributes = try! NSFileManager.defaultManager().attributesOfItemAtPath(bundleDirectory.URLByAppendingPathComponent("bar").path!)
XCTAssertEqual((newBarFileAttributes[NSFileModificationDate] as! NSDate).timeIntervalSinceDate(oldBarFileAttributes[NSFileModificationDate] as! NSDate), 0)
let newBarFileAttributes = try! FileManager.default.attributesOfItem(atPath: bundleDirectory!.appendingPathComponent("bar").path)
XCTAssertEqual((newBarFileAttributes[FileAttributeKey.modificationDate] as! Date).timeIntervalSince(oldBarFileAttributes[FileAttributeKey.modificationDate] as! Date), 0)
let newImporterAttributes = try! NSFileManager.defaultManager().attributesOfItemAtPath(importerDirectory.path!)
XCTAssertGreaterThan((newImporterAttributes[NSFileModificationDate] as! NSDate).timeIntervalSinceDate(oldImporterAttributes[NSFileModificationDate] as! NSDate), 0)
let newImporterAttributes = try! FileManager.default.attributesOfItem(atPath: importerDirectory!.path)
XCTAssertGreaterThan((newImporterAttributes[FileAttributeKey.modificationDate] as! Date).timeIntervalSince(oldImporterAttributes[FileAttributeKey.modificationDate] as! Date), 0)
let newFlagAttributes = try! NSFileManager.defaultManager().attributesOfItemAtPath(innerDirectory.URLByAppendingPathComponent("flag").path!)
XCTAssertEqual((newFlagAttributes[NSFileModificationDate] as! NSDate).timeIntervalSinceDate(oldFlagAttributes[NSFileModificationDate] as! NSDate), 0)
let newFlagAttributes = try! FileManager.default.attributesOfItem(atPath: innerDirectory!.appendingPathComponent("flag").path)
XCTAssertEqual((newFlagAttributes[FileAttributeKey.modificationDate] as! Date).timeIntervalSince(oldFlagAttributes[FileAttributeKey.modificationDate] as! Date), 0)
let newFileInImporterAttributes = try! NSFileManager.defaultManager().attributesOfItemAtPath(importerDirectory.URLByAppendingPathComponent("file").path!)
XCTAssertEqual((newFileInImporterAttributes[NSFileModificationDate] as! NSDate).timeIntervalSinceDate(oldFileInImporterAttributes[NSFileModificationDate] as! NSDate), 0)
let newFileInImporterAttributes = try! FileManager.default.attributesOfItem(atPath: importerDirectory!.appendingPathComponent("file").path)
XCTAssertEqual((newFileInImporterAttributes[FileAttributeKey.modificationDate] as! Date).timeIntervalSince(oldFileInImporterAttributes[FileAttributeKey.modificationDate] as! Date), 0)
try! fileManager.removeItemAtURL(tempDirectoryURL)
try! fileManager?.removeItem(at: tempDirectoryURL)
}
}
+18 -18
View File
@@ -14,52 +14,52 @@ class SUUnarchiverTest: XCTestCase, SUUnarchiverDelegate
var unarchivedExpectation: XCTestExpectation? = nil
var unarchivedResult: Bool = false
func unarchiver(unarchiver: SUUnarchiver!, extractedProgress progress: Double)
func unarchiver(_ unarchiver: SUUnarchiver!, extractedProgress progress: Double)
{
}
func unarchiverDidFail(unarchiver: SUUnarchiver!)
func unarchiverDidFail(_ unarchiver: SUUnarchiver!)
{
self.unarchivedResult = false
self.unarchivedExpectation!.fulfill()
}
func unarchiverDidFinish(unarchiver: SUUnarchiver!)
func unarchiverDidFinish(_ unarchiver: SUUnarchiver!)
{
self.unarchivedResult = true
self.unarchivedExpectation!.fulfill()
}
func unarchiveTestAppWithExtension(archiveExtension: String)
func unarchiveTestAppWithExtension(_ archiveExtension: String)
{
let appName = "SparkleTestCodeSignApp"
let archiveResourceURL = NSBundle(forClass: self.dynamicType).URLForResource(appName, withExtension: archiveExtension)!
let archiveResourceURL = Bundle(for: type(of: self)).url(forResource: appName, withExtension: archiveExtension)!
let fileManager = NSFileManager.defaultManager()
let fileManager = FileManager.default
let tempDirectoryURL = try! fileManager.URLForDirectory(.ItemReplacementDirectory, inDomain: .UserDomainMask, appropriateForURL: NSURL(fileURLWithPath: NSHomeDirectory()), create: true)
let tempDirectoryURL = try! fileManager.url(for: .itemReplacementDirectory, in: .userDomainMask, appropriateFor: URL(fileURLWithPath: NSHomeDirectory()), create: true)
defer {
try! fileManager.removeItemAtURL(tempDirectoryURL)
try! fileManager.removeItem(at: tempDirectoryURL)
}
let tempArchiveURL = tempDirectoryURL.URLByAppendingPathComponent(archiveResourceURL.lastPathComponent!)
let extractedAppURL = tempDirectoryURL.URLByAppendingPathComponent(appName).URLByAppendingPathExtension("app")
let tempArchiveURL = tempDirectoryURL.appendingPathComponent(archiveResourceURL.lastPathComponent)
let extractedAppURL = tempDirectoryURL.appendingPathComponent(appName).appendingPathExtension("app")
try! fileManager.copyItemAtURL(archiveResourceURL, toURL: tempArchiveURL)
try! fileManager.copyItem(at: archiveResourceURL, to: tempArchiveURL)
self.unarchivedExpectation = super.expectationWithDescription("Unarchived Application (format: \(archiveExtension))")
self.unarchivedExpectation = super.expectation(description: "Unarchived Application (format: \(archiveExtension))")
let unarchiver = SUUnarchiver(forPath: tempArchiveURL.path!, updatingHostBundlePath: nil, withPassword: self.password)
let unarchiver = SUUnarchiver(forPath: tempArchiveURL.path, updatingHostBundlePath: nil, withPassword: self.password)
unarchiver.delegate = self
unarchiver.start()
unarchiver?.delegate = self
unarchiver?.start()
super.waitForExpectationsWithTimeout(7.0, handler: nil)
super.waitForExpectations(timeout: 7.0, handler: nil)
XCTAssertTrue(self.unarchivedResult)
XCTAssertTrue(fileManager.fileExistsAtPath(extractedAppURL.path!))
XCTAssertTrue(fileManager.fileExists(atPath: extractedAppURL.path))
XCTAssertEqual("6a60ab31430cfca8fb499a884f4a29f73e59b472", hashOfTree(extractedAppURL.path!))
XCTAssertEqual("6a60ab31430cfca8fb499a884f4a29f73e59b472", hashOfTree(extractedAppURL.path))
}
func testUnarchivingZip()
+11 -11
View File
@@ -10,14 +10,14 @@ import XCTest
class SUTestApplicationTest: XCTestCase
{
var testApplicationURL: NSURL? = nil
var testApplicationBackupURL: NSURL? = nil
var tempDirectoryURL: NSURL? = nil
var testApplicationURL: URL? = nil
var testApplicationBackupURL: URL? = nil
var tempDirectoryURL: URL? = nil
func runningTestApplication() -> NSRunningApplication
{
// TODO: don't hardcode bundle ID?
let runningApplications = NSRunningApplication.runningApplicationsWithBundleIdentifier("org.sparkle-project.SparkleTestApp")
let runningApplications = NSRunningApplication.runningApplications(withBundleIdentifier: "org.sparkle-project.SparkleTestApp")
XCTAssertEqual(runningApplications.count, 1, "More than one or zero running instances of the Test Application are found")
return runningApplications[0]
}
@@ -35,11 +35,11 @@ class SUTestApplicationTest: XCTestCase
// When a successful test is over we'll revert the update
let testApplicationURL = self.runningTestApplication().bundleURL!
let tempDirectoryURL = try! NSFileManager.defaultManager().URLForDirectory(.ItemReplacementDirectory, inDomain: NSSearchPathDomainMask.UserDomainMask, appropriateForURL: testApplicationURL, create: true)
let tempDirectoryURL = try! FileManager.default.url(for: .itemReplacementDirectory, in: FileManager.SearchPathDomainMask.userDomainMask, appropriateFor: testApplicationURL, create: true)
let testApplicationBackupURL = tempDirectoryURL.URLByAppendingPathComponent(testApplicationURL.lastPathComponent!)
let testApplicationBackupURL = tempDirectoryURL.appendingPathComponent(testApplicationURL.lastPathComponent)
try! NSFileManager.defaultManager().copyItemAtURL(testApplicationURL, toURL: testApplicationBackupURL)
try! FileManager.default.copyItem(at: testApplicationURL, to: testApplicationBackupURL)
self.testApplicationURL = testApplicationURL
self.testApplicationBackupURL = testApplicationBackupURL
@@ -58,16 +58,16 @@ class SUTestApplicationTest: XCTestCase
// Revert our update with the original test application
var resultingURL: NSURL? = nil
try! NSFileManager.defaultManager().replaceItemAtURL(self.testApplicationURL!, withItemAtURL: self.testApplicationBackupURL!, backupItemName: nil, options: .UsingNewMetadataOnly, resultingItemURL: &resultingURL)
try! FileManager.default.replaceItem(at: self.testApplicationURL!, withItemAt: self.testApplicationBackupURL!, backupItemName: nil, options: .usingNewMetadataOnly, resultingItemURL: &resultingURL)
do {
try NSFileManager.defaultManager().removeItemAtURL(self.tempDirectoryURL!)
try FileManager.default.removeItem(at: self.tempDirectoryURL!)
} catch let error as NSError {
NSLog("Failed to remove temporary directory \(self.tempDirectoryURL) with error: \(error)")
}
// The URL we get back from NSFileManager should be the same..
XCTAssertEqual(self.testApplicationURL, resultingURL, "Test application was replaced, but at a different location")
XCTAssertEqual(self.testApplicationURL, resultingURL as URL?, "Test application was replaced, but at a different location")
super.tearDown()
}
@@ -91,7 +91,7 @@ class SUTestApplicationTest: XCTestCase
// Our new updated app should be launched now. Test if it's the active app
// We used to run into timing issues where the updated app sometimes may not show up as the frontmost one
XCTAssertTrue(self.runningTestApplication().active)
XCTAssertTrue(self.runningTestApplication().isActive)
// Grab another XCUIApplication instance rather than using the old one, just in case
let updatedApp = XCUIApplication()