3434#import " GoogleSignIn/Sources/GIDKeychainHandler/Implementations/Fakes/GIDFakeKeychainHandler.h"
3535#import " GoogleSignIn/Sources/GIDHTTPFetcher/Implementations/Fakes/GIDFakeHTTPFetcher.h"
3636#import " GoogleSignIn/Sources/GIDHTTPFetcher/Implementations/GIDHTTPFetcher.h"
37- #import " GoogleSignIn/Sources/GIDProfileDataFetcher/Implementations/GIDProfileDataFetcher.h"
37+ #import " GoogleSignIn/Sources/GIDProfileDataFetcher/API/GIDProfileDataFetcher.h"
38+ #import " GoogleSignIn/Sources/GIDProfileDataFetcher/Implementations/Fakes/GIDFakeProfileDataFetcher.h"
3839
3940
4041#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
4142#import " GoogleSignIn/Sources/GIDEMMErrorHandler.h"
4243#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
4344
4445#import " GoogleSignIn/Tests/Unit/GIDFakeMainBundle.h"
46+ #import " GoogleSignIn/Tests/Unit/GIDProfileData+Testing.h"
4547#import " GoogleSignIn/Tests/Unit/OIDAuthorizationResponse+Testing.h"
4648#import " GoogleSignIn/Tests/Unit/OIDTokenResponse+Testing.h"
4749
@@ -185,36 +187,39 @@ @interface GIDSignInTest : XCTestCase {
185187 // Whether or not the OS version is eligible for EMM.
186188 BOOL _isEligibleForEMM;
187189
188- // Mock | OIDAuthState| .
190+ // Mock ` OIDAuthState` .
189191 id _authState;
190192
191- // Mock | OIDTokenResponse| .
193+ // Mock ` OIDTokenResponse` .
192194 id _tokenResponse;
193195
194- // Mock | OIDTokenRequest| .
196+ // Mock ` OIDTokenRequest` .
195197 id _tokenRequest;
196198
197- // Mock | GTMAppAuthFetcherAuthorization| .
199+ // Mock ` GTMAppAuthFetcherAuthorization` .
198200 id _authorization;
199201
200- // Fake for | GIDKeychainHandler| .
202+ // Fake for ` GIDKeychainHandler` .
201203 GIDFakeKeychainHandler *_keychainHandler;
202204
203- // Fake for | GIDHTTPFetcher| .
205+ // Fake for ` GIDHTTPFetcher` .
204206 GIDFakeHTTPFetcher *_httpFetcher;
205207
208+ // Fake for `GIDProfileDataFetcher`.
209+ GIDFakeProfileDataFetcher *_profileDataFetcher;
210+
206211#if TARGET_OS_IOS || TARGET_OS_MACCATALYST
207- // Mock | UIViewController| .
212+ // Mock ` UIViewController` .
208213 id _presentingViewController;
209214#elif TARGET_OS_OSX
210- // Mock | NSWindow| .
215+ // Mock ` NSWindow` .
211216 id _presentingWindow;
212217#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
213218
214- // Mock for | GIDGoogleUser| .
219+ // Mock for ` GIDGoogleUser` .
215220 id _user;
216221
217- // Mock for | OIDAuthorizationService|
222+ // Mock for ` OIDAuthorizationService`.
218223 id _oidAuthorizationService;
219224
220225 // Parameter saved from delegate call.
@@ -226,16 +231,16 @@ @interface GIDSignInTest : XCTestCase {
226231 // Fake [NSBundle mainBundle];
227232 GIDFakeMainBundle *_fakeMainBundle;
228233
229- // The | GIDSignIn| object being tested.
234+ // The ` GIDSignIn` object being tested.
230235 GIDSignIn *_signIn;
231236
232- // The configuration to be used when testing | GIDSignIn| .
237+ // The configuration to be used when testing ` GIDSignIn` .
233238 GIDConfiguration *_configuration;
234239
235- // The login hint to be used when testing | GIDSignIn| .
240+ // The login hint to be used when testing ` GIDSignIn` .
236241 NSString *_hint;
237242
238- // The completion to be used when testing | GIDSignIn| .
243+ // The completion to be used when testing ` GIDSignIn` .
239244 GIDSignInCompletion _completion;
240245
241246 // The saved authorization request.
@@ -314,14 +319,14 @@ - (void)setUp {
314319
315320 _httpFetcher = [[GIDFakeHTTPFetcher alloc ] init ];
316321
322+ _profileDataFetcher = [[GIDFakeProfileDataFetcher alloc ] init ];
323+
317324 GIDAuthorizationFlowProcessor * authorizationFlowProcessor =
318325 [[GIDAuthorizationFlowProcessor alloc ] init ];
319326
320- id <GIDProfileDataFetcher> profileDataFetcher = [[GIDProfileDataFetcher alloc ] init ];
321-
322327 _signIn = [[GIDSignIn alloc ] initWithKeychainHandler: _keychainHandler
323328 httpFetcher: _httpFetcher
324- profileDataFetcher: profileDataFetcher
329+ profileDataFetcher: _profileDataFetcher
325330 authorizationFlowProcessor: authorizationFlowProcessor];
326331
327332 _hint = nil ;
@@ -423,20 +428,21 @@ - (void)testRestorePreviousSignInNoRefresh_hasPreviousUser {
423428
424429 OCMStub ([_authState lastAuthorizationResponse ]).andReturn (authResponse);
425430 OCMStub ([_tokenResponse idToken ]).andReturn (kFakeIDToken );
426- OCMStub ([_tokenResponse request ]).andReturn (_tokenRequest);
427- OCMStub ([_tokenRequest additionalParameters ]).andReturn (nil );
428431 OCMStub ([_tokenResponse accessToken ]).andReturn (kAccessToken );
429432 OCMStub ([_tokenResponse accessTokenExpirationDate ]).andReturn (nil );
430433
434+ GIDProfileData *fakeProfileData = [GIDProfileData testInstance ];
435+ GIDProfileDataFetcherTestBlock testBlock = ^(GIDProfileDataFetcherFakeResponseProvider
436+ responseProvider) {
437+ responseProvider (fakeProfileData, nil );
438+ };
439+
440+ _profileDataFetcher.testBlock = testBlock;
431441 [_signIn restorePreviousSignInNoRefresh ];
432442
433- [_authState verify ];
434- [_authorization verify ];
435- [_tokenResponse verify ];
436- [_tokenRequest verify ];
437- [idTokenDecoded verify ];
438443 XCTAssertEqual (_signIn.currentUser .userID , kFakeGaiaID );
439-
444+
445+ XCTAssertEqualObjects (_signIn.currentUser .profile , fakeProfileData);
440446 [idTokenDecoded stopMocking ];
441447}
442448
@@ -1065,7 +1071,6 @@ - (void)testAuthEndpointEMMError {
10651071 [[[mockEMMErrorHandler expect ] andReturnValue: @YES ]
10661072 handleErrorFromResponse: callbackParams completion: SAVE_TO_ARG_BLOCK (completion)];
10671073
1068-
10691074 [self OAuthLoginWithAddScopesFlow: NO
10701075 authError: callbackParams[@" error" ]
10711076 tokenError: nil
@@ -1215,6 +1220,15 @@ - (void)OAuthLoginWithAddScopesFlow:(BOOL)addScopesFlow
12151220 refreshToken: kRefreshToken
12161221 codeVerifier: nil
12171222 additionalParameters: tokenResponse.request.additionalParameters];
1223+
1224+ // Set the response for `GIDProfileDataFetcher`.
1225+ GIDProfileDataFetcherTestBlock testBlock = ^(GIDProfileDataFetcherFakeResponseProvider
1226+ responseProvider) {
1227+ GIDProfileData *profileData = [GIDProfileData testInstance ];
1228+ responseProvider (profileData, nil );
1229+ };
1230+
1231+ _profileDataFetcher.testBlock = testBlock;
12181232
12191233 if (restoredSignIn) {
12201234 // maybeFetchToken
@@ -1341,9 +1355,6 @@ - (void)OAuthLoginWithAddScopesFlow:(BOOL)addScopesFlow
13411355 return ;
13421356 }
13431357
1344- // DecodeIdTokenCallback
1345- [[[_authState expect ] andReturn: tokenResponse] lastTokenResponse ];
1346-
13471358 // SaveAuthCallback
13481359 __block OIDAuthState *authState;
13491360 __block OIDTokenResponse *updatedTokenResponse;
@@ -1397,10 +1408,7 @@ - (void)OAuthLoginWithAddScopesFlow:(BOOL)addScopesFlow
13971408 XCTAssertNotNil (authState);
13981409 }
13991410 // Check fat ID token decoding
1400- XCTAssertEqualObjects (profileData.name, kFatName );
1401- XCTAssertEqualObjects (profileData.givenName, kFatGivenName );
1402- XCTAssertEqualObjects (profileData.familyName, kFatFamilyName );
1403- XCTAssertTrue (profileData.hasImage);
1411+ XCTAssertEqualObjects (profileData, [GIDProfileData testInstance ]);
14041412
14051413 // If attempt to authenticate again, will reuse existing auth object.
14061414 _completionCalled = NO ;
0 commit comments