@@ -105,7 +105,7 @@ - (void)setUp {
105105 NSSet *attributes = [NSSet setWithArray: @[fileBasedKeychain]];
106106 _realLegacyGTMKeychainStore = [[GTMKeychainStore alloc ] initWithItemName: kKeychainName
107107 keychainAttributes: attributes];
108- #endif
108+ #endif // TARGET_OS_OSX || TARGET_OS_MACCATALYST
109109}
110110
111111- (void )tearDown {
@@ -127,7 +127,7 @@ - (void)tearDown {
127127 [_mockGTMOAuth2Compatibility stopMocking ];
128128#if TARGET_OS_OSX || TARGET_OS_MACCATALYST
129129 [_realLegacyGTMKeychainStore removeAuthSessionWithError: nil ];
130- #endif
130+ #endif // TARGET_OS_OSX || TARGET_OS_MACCATALYST
131131
132132 [super tearDown ];
133133}
@@ -188,11 +188,13 @@ - (void)testMigrateIfNeeded_KeychainFailure_DataProtectedMigration {
188188
189189- (void )testMigrateIfNeeded_NoPreviousMigration_GTMAppAuthMigration {
190190 [[[_mockUserDefaults stub ] andReturn: _mockUserDefaults] standardUserDefaults ];
191- [[[_mockUserDefaults expect ] andReturnValue: @NO ] boolForKey: kMigrationCheckPerformedKey ];
192- [[_mockUserDefaults expect ] setBool: YES forKey: kMigrationCheckPerformedKey ];
191+ [[[_mockUserDefaults expect ] andReturnValue: @NO ] boolForKey: kGTMAppAuthMigrationCheckPerformedKey ];
192+ [[_mockUserDefaults expect ] setBool: YES forKey: kGTMAppAuthMigrationCheckPerformedKey ];
193193
194194 [[_mockGTMKeychainStore expect ] saveAuthSession: OCMOCK_ANY error: OCMArg.anyObjectRef];
195195
196+ [self setUpCommonExtractAuthorizationMocksWithFingerPrint: kSavedFingerprint ];
197+
196198 GIDAuthStateMigration *migration =
197199 [[GIDAuthStateMigration alloc ] initWithKeychainStore: _mockGTMKeychainStore];
198200 [migration migrateIfNeededWithTokenURL: [NSURL URLWithString: kTokenURL ]
@@ -203,7 +205,7 @@ - (void)testMigrateIfNeeded_NoPreviousMigration_GTMAppAuthMigration {
203205
204206- (void )testMigrateIfNeeded_KeychainFailure_GTMAppAuthMigration {
205207 [[[_mockUserDefaults stub ] andReturn: _mockUserDefaults] standardUserDefaults ];
206- [[[_mockUserDefaults expect ] andReturnValue: @NO ] boolForKey: kMigrationCheckPerformedKey ];
208+ [[[_mockUserDefaults expect ] andReturnValue: @NO ] boolForKey: kGTMAppAuthMigrationCheckPerformedKey ];
207209
208210 NSError *keychainSaveError = [NSError new ];
209211 OCMStub ([_mockGTMKeychainStore saveAuthSession: OCMOCK_ANY error: [OCMArg setTo: keychainSaveError]]);
@@ -218,9 +220,30 @@ - (void)testMigrateIfNeeded_KeychainFailure_GTMAppAuthMigration {
218220 isFreshInstall: NO ];
219221}
220222
221- #endif
223+ - (void )testExtractAuthorization {
224+ [self setUpCommonExtractAuthorizationMocksWithFingerPrint: kSavedFingerprint ];
225+
226+ GIDAuthStateMigration *migration =
227+ [[GIDAuthStateMigration alloc ] initWithKeychainStore: _mockGTMKeychainStore];
228+ GTMAuthSession *authorization =
229+ [migration extractAuthSessionWithTokenURL: [NSURL URLWithString: kTokenURL ]
230+ callbackPath: kCallbackPath ];
222231
232+ XCTAssertNotNil (authorization);
233+ }
223234
235+ - (void )testExtractAuthorization_HostedDomain {
236+ [self setUpCommonExtractAuthorizationMocksWithFingerPrint: kSavedFingerprint_HostedDomain ];
237+
238+ GIDAuthStateMigration *migration =
239+ [[GIDAuthStateMigration alloc ] initWithKeychainStore: _mockGTMKeychainStore];
240+ GTMAuthSession *authorization =
241+ [migration extractAuthSessionWithTokenURL: [NSURL URLWithString: kTokenURL ]
242+ callbackPath: kCallbackPath ];
243+
244+ XCTAssertNotNil (authorization);
245+ }
246+ #endif
224247
225248- (void )testMigrateIfNeeded_HasPreviousMigration {
226249 [[[_mockUserDefaults stub ] andReturn: _mockUserDefaults] standardUserDefaults ];
@@ -242,9 +265,11 @@ - (void)testMigrateIfNeeded_HasPreviousMigration {
242265
243266- (void )testMigrateIfNeeded_isFreshInstall {
244267 [[[_mockUserDefaults stub ] andReturn: _mockUserDefaults] standardUserDefaults ];
245- [[[_mockUserDefaults expect ] andReturnValue: @NO ]
246- boolForKey: kMigrationCheckPerformedKey ];
247- [[_mockUserDefaults expect ] setBool: YES forKey: kMigrationCheckPerformedKey ];
268+ #if TARGET_OS_OSX || TARGET_OS_MACCATALYST
269+ [[_mockUserDefaults expect ] setBool: YES forKey: kDataProtectedMigrationCheckPerformedKey ];
270+ #else
271+ [[_mockUserDefaults expect ] setBool: YES forKey: kGTMAppAuthMigrationCheckPerformedKey ];
272+ #endif // TARGET_OS_OSX || TARGET_OS_MACCATALYST
248273
249274 GIDAuthStateMigration *migration =
250275 [[GIDAuthStateMigration alloc ] initWithKeychainStore: _mockGTMKeychainStore];
@@ -254,29 +279,7 @@ - (void)testMigrateIfNeeded_isFreshInstall {
254279 isFreshInstall: YES ];
255280}
256281
257- - (void )testExtractAuthorization {
258- [self setUpCommonExtractAuthorizationMocksWithFingerPrint: kSavedFingerprint ];
259-
260- GIDAuthStateMigration *migration =
261- [[GIDAuthStateMigration alloc ] initWithKeychainStore: _mockGTMKeychainStore];
262- GTMAuthSession *authorization =
263- [migration extractAuthSessionWithTokenURL: [NSURL URLWithString: kTokenURL ]
264- callbackPath: kCallbackPath ];
265-
266- XCTAssertNotNil (authorization);
267- }
268-
269- - (void )testExtractAuthorization_HostedDomain {
270- [self setUpCommonExtractAuthorizationMocksWithFingerPrint: kSavedFingerprint_HostedDomain ];
271282
272- GIDAuthStateMigration *migration =
273- [[GIDAuthStateMigration alloc ] initWithKeychainStore: _mockGTMKeychainStore];
274- GTMAuthSession *authorization =
275- [migration extractAuthSessionWithTokenURL: [NSURL URLWithString: kTokenURL ]
276- callbackPath: kCallbackPath ];
277-
278- XCTAssertNotNil (authorization);
279- }
280283
281284#pragma mark - Helpers
282285
0 commit comments