Skip to content

Commit afbf81c

Browse files
committed
Use GIDFakeProfileDataFetcher in GIDSignInTest.
1 parent c597b54 commit afbf81c

1 file changed

Lines changed: 11 additions & 16 deletions

File tree

GoogleSignIn/Tests/Unit/GIDSignInTest.m

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
4040

4141
#import "GoogleSignIn/Tests/Unit/GIDFakeMainBundle.h"
42+
#import "GoogleSignIn/Tests/Unit/GIDProfileData+Testing.h"
4243
#import "GoogleSignIn/Tests/Unit/OIDAuthorizationResponse+Testing.h"
4344
#import "GoogleSignIn/Tests/Unit/OIDTokenResponse+Testing.h"
4445

@@ -132,14 +133,6 @@
132133
static NSString * const kIDTokenExpirationKey = @"idTokenExp";
133134
static NSString * const kScopeKey = @"scope";
134135

135-
// Basic profile (Fat ID Token / userinfo endpoint) keys
136-
static NSString *const kBasicProfilePictureKey = @"picture";
137-
static NSString *const kBasicProfileNameKey = @"name";
138-
static NSString *const kBasicProfileGivenNameKey = @"given_name";
139-
static NSString *const kBasicProfileFamilyNameKey = @"family_name";
140-
141-
static NSString * const kCustomKeychainName = @"CUSTOM_KEYCHAIN_NAME";
142-
static NSString * const kAddActivity = @"http://schemas.google.com/AddActivity";
143136
static NSString * const kErrorDomain = @"ERROR_DOMAIN";
144137
static NSInteger const kErrorCode = 212;
145138

@@ -1181,7 +1174,15 @@ - (void)OAuthLoginWithAddScopesFlow:(BOOL)addScopesFlow
11811174
refreshToken:kRefreshToken
11821175
codeVerifier:nil
11831176
additionalParameters:tokenResponse.request.additionalParameters];
1184-
1177+
1178+
// Set the response for GIDProfileDataFetcher.
1179+
GIDProfileDataFetcherTestBlock testBlock = ^(GIDProfileDataFetcherFakeResponse response) {
1180+
GIDProfileData *profileData = [GIDProfileData testInstance];
1181+
response(profileData, nil);
1182+
};
1183+
1184+
[_profileDataFetcher setTestBlock:testBlock];
1185+
11851186
if (restoredSignIn) {
11861187
// maybeFetchToken
11871188
[[[_authState expect] andReturn:tokenResponse] lastTokenResponse];
@@ -1307,9 +1308,6 @@ - (void)OAuthLoginWithAddScopesFlow:(BOOL)addScopesFlow
13071308
return;
13081309
}
13091310

1310-
// DecodeIdTokenCallback
1311-
[[[_authState expect] andReturn:tokenResponse] lastTokenResponse];
1312-
13131311
// SaveAuthCallback
13141312
__block OIDAuthState *authState;
13151313
__block OIDTokenResponse *updatedTokenResponse;
@@ -1363,10 +1361,7 @@ - (void)OAuthLoginWithAddScopesFlow:(BOOL)addScopesFlow
13631361
XCTAssertNotNil(authState);
13641362
}
13651363
// Check fat ID token decoding
1366-
XCTAssertEqualObjects(profileData.name, kFatName);
1367-
XCTAssertEqualObjects(profileData.givenName, kFatGivenName);
1368-
XCTAssertEqualObjects(profileData.familyName, kFatFamilyName);
1369-
XCTAssertTrue(profileData.hasImage);
1364+
XCTAssertEqualObjects(profileData, [GIDProfileData testInstance]);
13701365

13711366
// If attempt to authenticate again, will reuse existing auth object.
13721367
_completionCalled = NO;

0 commit comments

Comments
 (0)