Skip to content

Commit c40fcf4

Browse files
authored
Merge branch 'camden-king/create-GIDAuthStateMigrationFake' into camden-king/remove-keychain-name-param
2 parents 83f59eb + 3a54ce8 commit c40fcf4

File tree

5 files changed

+15
-27
lines changed

5 files changed

+15
-27
lines changed

GoogleSignIn/Sources/GIDAuthStateMigration/Fake/GIDFakeAuthStateMigration.m

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ - (instancetype)initWithKeychainStore:(GTMKeychainStore *)keychainStore {
2727
return self;
2828
}
2929

30-
- (instancetype)init {
31-
return self;
32-
}
33-
3430
- (void)migrateIfNeededWithTokenURL:(NSURL *)tokenURL
3531
callbackPath:(NSString *)callbackPath
3632
isFreshInstall:(BOOL)isFreshInstall {

GoogleSignIn/Sources/GIDAuthStateMigration/Implementation/GIDAuthStateMigration.m

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,6 @@ - (void)performDataProtectedMigrationIfNeeded {
105105
if (authSession) {
106106
NSError *err;
107107
[self.keychainStore saveAuthSession:authSession error:&err];
108-
// If we're unable to save to the keychain, return without marking migration performed.
109-
if (err) {
110-
return;
111-
};
112108
[keychainStoreLegacy removeAuthSessionWithError:nil];
113109
}
114110

@@ -135,10 +131,6 @@ - (void)performGIDMigrationIfNeededWithTokenURL:(NSURL *)tokenURL
135131
if (authSession) {
136132
NSError *err;
137133
[self.keychainStore saveAuthSession:authSession error:&err];
138-
// If we're unable to save to the keychain, return without marking migration performed.
139-
if (err) {
140-
return;
141-
};
142134
}
143135

144136
// Mark the migration check as having been performed.

GoogleSignIn/Sources/GIDSignIn.m

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ + (GIDSignIn *)sharedInstance {
491491
GTMKeychainStore *keychainStore =
492492
[[GTMKeychainStore alloc] initWithItemName:kGTMAppAuthKeychainName];
493493
GIDAuthStateMigration *authStateMigrationService =
494-
[[GIDAuthStateMigration alloc] initWithKeychainStore:keychainStore];
494+
[[GIDAuthStateMigration alloc] initWithKeychainStore:keychainStore];
495495
#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
496496
if (@available(iOS 14.0, *)) {
497497
GIDAppCheck *appCheck = [GIDAppCheck appCheckUsingAppAttestProvider];
@@ -501,7 +501,8 @@ + (GIDSignIn *)sharedInstance {
501501
}
502502
#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
503503
if (!sharedInstance) {
504-
sharedInstance = [[self alloc] initWithKeychainStore:keychainStore authStateMigrationService:authStateMigrationService];
504+
sharedInstance = [[self alloc] initWithKeychainStore:keychainStore
505+
authStateMigrationService:authStateMigrationService];
505506
}
506507
});
507508
return sharedInstance;
@@ -566,8 +567,8 @@ - (instancetype)initWithKeychainStore:(GTMKeychainStore *)keychainStore
566567
_keychainStore = keychainStore;
567568
// Perform migration of auth state from old versions of the SDK if needed.
568569
[authStateMigrationService migrateIfNeededWithTokenURL:_appAuthConfiguration.tokenEndpoint
569-
callbackPath:kBrowserCallbackPath
570-
isFreshInstall:isFreshInstall];
570+
callbackPath:kBrowserCallbackPath
571+
isFreshInstall:isFreshInstall];
571572
}
572573
return self;
573574
}
@@ -576,7 +577,8 @@ - (instancetype)initWithKeychainStore:(GTMKeychainStore *)keychainStore
576577
- (instancetype)initWithKeychainStore:(GTMKeychainStore *)keychainStore
577578
authStateMigrationService:(GIDAuthStateMigration *) authStateMigrationService
578579
appCheck:(GIDAppCheck *)appCheck {
579-
self = [self initWithKeychainStore:keychainStore authStateMigrationService:authStateMigrationService];
580+
self = [self initWithKeychainStore:keychainStore
581+
authStateMigrationService:authStateMigrationService];
580582
if (self) {
581583
_appCheck = appCheck;
582584
_configureAppCheckCalled = NO;

GoogleSignIn/Tests/Unit/GIDAuthStateMigrationTest.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ - (void)testMigrateIfNeeded_KeychainFailure_DataProtectedMigration {
179179
[migration migrateIfNeededWithTokenURL:[NSURL URLWithString:kTokenURL]
180180
callbackPath:kCallbackPath
181181
isFreshInstall:NO];
182-
XCTAssertNotNil([_realLegacyGTMKeychainStore retrieveAuthSessionWithError:nil]);
182+
XCTAssertNil([_realLegacyGTMKeychainStore retrieveAuthSessionWithError:nil]);
183183
}
184184

185185
#else

GoogleSignIn/Tests/Unit/GIDSignInTest.m

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ @interface GIDSignInTest : XCTestCase {
222222
// Whether callback block has been called.
223223
BOOL _completionCalled;
224224

225-
// Fake for GIDAuthStateMigration
225+
// Fake for |GIDAuthStateMigration|.
226226
GIDFakeAuthStateMigration *_authStateMigrationService;
227227

228228
// Fake fetcher service to emulate network requests.
@@ -500,16 +500,14 @@ - (void)testInitWithKeychainStore_invalidConfig {
500500
- (void)testInitWithKeychainStore_attemptsMigration {
501501
XCTestExpectation *expectation = [self expectationWithDescription:@"Callback should be called."];
502502
_authStateMigrationService.migrationInvokedCallback =
503-
^(NSURL *tokenURL, NSString *callbackPath, BOOL isFreshInstall) {
504-
XCTAssertFalse(isFreshInstall);
505-
[expectation fulfill];
506-
};
503+
^(NSURL *tokenURL, NSString *callbackPath, BOOL isFreshInstall) {
504+
XCTAssertFalse(isFreshInstall);
505+
[expectation fulfill];
506+
};
507507

508508
GTMKeychainStore *store = [[GTMKeychainStore alloc] initWithItemName:kKeychainName];
509-
GIDSignIn *signIn;
510-
signIn = [[GIDSignIn alloc] initWithKeychainStore:store
511-
authStateMigrationService:_authStateMigrationService];
512-
509+
GIDSignIn *signIn = [[GIDSignIn alloc] initWithKeychainStore:store
510+
authStateMigrationService:_authStateMigrationService];
513511
[self waitForExpectationsWithTimeout:1 handler:nil];
514512
}
515513

0 commit comments

Comments
 (0)