Skip to content

Commit 93b654a

Browse files
authored
Merge pull request #987 from firebase/mc/gsi6
update FUIGoogleAuth for GoogleSignIn 6
2 parents 416181c + 8c25c45 commit 93b654a

File tree

10 files changed

+224
-157
lines changed

10 files changed

+224
-157
lines changed

.github/workflows/googleauth.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,19 @@ jobs:
4040
- name: Build
4141
run: |
4242
./test.sh FirebaseGoogleAuthUI
43+
spm:
44+
name: spm
45+
runs-on: macOS-latest
46+
47+
steps:
48+
- name: Checkout
49+
uses: actions/checkout@master
50+
- name: List
51+
run: |
52+
xcodebuild -list
53+
- name: Build
54+
run: |
55+
xcodebuild -scheme FirebaseGoogleAuthUI -sdk iphonesimulator
4356
pod:
4457
name: pod lib lint
4558
runs-on: macOS-latest

FirebaseGoogleAuthUI.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Pod::Spec.new do |s|
2121
s.dependency 'FirebaseAuth'
2222
s.dependency 'FirebaseCore'
2323
s.dependency 'FirebaseAuthUI'
24-
s.dependency 'GoogleSignIn', '~> 5.0'
24+
s.dependency 'GoogleSignIn', '~> 6.0'
2525
s.resource_bundles = {
2626
'FirebaseGoogleAuthUI' => ['FirebaseGoogleAuthUI/Sources/{Resources,Strings}/*.{png,lproj}']
2727
}

FirebaseGoogleAuthUI/FirebaseGoogleAuthUI.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -775,12 +775,12 @@
775775
"\"${PODS_CONFIGURATION_BUILD_DIR}/GTMSessionFetcher\"",
776776
"\"${PODS_CONFIGURATION_BUILD_DIR}/GoogleDataTransport\"",
777777
"\"${PODS_CONFIGURATION_BUILD_DIR}/GoogleUtilities\"",
778-
"\"${PODS_ROOT}/GoogleSignIn/Frameworks\"",
779778
"\"${PODS_CONFIGURATION_BUILD_DIR}/AppAuth\"",
780779
"\"${PODS_CONFIGURATION_BUILD_DIR}/PromisesObjC\"",
781780
"\"${PODS_CONFIGURATION_BUILD_DIR}/GTMAppAuth\"",
782781
"\"${PODS_CONFIGURATION_BUILD_DIR}/nanopb\"",
783782
"\"$(PODS_CONFIGURATION_BUILD_DIR)/FirebaseAuthUI\"",
783+
"\"$(PODS_CONFIGURATION_BUILD_DIR)/GoogleSignIn\"",
784784
);
785785
OTHER_LDFLAGS = (
786786
"$(inherited)",
@@ -830,12 +830,12 @@
830830
"\"${PODS_CONFIGURATION_BUILD_DIR}/GTMSessionFetcher\"",
831831
"\"${PODS_CONFIGURATION_BUILD_DIR}/GoogleDataTransport\"",
832832
"\"${PODS_CONFIGURATION_BUILD_DIR}/GoogleUtilities\"",
833-
"\"${PODS_ROOT}/GoogleSignIn/Frameworks\"",
834833
"\"${PODS_CONFIGURATION_BUILD_DIR}/AppAuth\"",
835834
"\"${PODS_CONFIGURATION_BUILD_DIR}/PromisesObjC\"",
836835
"\"${PODS_CONFIGURATION_BUILD_DIR}/GTMAppAuth\"",
837836
"\"${PODS_CONFIGURATION_BUILD_DIR}/nanopb\"",
838837
"\"$(PODS_CONFIGURATION_BUILD_DIR)/FirebaseAuthUI\"",
838+
"\"$(PODS_CONFIGURATION_BUILD_DIR)/GoogleSignIn\"",
839839
);
840840
OTHER_LDFLAGS = (
841841
"$(inherited)",

FirebaseGoogleAuthUI/FirebaseGoogleAuthUITests/FirebaseGoogleAuthUITests.m

Lines changed: 50 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@
2323
#import "FUIGoogleAuth.h"
2424

2525
@interface FUIGoogleAuth (Testing)
26-
- (GIDSignIn *)configuredGoogleSignIn;
26+
- (NSString *)clientID;
27+
- (GIDSignIn *)googleSignIn;
28+
- (void)handleSignInWithUser:(GIDGoogleUser *)user
29+
error:(NSError *)error
30+
presentingViewController:(UIViewController *)presentingViewController
31+
callback:(FUIAuthProviderSignInCompletionBlock)callback;
2732
@end
2833

2934
@interface FirebaseGoogleAuthUITests : XCTestCase
@@ -48,6 +53,7 @@ - (void)setUp {
4853
FIRAuth *auth = [FIRAuth auth];
4954
self.authUI = [FUIAuth authUIWithAuth:auth];
5055
self.mockProvider = OCMPartialMock([[FUIGoogleAuth alloc] initWithAuthUI:self.authUI]);
56+
OCMStub([_mockProvider clientID]).andReturn(@"clientID");
5157
}
5258

5359
- (void)tearDown {
@@ -82,7 +88,7 @@ - (void)testUseEmulatorCreatesOAuthProvider {
8288
OCMVerify([self.mockOAuthProvider providerWithProviderID:@"google.com"]);
8389
}
8490

85-
- (void)testSuccessfullLogin {
91+
- (void)testSuccessfulLogin {
8692
NSString *testIdToken = @"idToken";
8793
NSString *testAccessToken = @"accessToken";
8894

@@ -99,11 +105,16 @@ - (void)testSuccessfullLogin {
99105
OCMExpect([mockGoogleUser authentication]).andReturn(mockAuthentication);
100106
OCMExpect([mockAuthentication idToken]).andReturn(testIdToken);
101107

102-
OCMExpect([_mockProvider configuredGoogleSignIn]).andReturn(mockSignIn);
108+
OCMExpect([_mockProvider googleSignIn]).andReturn(mockSignIn);
103109

104-
//forward call to signIn delegate
105-
OCMExpect([mockSignIn signIn]).andDo(^(NSInvocation *invocation) {
106-
[mockSignInDelegate signIn:mockSignIn didSignInForUser:mockGoogleUser withError:nil];
110+
// forward call to signIn delegate
111+
OCMExpect([mockSignIn signInWithConfiguration:[OCMArg any]
112+
presentingViewController:[OCMArg any]
113+
hint:[OCMArg any]
114+
callback:[OCMArg any]]).andDo(^(NSInvocation *invocation) {
115+
void (^callback)(GIDGoogleUser *, NSError *) = nil;
116+
[invocation getArgument:&callback atIndex:5];
117+
callback(mockGoogleUser, nil);
107118
});
108119

109120
XCTestExpectation *expectation = [self expectationWithDescription:@"logged in"];
@@ -147,13 +158,15 @@ - (void)testLegacyInitSuccessfulLogin {
147158
NSString *testIdToken = @"idToken";
148159
NSString *testAccessToken = @"accessToken";
149160

150-
_mockProvider = OCMPartialMock([[FUIGoogleAuth alloc] init]);
161+
_mockProvider = OCMPartialMock([[FUIGoogleAuth alloc] init]);
151162

152163
id mockSignInDelegate = _mockProvider;
153164
id mockSignIn = OCMClassMock([GIDSignIn class]);
154165
id mockAuthentication = OCMClassMock([GIDAuthentication class]);
155166
id mockGoogleUser = OCMClassMock([GIDGoogleUser class]);
156167

168+
OCMStub([_mockProvider clientID]).andReturn(@"clientID");
169+
157170
// mock accessToken
158171
OCMExpect([mockGoogleUser authentication]).andReturn(mockAuthentication);
159172
OCMExpect([mockAuthentication accessToken]).andReturn(testAccessToken);
@@ -162,11 +175,16 @@ - (void)testLegacyInitSuccessfulLogin {
162175
OCMExpect([mockGoogleUser authentication]).andReturn(mockAuthentication);
163176
OCMExpect([mockAuthentication idToken]).andReturn(testIdToken);
164177

165-
OCMExpect([_mockProvider configuredGoogleSignIn]).andReturn(mockSignIn);
178+
OCMExpect([_mockProvider googleSignIn]).andReturn(mockSignIn);
166179

167-
//forward call to signIn delegate
168-
OCMExpect([mockSignIn signIn]).andDo(^(NSInvocation *invocation) {
169-
[mockSignInDelegate signIn:mockSignIn didSignInForUser:mockGoogleUser withError:nil];
180+
// forward call to signIn delegate
181+
OCMExpect([mockSignIn signInWithConfiguration:[OCMArg any]
182+
presentingViewController:[OCMArg any]
183+
hint:[OCMArg any]
184+
callback:[OCMArg any]]).andDo(^(NSInvocation *invocation) {
185+
void (^callback)(GIDGoogleUser *, NSError *) = nil;
186+
[invocation getArgument:&callback atIndex:5];
187+
callback(mockGoogleUser, nil);
170188
});
171189

172190
XCTestExpectation *expectation = [self expectationWithDescription:@"logged in"];
@@ -222,11 +240,17 @@ - (void)testErrorLogin {
222240
OCMStub([mockGoogleUser authentication]).andReturn(mockAuthentication);
223241
OCMStub([mockAuthentication idToken]).andReturn(testIdToken);
224242

225-
OCMExpect([_mockProvider configuredGoogleSignIn]).andReturn(mockSignIn);
243+
OCMExpect([_mockProvider googleSignIn]).andReturn(mockSignIn);
226244
NSError *signInError = [NSError errorWithDomain:@"sign in domain" code:kGIDSignInErrorCodeUnknown userInfo:@{}];
227245

228-
OCMExpect([mockSignIn signIn]).andDo(^(NSInvocation *invocation) {
229-
[mockSignInDelegate signIn:mockSignIn didSignInForUser:mockGoogleUser withError:signInError];
246+
// forward call to signIn delegate
247+
OCMExpect([mockSignIn signInWithConfiguration:[OCMArg any]
248+
presentingViewController:[OCMArg any]
249+
hint:[OCMArg any]
250+
callback:[OCMArg any]]).andDo(^(NSInvocation *invocation) {
251+
void (^callback)(GIDGoogleUser *, NSError *) = nil;
252+
[invocation getArgument:&callback atIndex:5];
253+
callback(mockGoogleUser, signInError);
230254
});
231255

232256

@@ -275,11 +299,17 @@ - (void)testCancelLogin {
275299
OCMStub([mockGoogleUser authentication]).andReturn(mockAuthentication);
276300
OCMStub([mockAuthentication idToken]).andReturn(testIdToken);
277301

278-
OCMExpect([_mockProvider configuredGoogleSignIn]).andReturn(mockSignIn);
302+
OCMExpect([_mockProvider googleSignIn]).andReturn(mockSignIn);
279303
NSError *signInError = [NSError errorWithDomain:@"sign in domain" code:kGIDSignInErrorCodeCanceled userInfo:@{}];
280304

281-
OCMExpect([mockSignIn signIn]).andDo(^(NSInvocation *invocation) {
282-
[mockSignInDelegate signIn:mockSignIn didSignInForUser:mockGoogleUser withError:signInError];
305+
// forward call to signIn delegate
306+
OCMExpect([mockSignIn signInWithConfiguration:[OCMArg any]
307+
presentingViewController:[OCMArg any]
308+
hint:[OCMArg any]
309+
callback:[OCMArg any]]).andDo(^(NSInvocation *invocation) {
310+
void (^callback)(GIDGoogleUser *, NSError *) = nil;
311+
[invocation getArgument:&callback atIndex:5];
312+
callback(mockGoogleUser, signInError);
283313
});
284314

285315
XCTestExpectation *expectation = [self expectationWithDescription:@"logged in"];
@@ -313,7 +343,7 @@ - (void)testCancelLogin {
313343

314344
- (void)testSignOut {
315345
id mockSignIn = OCMClassMock([GIDSignIn class]);
316-
OCMExpect([_mockProvider configuredGoogleSignIn]).andReturn(mockSignIn);
346+
OCMExpect([_mockProvider googleSignIn]).andReturn(mockSignIn);
317347
OCMExpect([mockSignIn signOut]);
318348

319349
[_mockProvider signOut];
@@ -324,7 +354,7 @@ - (void)testSignOut {
324354

325355
- (void)testUseEmulatorUsesOAuthProvider {
326356
[self.authUI useEmulatorWithHost:@"host" port:12345];
327-
self.mockProvider = OCMPartialMock([[FUIGoogleAuth alloc] initWithAuthUI:self.authUI]);
357+
self.mockProvider = OCMPartialMock([[FUIGoogleAuth alloc] initWithAuthUI:self.authUI]);
328358

329359
[self.mockProvider signInWithDefaultValue:nil
330360
presentingViewController:nil
@@ -334,7 +364,7 @@ - (void)testUseEmulatorUsesOAuthProvider {
334364
NSDictionary *_Nullable userInfo) {}];
335365

336366
OCMVerify([self.mockOAuthProvider getCredentialWithUIDelegate:nil completion:OCMOCK_ANY]);
337-
OCMVerify(never(), [self.mockProvider configuredGoogleSignIn]);
367+
OCMVerify(never(), [self.mockProvider googleSignIn]);
338368
}
339369

340370

FirebaseGoogleAuthUI/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ platform :ios, '10.0'
66
target 'FirebaseGoogleAuthUI' do
77
use_frameworks!
88

9-
pod 'GoogleSignIn', '~> 5.0'
9+
pod 'GoogleSignIn', '~> 6.0'
1010
pod 'FirebaseAuthUI', :path => '../'
1111

1212
target 'FirebaseGoogleAuthUITests' do

FirebaseGoogleAuthUI/Podfile.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ PODS:
2525
- GoogleUtilities/Environment (~> 7.2)
2626
- nanopb (~> 2.30908.0)
2727
- PromisesObjC (< 3.0, >= 1.2)
28-
- GoogleSignIn (5.0.2):
29-
- AppAuth (~> 1.2)
28+
- GoogleSignIn (6.0.0):
29+
- AppAuth (~> 1.4)
3030
- GTMAppAuth (~> 1.0)
3131
- GTMSessionFetcher/Core (~> 1.1)
3232
- GoogleUtilities/AppDelegateSwizzler (7.5.0):
@@ -58,7 +58,7 @@ PODS:
5858

5959
DEPENDENCIES:
6060
- FirebaseAuthUI (from `../`)
61-
- GoogleSignIn (~> 5.0)
61+
- GoogleSignIn (~> 6.0)
6262
- OCMock
6363

6464
SPEC REPOS:
@@ -87,14 +87,14 @@ SPEC CHECKSUMS:
8787
FirebaseCore: 31f389c37ac1ea52454a53d3081f2d7019485a4a
8888
FirebaseCoreDiagnostics: cad03be1904b975f845e632f2720c3337da27faf
8989
GoogleDataTransport: 85fd18ff3019bb85d3f2c551d04c481dedf71fc9
90-
GoogleSignIn: 7137d297ddc022a7e0aa4619c86d72c909fa7213
90+
GoogleSignIn: b7779a809e1dfb32ebb43131b10d8bfcd53c1383
9191
GoogleUtilities: eea970f4a389963963bffe8d8fabe43540678b9c
9292
GTMAppAuth: ad5c2b70b9a8689e1a04033c9369c4915bfcbe89
9393
GTMSessionFetcher: 36689134877faeb055b27dfa4ccc9ceaa42e029e
9494
nanopb: a0ba3315591a9ae0a16a309ee504766e90db0c96
9595
OCMock: 29f6e52085b4e7d9b075cbf03ed7c3112f82f934
9696
PromisesObjC: 68159ce6952d93e17b2dfe273b8c40907db5ba58
9797

98-
PODFILE CHECKSUM: 5b245dea8385cbe6f02f214577a97083894700bf
98+
PODFILE CHECKSUM: 0ab8f1a707baefc68f0b4f5320060c1502798f29
9999

100100
COCOAPODS: 1.10.1

0 commit comments

Comments
 (0)