-
Notifications
You must be signed in to change notification settings - Fork 53
[DNM] Investigate macOS keychain issue #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The |
#pragma mark - Version Compatibility | ||
|
||
- (void)FAILS_testVersionCompatibility_GetObject { | ||
// Given | ||
// - Object is set with old implementation. | ||
id oldMockCache = OCMPartialMock([[NSCache alloc] init]); | ||
GULKeychainStorageV7_7_0 *oldKeychainStorage = | ||
[[GULKeychainStorageV7_7_0 alloc] initWithService:kKeychainServiceName cache:oldMockCache]; | ||
|
||
[self assertSuccessWriteObject:@100 | ||
forKey:@"test-key1" | ||
toStorage:(GULKeychainStorage *)oldKeychainStorage | ||
withMockCache:oldMockCache]; | ||
|
||
// When | ||
// - App is updated to include a Google Utilities version greater than 7.7.0. | ||
|
||
// Then | ||
// - Object is retrieved with new implementation. | ||
[self.mockCache removeAllObjects]; | ||
[self assertSuccessReadObject:@100 | ||
forKey:@"test-key1" | ||
class:[NSNumber class] | ||
existsInCache:YES | ||
fromStorage:self.storage | ||
withMockCache:self.mockCache]; | ||
} | ||
|
||
- (void)testVersionCompatibility_SetObject { | ||
// Given | ||
// - Object is set with old implementation. | ||
id oldMockCache = OCMPartialMock([[NSCache alloc] init]); | ||
GULKeychainStorageV7_7_0 *oldKeychainStorage = | ||
[[GULKeychainStorageV7_7_0 alloc] initWithService:kKeychainServiceName cache:oldMockCache]; | ||
|
||
[self assertSuccessWriteObject:@100 | ||
forKey:@"test-key1" | ||
toStorage:(GULKeychainStorage *)oldKeychainStorage | ||
withMockCache:oldMockCache]; | ||
|
||
// When | ||
// - App is updated to include a Google Utilities version greater than 7.7.0. | ||
|
||
// Then | ||
// - The same object is updated with new implementation. | ||
[self assertSuccessWriteObject:@200 | ||
forKey:@"test-key1" | ||
toStorage:self.storage | ||
withMockCache:self.mockCache]; | ||
|
||
[self assertSuccessReadObject:@200 | ||
forKey:@"test-key1" | ||
class:[NSNumber class] | ||
existsInCache:YES | ||
fromStorage:self.storage | ||
withMockCache:self.mockCache]; | ||
|
||
[oldMockCache removeAllObjects]; | ||
[self assertSuccessReadObject:@200 | ||
forKey:@"test-key1" | ||
class:[NSNumber class] | ||
existsInCache:NO | ||
fromStorage:(GULKeychainStorage *)oldKeychainStorage | ||
withMockCache:oldMockCache]; | ||
} | ||
|
||
- (void)FAILS_testVersionCompatibility_RemoveObject { | ||
// Given | ||
// - Object is set with old implementation. | ||
[self assertNonExistingObjectForKey:@"test-key1" class:[NSNumber class]]; | ||
|
||
id oldMockCache = OCMPartialMock([[NSCache alloc] init]); | ||
GULKeychainStorageV7_7_0 *oldKeychainStorage = | ||
[[GULKeychainStorageV7_7_0 alloc] initWithService:kKeychainServiceName cache:oldMockCache]; | ||
|
||
[self assertSuccessWriteObject:@100 | ||
forKey:@"test-key1" | ||
toStorage:(GULKeychainStorage *)oldKeychainStorage | ||
withMockCache:oldMockCache]; | ||
|
||
// When | ||
// - App is updated to include a Google Utilities version greater than 7.7.0. | ||
|
||
// Then | ||
// - The same object is removed with new implementation. | ||
[self assertRemoveObjectForKey:@"test-key1"]; | ||
|
||
// The below assertion should not pass but does. | ||
[oldMockCache removeAllObjects]; | ||
[self assertSuccessReadObject:@100 | ||
forKey:@"test-key1" | ||
class:[NSNumber class] | ||
existsInCache:NO | ||
fromStorage:(GULKeychainStorage *)oldKeychainStorage | ||
withMockCache:oldMockCache]; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are three cases to check for version compatibility. The first and third tests are prefixed with FAILS_
as they fail locally. The other case passes.
The failures indicate two things:
- that when apps upgrade to the new implementation, they will not be able to receive any data that was stored with the previous implementation.
- that when apps upgrade to the new implementation, they will not be able to remove any data that was stored with the previous implementation.
if (@available(iOS 13.0, macOS 10.15, macCatalyst 13.0, tvOS 13.0, watchOS 6.0, *)) { | ||
query[(__bridge id)kSecUseDataProtectionKeychain] = (__bridge id)kCFBooleanTrue; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the necessary code to resolve the issue.
Actual fix is in #75 |
#no-changelog