Fix issues with unit tests

I added public DSA file, automatic update checking, disabled system profiling
in the unit test's info.plist so that SUUpdater won't complain that DSA is missing,
and it won't prompt for update permission the first time.

I also made SUUpdater use the correct bundle in SUUpdaterTest
This commit is contained in:
Zorg committed 2016-03-13 22:27:57 -04:00
1 parent b319fb50f9
commit b8fecf1f36
3 files changed
+27 -12

No files matched your search

+20 -11
View File
@@ -10,6 +10,7 @@
#import <XCTest/XCTest.h>
#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];
}
}
+1 -1
View File
@@ -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;
}
+6
View File
@@ -16,5 +16,11 @@
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>SUEnableAutomaticChecks</key>
<true/>
<key>SUEnableSystemProfiling</key>
<false/>
<key>SUPublicDSAKeyFile</key>
<string>test-pubkey.pem</string>
</dict>
</plist>