diff --git a/Tests/SUCodeSigningVerifierTest.m b/Tests/SUCodeSigningVerifierTest.m index a2b7e764..43f91d7e 100644 --- a/Tests/SUCodeSigningVerifierTest.m +++ b/Tests/SUCodeSigningVerifierTest.m @@ -10,6 +10,7 @@ #import #import "NTSynchronousTask.h" #import "SUCodeSigningVerifier.h" +#import "SUFileManager.h" @interface SUCodeSigningVerifierTest : XCTestCase @@ -32,11 +33,24 @@ NSBundle *unitTestBundle = [NSBundle bundleForClass:[self class]]; NSString *unitTestBundleIdentifier = unitTestBundle.bundleIdentifier; NSString *zippedAppPath = [unitTestBundle pathForResource:@"SparkleTestCodeSignApp" ofType:@"zip"]; - NSString *tempDir = [NSTemporaryDirectory() stringByAppendingPathComponent:unitTestBundleIdentifier]; + + SUFileManager *fileManager = [SUFileManager fileManagerAllowingAuthorization:NO]; + + NSError *tempError = nil; + NSURL *tempDir = [fileManager makeTemporaryDirectoryWithPreferredName:unitTestBundleIdentifier appropriateForDirectoryURL:[NSURL fileURLWithPath:zippedAppPath] error:&tempError]; + + if (tempDir == nil) { + XCTFail(@"Failed to create temporary directory with error: %@", tempError); + return; + } + + NSString *tempDirPath = tempDir.path; + XCTAssertNotNil(tempDirPath); + NSError *error = nil; - if ([[NSFileManager defaultManager] createDirectoryAtPath:tempDir withIntermediateDirectories:YES attributes:nil error:&error]) { - if ([self unzip:zippedAppPath toPath:tempDir]) { - self.notSignedAppPath = [tempDir stringByAppendingPathComponent:@"SparkleTestCodeSignApp.app"]; + if ([[NSFileManager defaultManager] createDirectoryAtPath:tempDirPath withIntermediateDirectories:YES attributes:nil error:&error]) { + if ([self unzip:zippedAppPath toPath:tempDirPath]) { + self.notSignedAppPath = [tempDirPath stringByAppendingPathComponent:@"SparkleTestCodeSignApp.app"]; [self setupValidSignedApp]; [self setupInvalidSignedApp]; } @@ -54,13 +68,8 @@ [super tearDown]; if (self.notSignedAppPath) { - [[NSFileManager defaultManager] removeItemAtPath:self.notSignedAppPath error:nil]; - } - if (self.validSignedAppPath) { - [[NSFileManager defaultManager] removeItemAtPath:self.validSignedAppPath error:nil]; - } - if (self.invalidSignedAppPath) { - [[NSFileManager defaultManager] removeItemAtPath:self.invalidSignedAppPath error:nil]; + NSString *tempDir = [self.notSignedAppPath stringByDeletingLastPathComponent]; + [[NSFileManager defaultManager] removeItemAtPath:tempDir error:nil]; } } diff --git a/Tests/SUUpdaterTest.m b/Tests/SUUpdaterTest.m index 0e7d6e76..0ff7e930 100644 --- a/Tests/SUUpdaterTest.m +++ b/Tests/SUUpdaterTest.m @@ -24,7 +24,7 @@ { [super setUp]; self.queue = [[NSOperationQueue alloc] init]; - self.updater = [[SUUpdater alloc] init]; + self.updater = [[SUUpdater alloc] initForBundle:[NSBundle bundleForClass:[self class]]]; self.updater.delegate = self; } diff --git a/Tests/SparkleTests-Info.plist b/Tests/SparkleTests-Info.plist index 460a7d93..e7e83b9d 100644 --- a/Tests/SparkleTests-Info.plist +++ b/Tests/SparkleTests-Info.plist @@ -16,5 +16,11 @@ ???? CFBundleVersion 1.0 + SUEnableAutomaticChecks + + SUEnableSystemProfiling + + SUPublicDSAKeyFile + test-pubkey.pem