From 56c1a1a2a7bc1d290f5780f6964306982386943e Mon Sep 17 00:00:00 2001 From: Akshat Gandhi <54901287+AkshatG6@users.noreply.github.com> Date: Fri, 19 Sep 2025 13:15:17 -0700 Subject: [PATCH 1/6] Updated Add Scopes to include previously requested tokenClaims in the options --- GoogleSignIn/Sources/GIDSignIn.m | 45 +++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/GoogleSignIn/Sources/GIDSignIn.m b/GoogleSignIn/Sources/GIDSignIn.m index 4da18b2c..0125052f 100644 --- a/GoogleSignIn/Sources/GIDSignIn.m +++ b/GoogleSignIn/Sources/GIDSignIn.m @@ -367,6 +367,14 @@ - (void)addScopes:(NSArray *)scopes addScopesFlow:YES completion:completion]; + OIDAuthorizationRequest *lastAuthorizationRequest = + self.currentUser.authState.lastAuthorizationResponse.request; + NSString *lastTokenClaimsAsJSON = + lastAuthorizationRequest.additionalParameters[kTokenClaimsParameter]; + if (lastTokenClaimsAsJSON) { + options.tokenClaimsAsJSON = lastTokenClaimsAsJSON; + } + NSSet *requestedScopes = [NSSet setWithArray:scopes]; NSMutableSet *grantedScopes = [NSMutableSet setWithArray:self.currentUser.grantedScopes]; @@ -499,6 +507,14 @@ - (void)addScopes:(NSArray *)scopes addScopesFlow:YES completion:completion]; + OIDAuthorizationRequest *lastAuthorizationRequest = + self.currentUser.authState.lastAuthorizationResponse.request; + NSString *lastTokenClaimsAsJSON = + lastAuthorizationRequest.additionalParameters[kTokenClaimsParameter]; + if (lastTokenClaimsAsJSON) { + options.tokenClaimsAsJSON = lastTokenClaimsAsJSON; + } + NSSet *requestedScopes = [NSSet setWithArray:scopes]; NSMutableSet *grantedScopes = [NSMutableSet setWithArray:self.currentUser.grantedScopes]; @@ -739,20 +755,23 @@ - (void)signInWithOptions:(GIDSignInInternalOptions *)options { } }]; } else { - NSError *claimsError; - - // If tokenClaims are invalid or JSON serialization fails, return with an error. - options.tokenClaimsAsJSON = [_tokenClaimsInternalOptions - validatedJSONStringForClaims:options.tokenClaims - error:&claimsError]; - if (claimsError) { - if (options.completion) { - self->_currentOptions = nil; - dispatch_async(dispatch_get_main_queue(), ^{ - options.completion(nil, claimsError); - }); + // Only serialize tokenClaims if options.tokenClaimsAsJSON isn't already set. + if (!options.tokenClaimsAsJSON) { + NSError *claimsError; + + // If tokenClaims are invalid or JSON serialization fails, return with an error. + options.tokenClaimsAsJSON = [_tokenClaimsInternalOptions + validatedJSONStringForClaims:options.tokenClaims + error:&claimsError]; + if (claimsError) { + if (options.completion) { + self->_currentOptions = nil; + dispatch_async(dispatch_get_main_queue(), ^{ + options.completion(nil, claimsError); + }); + } + return; } - return; } [self authenticateWithOptions:options]; } From 0dbcb2d186f89b8b229790155cf2838b8529df92 Mon Sep 17 00:00:00 2001 From: Akshat Gandhi <54901287+AkshatG6@users.noreply.github.com> Date: Sun, 21 Sep 2025 22:16:18 -0700 Subject: [PATCH 2/6] Added unit test to test the updated implementation of AddScopes. --- GoogleSignIn/Tests/Unit/GIDSignInTest.m | 126 +++++++++++++++++- .../Unit/OIDAuthorizationRequest+Testing.h | 4 +- .../Unit/OIDAuthorizationRequest+Testing.m | 8 +- .../Unit/OIDAuthorizationResponse+Testing.m | 5 +- 4 files changed, 135 insertions(+), 8 deletions(-) diff --git a/GoogleSignIn/Tests/Unit/GIDSignInTest.m b/GoogleSignIn/Tests/Unit/GIDSignInTest.m index 17453785..882a0fb6 100644 --- a/GoogleSignIn/Tests/Unit/GIDSignInTest.m +++ b/GoogleSignIn/Tests/Unit/GIDSignInTest.m @@ -644,6 +644,7 @@ - (void)testOAuthLogin { authError:nil tokenError:nil emmPasscodeInfoRequired:NO + tokenClaimsAsJSONRequired:NO keychainError:NO restoredSignIn:NO oldAccessToken:NO @@ -661,6 +662,7 @@ - (void)testOAuthLogin_RestoredSignIn { authError:nil tokenError:nil emmPasscodeInfoRequired:NO + tokenClaimsAsJSONRequired:NO keychainError:NO restoredSignIn:YES oldAccessToken:NO @@ -678,6 +680,7 @@ - (void)testOAuthLogin_RestoredSignInOldAccessToken { authError:nil tokenError:nil emmPasscodeInfoRequired:NO + tokenClaimsAsJSONRequired:NO keychainError:NO restoredSignIn:YES oldAccessToken:YES @@ -697,6 +700,7 @@ - (void)testOAuthLogin_AdditionalScopes { authError:nil tokenError:nil emmPasscodeInfoRequired:NO + tokenClaimsAsJSONRequired:NO keychainError:NO tokenClaimsError:NO restoredSignIn:NO @@ -714,6 +718,7 @@ - (void)testOAuthLogin_AdditionalScopes { authError:nil tokenError:nil emmPasscodeInfoRequired:NO + tokenClaimsAsJSONRequired:NO keychainError:NO tokenClaimsError:NO restoredSignIn:NO @@ -731,6 +736,7 @@ - (void)testOAuthLogin_AdditionalScopes { authError:nil tokenError:nil emmPasscodeInfoRequired:NO + tokenClaimsAsJSONRequired:NO keychainError:NO tokenClaimsError:NO restoredSignIn:NO @@ -758,6 +764,7 @@ - (void)testOAuthLogin_WithTokenClaims_FormatsParametersCorrectly { authError:nil tokenError:nil emmPasscodeInfoRequired:NO + tokenClaimsAsJSONRequired:NO keychainError:NO tokenClaimsError:NO restoredSignIn:NO @@ -776,6 +783,7 @@ - (void)testOAuthLogin_WithTokenClaims_FormatsParametersCorrectly { authError:nil tokenError:nil emmPasscodeInfoRequired:NO + tokenClaimsAsJSONRequired:NO keychainError:NO tokenClaimsError:NO restoredSignIn:NO @@ -803,6 +811,7 @@ - (void)testOAuthLogin_WithTokenClaims_ReturnsIdTokenWithCorrectClaims { authError:nil tokenError:nil emmPasscodeInfoRequired:NO + tokenClaimsAsJSONRequired:NO keychainError:NO tokenClaimsError:NO restoredSignIn:NO @@ -838,6 +847,7 @@ - (void)testAddScopes { authError:nil tokenError:nil emmPasscodeInfoRequired:NO + tokenClaimsAsJSONRequired:NO keychainError:NO restoredSignIn:YES oldAccessToken:NO @@ -856,11 +866,13 @@ - (void)testAddScopes { OCMStub([_user configuration]).andReturn(configuration); OCMStub([_user profile]).andReturn(profile); OCMStub([_user grantedScopes]).andReturn(@[kGrantedScope]); + OCMStub([_user authState]).andReturn(_authState); [self OAuthLoginWithAddScopesFlow:YES authError:nil tokenError:nil emmPasscodeInfoRequired:NO + tokenClaimsAsJSONRequired:NO keychainError:NO restoredSignIn:NO oldAccessToken:NO @@ -888,6 +900,80 @@ - (void)testAddScopes { [profile stopMocking]; } +- (void)testAddScopes_WithPreviouslyRequestedClaims { + GIDTokenClaim *authTimeClaim = [GIDTokenClaim authTimeClaim]; + // Restore the previous sign-in account. This is the preparation for adding scopes. + OCMStub( + [_keychainStore saveAuthSession:OCMOCK_ANY error:OCMArg.anyObjectRef] + ).andDo(^(NSInvocation *invocation) { + self->_keychainSaved = self->_saveAuthorizationReturnValue; + }); + [self OAuthLoginWithAddScopesFlow:NO + authError:nil + tokenError:nil + emmPasscodeInfoRequired:NO + tokenClaimsAsJSONRequired:NO + keychainError:NO + tokenClaimsError:NO + restoredSignIn:NO + oldAccessToken:NO + modalCancel:NO + useAdditionalScopes:NO + additionalScopes:nil + manualNonce:nil + tokenClaims:[NSSet setWithObject:authTimeClaim]]; + + XCTAssertNotNil(_signIn.currentUser); + + id profile = OCMStrictClassMock([GIDProfileData class]); + OCMStub([profile email]).andReturn(kUserEmail); + + // Mock for the method `addScopes`. + GIDConfiguration *configuration = [[GIDConfiguration alloc] initWithClientID:kClientId + serverClientID:nil + hostedDomain:nil + openIDRealm:kOpenIDRealm]; + OCMStub([_user configuration]).andReturn(configuration); + OCMStub([_user profile]).andReturn(profile); + OCMStub([_user grantedScopes]).andReturn(@[kGrantedScope]); + OCMStub([_user authState]).andReturn(_authState); + + [self OAuthLoginWithAddScopesFlow:YES + authError:nil + tokenError:nil + emmPasscodeInfoRequired:NO + tokenClaimsAsJSONRequired:YES + keychainError:NO + restoredSignIn:NO + oldAccessToken:NO + modalCancel:NO]; + + NSArray *grantedScopes; + NSString *grantedScopeString = _savedAuthorizationRequest.scope; + + if (grantedScopeString) { + grantedScopeString = [grantedScopeString stringByTrimmingCharactersInSet: + [NSCharacterSet whitespaceCharacterSet]]; + // Tokenize with space as a delimiter. + NSMutableArray *parsedScopes = + [[grantedScopeString componentsSeparatedByString:@" "] mutableCopy]; + // Remove empty strings. + [parsedScopes removeObject:@""]; + grantedScopes = [parsedScopes copy]; + } + + NSArray *expectedScopes = @[kNewScope, kGrantedScope]; + XCTAssertEqualObjects(grantedScopes, expectedScopes); + XCTAssertEqualObjects(_savedAuthorizationRequest.additionalParameters[@"claims"], + kNonEssentialAuthTimeClaimsJsonString, + @"Claims JSON should be correctly formatted"); + + [_user verify]; + [profile verify]; + [profile stopMocking]; +} + + - (void)testOpenIDRealm { _signIn.configuration = [[GIDConfiguration alloc] initWithClientID:kClientId serverClientID:nil @@ -904,6 +990,7 @@ - (void)testOpenIDRealm { authError:nil tokenError:nil emmPasscodeInfoRequired:NO + tokenClaimsAsJSONRequired:NO keychainError:NO restoredSignIn:NO oldAccessToken:NO @@ -931,6 +1018,7 @@ - (void)testManualNonce { authError:nil tokenError:nil emmPasscodeInfoRequired:NO + tokenClaimsAsJSONRequired:NO keychainError:NO tokenClaimsError:NO restoredSignIn:NO @@ -959,6 +1047,7 @@ - (void)testOAuthLogin_LoginHint { authError:nil tokenError:nil emmPasscodeInfoRequired:NO + tokenClaimsAsJSONRequired:NO keychainError:NO restoredSignIn:NO oldAccessToken:NO @@ -984,6 +1073,7 @@ - (void)testOAuthLogin_HostedDomain { authError:nil tokenError:nil emmPasscodeInfoRequired:NO + tokenClaimsAsJSONRequired:NO keychainError:NO restoredSignIn:NO oldAccessToken:NO @@ -998,6 +1088,7 @@ - (void)testOAuthLogin_ConsentCanceled { authError:@"access_denied" tokenError:nil emmPasscodeInfoRequired:NO + tokenClaimsAsJSONRequired:NO keychainError:NO restoredSignIn:NO oldAccessToken:NO @@ -1012,6 +1103,7 @@ - (void)testOAuthLogin_ModalCanceled { authError:nil tokenError:nil emmPasscodeInfoRequired:NO + tokenClaimsAsJSONRequired:NO keychainError:NO restoredSignIn:NO oldAccessToken:NO @@ -1036,6 +1128,7 @@ - (void)testOAuthLogin_KeychainError { authError:nil tokenError:nil emmPasscodeInfoRequired:NO + tokenClaimsAsJSONRequired:NO keychainError:YES restoredSignIn:NO oldAccessToken:NO @@ -1056,6 +1149,7 @@ - (void)testOAuthLogin_TokenClaims_FailsWithError { authError:nil tokenError:nil emmPasscodeInfoRequired:NO + tokenClaimsAsJSONRequired:NO keychainError:NO tokenClaimsError:YES restoredSignIn:NO @@ -1093,6 +1187,7 @@ - (void)testSignOut { authError:nil tokenError:nil emmPasscodeInfoRequired:NO + tokenClaimsAsJSONRequired:NO keychainError:NO restoredSignIn:YES oldAccessToken:NO @@ -1339,6 +1434,7 @@ - (void)testEmmSupportRequestParameters { authError:nil tokenError:nil emmPasscodeInfoRequired:NO + tokenClaimsAsJSONRequired:NO keychainError:NO restoredSignIn:NO oldAccessToken:NO @@ -1390,6 +1486,7 @@ - (void)testEmmPasscodeInfo { authError:nil tokenError:nil emmPasscodeInfoRequired:YES + tokenClaimsAsJSONRequired:NO keychainError:NO restoredSignIn:NO oldAccessToken:NO @@ -1421,6 +1518,7 @@ - (void)testAuthEndpointEMMError { authError:callbackParams[@"error"] tokenError:nil emmPasscodeInfoRequired:NO + tokenClaimsAsJSONRequired:NO keychainError:NO restoredSignIn:NO oldAccessToken:NO @@ -1458,6 +1556,7 @@ - (void)testTokenEndpointEMMError { authError:nil tokenError:emmError emmPasscodeInfoRequired:NO + tokenClaimsAsJSONRequired:NO keychainError:NO restoredSignIn:NO oldAccessToken:NO @@ -1542,6 +1641,7 @@ - (void)OAuthLoginWithAddScopesFlow:(BOOL)addScopesFlow authError:(NSString *)authError tokenError:(NSError *)tokenError emmPasscodeInfoRequired:(BOOL)emmPasscodeInfoRequired + tokenClaimsAsJSONRequired:(BOOL)tokenClaimsAsJSONRequired keychainError:(BOOL)keychainError restoredSignIn:(BOOL)restoredSignIn oldAccessToken:(BOOL)oldAccessToken @@ -1550,6 +1650,7 @@ - (void)OAuthLoginWithAddScopesFlow:(BOOL)addScopesFlow authError:authError tokenError:tokenError emmPasscodeInfoRequired:emmPasscodeInfoRequired + tokenClaimsAsJSONRequired:tokenClaimsAsJSONRequired keychainError:keychainError tokenClaimsError:NO restoredSignIn:restoredSignIn @@ -1566,6 +1667,7 @@ - (void)OAuthLoginWithAddScopesFlow:(BOOL)addScopesFlow authError:(NSString *)authError tokenError:(NSError *)tokenError emmPasscodeInfoRequired:(BOOL)emmPasscodeInfoRequired + tokenClaimsAsJSONRequired:(BOOL)tokenClaimsAsJSONRequired keychainError:(BOOL)keychainError tokenClaimsError:(BOOL)tokenClaimsError restoredSignIn:(BOOL)restoredSignIn @@ -1582,8 +1684,9 @@ - (void)OAuthLoginWithAddScopesFlow:(BOOL)addScopesFlow [[[_authState expect] andReturnValue:[NSNumber numberWithBool:isAuthorized]] isAuthorized]; } - NSDictionary *additionalParameters = emmPasscodeInfoRequired ? - @{ @"emm_passcode_info_required" : @"1" } : nil; + NSDictionary *additionalParameters = + [self getAdditionalParametersWithEMMPasscodeInfoRequired:emmPasscodeInfoRequired + tokenClaimsAsJSONRequired:tokenClaimsAsJSONRequired]; OIDAuthorizationResponse *authResponse = [OIDAuthorizationResponse testInstanceWithAdditionalParameters:additionalParameters nonce:nonce @@ -1646,6 +1749,7 @@ - (void)OAuthLoginWithAddScopesFlow:(BOOL)addScopesFlow self->_authError = error; }; if (addScopesFlow) { + [[[_authState expect] andReturn:authResponse] lastAuthorizationResponse]; [_signIn addScopes:@[kNewScope] #if TARGET_OS_IOS || TARGET_OS_MACCATALYST presentingViewController:_presentingViewController @@ -1846,4 +1950,22 @@ - (void)OAuthLoginWithAddScopesFlow:(BOOL)addScopesFlow } } +#pragma mark - Private Helpers + +- (NSDictionary *) + getAdditionalParametersWithEMMPasscodeInfoRequired:(BOOL)emmPasscodeInfoRequired + tokenClaimsAsJSONRequired:(BOOL)tokenClaimsAsJSONRequired { + NSMutableDictionary *additionalParameters = + [NSMutableDictionary dictionary]; + + if (emmPasscodeInfoRequired) { + additionalParameters[@"emm_passcode_info_required"] = @"1"; + } + if (tokenClaimsAsJSONRequired) { + additionalParameters[@"claims"] = kNonEssentialAuthTimeClaimsJsonString; + } + + return [additionalParameters copy]; +} + @end diff --git a/GoogleSignIn/Tests/Unit/OIDAuthorizationRequest+Testing.h b/GoogleSignIn/Tests/Unit/OIDAuthorizationRequest+Testing.h index a70d5e80..d3e691c5 100644 --- a/GoogleSignIn/Tests/Unit/OIDAuthorizationRequest+Testing.h +++ b/GoogleSignIn/Tests/Unit/OIDAuthorizationRequest+Testing.h @@ -29,6 +29,6 @@ extern NSString * _Nonnull const OIDAuthorizationRequestTestingCodeVerifier; + (instancetype _Nonnull)testInstance; -+ (instancetype _Nonnull)testInstanceWithNonce:(nullable NSString *)nonce; - ++ (instancetype _Nonnull)testInstanceWithNonce:(nullable NSString *)nonce + additionalParameters:(nullable NSDictionary *)additionalParameters; @end diff --git a/GoogleSignIn/Tests/Unit/OIDAuthorizationRequest+Testing.m b/GoogleSignIn/Tests/Unit/OIDAuthorizationRequest+Testing.m index a8dd0b81..a45dac90 100644 --- a/GoogleSignIn/Tests/Unit/OIDAuthorizationRequest+Testing.m +++ b/GoogleSignIn/Tests/Unit/OIDAuthorizationRequest+Testing.m @@ -32,10 +32,12 @@ @implementation OIDAuthorizationRequest (Testing) + (instancetype)testInstance { - return [self testInstanceWithNonce:nil]; + return [self testInstanceWithNonce:nil additionalParameters:nil]; } -+ (instancetype)testInstanceWithNonce:(nullable NSString *)nonce { ++ (instancetype)testInstanceWithNonce:(nullable NSString *)nonce + additionalParameters: + (nullable NSDictionary *)additionalParameters { return [[OIDAuthorizationRequest alloc] initWithConfiguration:[OIDServiceConfiguration testInstance] clientId:OIDAuthorizationRequestTestingClientID @@ -44,7 +46,7 @@ + (instancetype)testInstanceWithNonce:(nullable NSString *)nonce { redirectURL:[NSURL URLWithString:@"http://test.com"] responseType:OIDResponseTypeCode nonce:nonce - additionalParameters:nil]; + additionalParameters:additionalParameters]; } @end diff --git a/GoogleSignIn/Tests/Unit/OIDAuthorizationResponse+Testing.m b/GoogleSignIn/Tests/Unit/OIDAuthorizationResponse+Testing.m index cc4f1211..5404d411 100644 --- a/GoogleSignIn/Tests/Unit/OIDAuthorizationResponse+Testing.m +++ b/GoogleSignIn/Tests/Unit/OIDAuthorizationResponse+Testing.m @@ -46,7 +46,10 @@ + (instancetype)testInstanceWithAdditionalParameters: [parameters addEntriesFromDictionary:additionalParameters]; } } - return [[OIDAuthorizationResponse alloc] initWithRequest:[OIDAuthorizationRequest testInstanceWithNonce:nonce] + OIDAuthorizationRequest *request = + [OIDAuthorizationRequest testInstanceWithNonce:nonce + additionalParameters:additionalParameters]; + return [[OIDAuthorizationResponse alloc] initWithRequest:request parameters:parameters]; } From fcd1a6570daca5e3b4957bfced14096c425fff04 Mon Sep 17 00:00:00 2001 From: Akshat Gandhi <54901287+AkshatG6@users.noreply.github.com> Date: Mon, 22 Sep 2025 08:52:00 -0700 Subject: [PATCH 3/6] Updated method name from getAdditionalParametersWith... to additionalParametersWith.... within GIDSignInTest --- GoogleSignIn/Tests/Unit/GIDSignInTest.m | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/GoogleSignIn/Tests/Unit/GIDSignInTest.m b/GoogleSignIn/Tests/Unit/GIDSignInTest.m index 882a0fb6..34cebb3f 100644 --- a/GoogleSignIn/Tests/Unit/GIDSignInTest.m +++ b/GoogleSignIn/Tests/Unit/GIDSignInTest.m @@ -973,7 +973,6 @@ - (void)testAddScopes_WithPreviouslyRequestedClaims { [profile stopMocking]; } - - (void)testOpenIDRealm { _signIn.configuration = [[GIDConfiguration alloc] initWithClientID:kClientId serverClientID:nil @@ -1685,7 +1684,7 @@ - (void)OAuthLoginWithAddScopesFlow:(BOOL)addScopesFlow } NSDictionary *additionalParameters = - [self getAdditionalParametersWithEMMPasscodeInfoRequired:emmPasscodeInfoRequired + [self additionalParametersWithEMMPasscodeInfoRequired:emmPasscodeInfoRequired tokenClaimsAsJSONRequired:tokenClaimsAsJSONRequired]; OIDAuthorizationResponse *authResponse = [OIDAuthorizationResponse testInstanceWithAdditionalParameters:additionalParameters @@ -1953,8 +1952,8 @@ - (void)OAuthLoginWithAddScopesFlow:(BOOL)addScopesFlow #pragma mark - Private Helpers - (NSDictionary *) - getAdditionalParametersWithEMMPasscodeInfoRequired:(BOOL)emmPasscodeInfoRequired - tokenClaimsAsJSONRequired:(BOOL)tokenClaimsAsJSONRequired { + additionalParametersWithEMMPasscodeInfoRequired:(BOOL)emmPasscodeInfoRequired + tokenClaimsAsJSONRequired:(BOOL)tokenClaimsAsJSONRequired { NSMutableDictionary *additionalParameters = [NSMutableDictionary dictionary]; From 438aa691aa03d95981f62ba8b91174b8603e1da9 Mon Sep 17 00:00:00 2001 From: Akshat Gandhi <54901287+AkshatG6@users.noreply.github.com> Date: Mon, 22 Sep 2025 08:54:16 -0700 Subject: [PATCH 4/6] Updated method name from getAdditionalParametersWith... to additionalParametersWith.... within GIDSignInTest --- GoogleSignIn/Tests/Unit/GIDSignInTest.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GoogleSignIn/Tests/Unit/GIDSignInTest.m b/GoogleSignIn/Tests/Unit/GIDSignInTest.m index 34cebb3f..0014e88f 100644 --- a/GoogleSignIn/Tests/Unit/GIDSignInTest.m +++ b/GoogleSignIn/Tests/Unit/GIDSignInTest.m @@ -1685,7 +1685,7 @@ - (void)OAuthLoginWithAddScopesFlow:(BOOL)addScopesFlow NSDictionary *additionalParameters = [self additionalParametersWithEMMPasscodeInfoRequired:emmPasscodeInfoRequired - tokenClaimsAsJSONRequired:tokenClaimsAsJSONRequired]; + tokenClaimsAsJSONRequired:tokenClaimsAsJSONRequired]; OIDAuthorizationResponse *authResponse = [OIDAuthorizationResponse testInstanceWithAdditionalParameters:additionalParameters nonce:nonce From 8753da63244c2fb52f3bd018c5938ec9de411a91 Mon Sep 17 00:00:00 2001 From: Akshat Gandhi <54901287+AkshatG6@users.noreply.github.com> Date: Mon, 22 Sep 2025 13:24:16 -0700 Subject: [PATCH 5/6] Fixed styling in GIDSignIn.m and GIDSignInTest.m --- GoogleSignIn/Sources/GIDSignIn.m | 4 ++-- GoogleSignIn/Tests/Unit/GIDSignInTest.m | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/GoogleSignIn/Sources/GIDSignIn.m b/GoogleSignIn/Sources/GIDSignIn.m index 0125052f..ff4fcdae 100644 --- a/GoogleSignIn/Sources/GIDSignIn.m +++ b/GoogleSignIn/Sources/GIDSignIn.m @@ -762,10 +762,10 @@ - (void)signInWithOptions:(GIDSignInInternalOptions *)options { // If tokenClaims are invalid or JSON serialization fails, return with an error. options.tokenClaimsAsJSON = [_tokenClaimsInternalOptions validatedJSONStringForClaims:options.tokenClaims - error:&claimsError]; + error:&claimsError]; if (claimsError) { if (options.completion) { - self->_currentOptions = nil; + _currentOptions = nil; dispatch_async(dispatch_get_main_queue(), ^{ options.completion(nil, claimsError); }); diff --git a/GoogleSignIn/Tests/Unit/GIDSignInTest.m b/GoogleSignIn/Tests/Unit/GIDSignInTest.m index 0014e88f..49946569 100644 --- a/GoogleSignIn/Tests/Unit/GIDSignInTest.m +++ b/GoogleSignIn/Tests/Unit/GIDSignInTest.m @@ -952,12 +952,11 @@ - (void)testAddScopes_WithPreviouslyRequestedClaims { NSString *grantedScopeString = _savedAuthorizationRequest.scope; if (grantedScopeString) { - grantedScopeString = [grantedScopeString stringByTrimmingCharactersInSet: - [NSCharacterSet whitespaceCharacterSet]]; - // Tokenize with space as a delimiter. + NSCharacterSet *whiteSpaceChars = [NSCharacterSet whitespaceCharacterSet]; + grantedScopeString = + [grantedScopeString stringByTrimmingCharactersInSet:whiteSpaceChars]; NSMutableArray *parsedScopes = [[grantedScopeString componentsSeparatedByString:@" "] mutableCopy]; - // Remove empty strings. [parsedScopes removeObject:@""]; grantedScopes = [parsedScopes copy]; } @@ -970,7 +969,6 @@ - (void)testAddScopes_WithPreviouslyRequestedClaims { [_user verify]; [profile verify]; - [profile stopMocking]; } - (void)testOpenIDRealm { From cd754d6a81e0c5593f133ea0cd6db3f8780f40f5 Mon Sep 17 00:00:00 2001 From: Akshat Gandhi <54901287+AkshatG6@users.noreply.github.com> Date: Tue, 23 Sep 2025 16:07:46 -0700 Subject: [PATCH 6/6] Updated comments in GIDSignInTest.m --- GoogleSignIn/Tests/Unit/GIDSignInTest.m | 1 - 1 file changed, 1 deletion(-) diff --git a/GoogleSignIn/Tests/Unit/GIDSignInTest.m b/GoogleSignIn/Tests/Unit/GIDSignInTest.m index 49946569..55f239d0 100644 --- a/GoogleSignIn/Tests/Unit/GIDSignInTest.m +++ b/GoogleSignIn/Tests/Unit/GIDSignInTest.m @@ -928,7 +928,6 @@ - (void)testAddScopes_WithPreviouslyRequestedClaims { id profile = OCMStrictClassMock([GIDProfileData class]); OCMStub([profile email]).andReturn(kUserEmail); - // Mock for the method `addScopes`. GIDConfiguration *configuration = [[GIDConfiguration alloc] initWithClientID:kClientId serverClientID:nil hostedDomain:nil