From 30d4a5eb5c1376f177b836a4e753238f0774bdd3 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sun, 4 Sep 2016 18:22:24 -0400 Subject: [PATCH] Merge code sign test changes from master --- CHANGELOG | 2 ++ Tests/SUCodeSigningVerifierTest.m | 18 ++++++------------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 8d1558e0..717c8bf1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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) diff --git a/Tests/SUCodeSigningVerifierTest.m b/Tests/SUCodeSigningVerifierTest.m index d94316b1..f52dae7b 100644 --- a/Tests/SUCodeSigningVerifierTest.m +++ b/Tests/SUCodeSigningVerifierTest.m @@ -81,16 +81,12 @@ NSURL *tempDir = [self.notSignedAppURL URLByDeletingLastPathComponent]; NSURL *signedAndValid = [tempDir URLByAppendingPathComponent:@"valid-signed.app"]; - if ([signedAndValid checkResourceIsReachableAndReturnError:NULL]) { - [[NSFileManager defaultManager] removeItemAtURL:signedAndValid error:NULL]; - } - + [[NSFileManager defaultManager] removeItemAtURL:signedAndValid error:NULL]; if (![[NSFileManager defaultManager] copyItemAtURL:self.notSignedAppURL toURL:signedAndValid error:&error]) { XCTFail("Failed to copy %@ to %@ with error: %@", self.notSignedAppURL, signedAndValid, error); } self.validSignedAppURL = signedAndValid; - if (![SUAdHocCodeSigning codeSignApplicationAtPath:self.validSignedAppURL.path]) { NSLog(@"Failed to codesign %@", self.validSignedAppURL); } @@ -101,9 +97,7 @@ NSURL *tempDir = [self.notSignedAppURL URLByDeletingLastPathComponent]; NSURL *calculatorCopy = [tempDir URLByAppendingPathComponent:@"calc.app"]; - if ([calculatorCopy checkResourceIsReachableAndReturnError:NULL]) { - [[NSFileManager defaultManager] removeItemAtURL:calculatorCopy error:NULL]; - } + [[NSFileManager defaultManager] removeItemAtURL:calculatorCopy error:NULL]; // Make a copy of the signed calculator app so we can match signatures later // Matching signatures on ad-hoc signed apps does *not* work @@ -119,7 +113,9 @@ // Alter the signed copy slightly, this won't invalidate signature matching (although it will invalidate the integrity part of the signature) // Which is what we want. If a user alters an app bundle, we should still be able to update as long as its identity is still valid NSError *removeError = nil; - if (![[NSFileManager defaultManager] removeItemAtURL:[[calculatorCopy URLByAppendingPathComponent:@"Contents"] URLByAppendingPathComponent:@"PkgInfo"] error:&removeError]) { + NSURL *calculatorPkgInfo = [[calculatorCopy URLByAppendingPathComponent:@"Contents"] URLByAppendingPathComponent:@"PkgInfo"]; + XCTAssertNotNil(calculatorPkgInfo); + if (![[NSFileManager defaultManager] removeItemAtURL:calculatorPkgInfo error:&removeError]) { XCTFail(@"Failed to remove file in calculator copy with error: %@", removeError); } @@ -132,9 +128,7 @@ NSURL *tempDir = [self.notSignedAppURL URLByDeletingLastPathComponent]; NSURL *signedAndInvalid = [tempDir URLByAppendingPathComponent:@"invalid-signed.app"]; - if ([signedAndInvalid checkResourceIsReachableAndReturnError:NULL]) { - [[NSFileManager defaultManager] removeItemAtURL:signedAndInvalid error:NULL]; - } + [[NSFileManager defaultManager] removeItemAtURL:signedAndInvalid error:NULL]; if ([[NSFileManager defaultManager] copyItemAtURL:self.notSignedAppURL toURL:signedAndInvalid error:&error]) { self.invalidSignedAppURL = signedAndInvalid; if ([SUAdHocCodeSigning codeSignApplicationAtPath:self.invalidSignedAppURL.path]) {