Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/googleauth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@ jobs:
- name: Build
run: |
./test.sh FirebaseGoogleAuthUI
spm:
name: spm
runs-on: macOS-latest

steps:
- name: Checkout
uses: actions/checkout@master
- name: List
run: |
xcodebuild -list
- name: Build
run: |
xcodebuild -scheme FirebaseGoogleAuthUI -sdk iphonesimulator
pod:
name: pod lib lint
runs-on: macOS-latest
Expand Down
2 changes: 1 addition & 1 deletion FirebaseGoogleAuthUI.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Pod::Spec.new do |s|
s.dependency 'FirebaseAuth'
s.dependency 'FirebaseCore'
s.dependency 'FirebaseAuthUI'
s.dependency 'GoogleSignIn', '~> 5.0'
s.dependency 'GoogleSignIn', '~> 6.0'
s.resource_bundles = {
'FirebaseGoogleAuthUI' => ['FirebaseGoogleAuthUI/Sources/{Resources,Strings}/*.{png,lproj}']
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -775,12 +775,12 @@
"\"${PODS_CONFIGURATION_BUILD_DIR}/GTMSessionFetcher\"",
"\"${PODS_CONFIGURATION_BUILD_DIR}/GoogleDataTransport\"",
"\"${PODS_CONFIGURATION_BUILD_DIR}/GoogleUtilities\"",
"\"${PODS_ROOT}/GoogleSignIn/Frameworks\"",
"\"${PODS_CONFIGURATION_BUILD_DIR}/AppAuth\"",
"\"${PODS_CONFIGURATION_BUILD_DIR}/PromisesObjC\"",
"\"${PODS_CONFIGURATION_BUILD_DIR}/GTMAppAuth\"",
"\"${PODS_CONFIGURATION_BUILD_DIR}/nanopb\"",
"\"$(PODS_CONFIGURATION_BUILD_DIR)/FirebaseAuthUI\"",
"\"$(PODS_CONFIGURATION_BUILD_DIR)/GoogleSignIn\"",
);
OTHER_LDFLAGS = (
"$(inherited)",
Expand Down Expand Up @@ -830,12 +830,12 @@
"\"${PODS_CONFIGURATION_BUILD_DIR}/GTMSessionFetcher\"",
"\"${PODS_CONFIGURATION_BUILD_DIR}/GoogleDataTransport\"",
"\"${PODS_CONFIGURATION_BUILD_DIR}/GoogleUtilities\"",
"\"${PODS_ROOT}/GoogleSignIn/Frameworks\"",
"\"${PODS_CONFIGURATION_BUILD_DIR}/AppAuth\"",
"\"${PODS_CONFIGURATION_BUILD_DIR}/PromisesObjC\"",
"\"${PODS_CONFIGURATION_BUILD_DIR}/GTMAppAuth\"",
"\"${PODS_CONFIGURATION_BUILD_DIR}/nanopb\"",
"\"$(PODS_CONFIGURATION_BUILD_DIR)/FirebaseAuthUI\"",
"\"$(PODS_CONFIGURATION_BUILD_DIR)/GoogleSignIn\"",
);
OTHER_LDFLAGS = (
"$(inherited)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@
#import "FUIGoogleAuth.h"

@interface FUIGoogleAuth (Testing)
- (GIDSignIn *)configuredGoogleSignIn;
- (NSString *)clientID;
- (GIDSignIn *)googleSignIn;
- (void)handleSignInWithUser:(GIDGoogleUser *)user
error:(NSError *)error
presentingViewController:(UIViewController *)presentingViewController
callback:(FUIAuthProviderSignInCompletionBlock)callback;
@end

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

- (void)tearDown {
Expand Down Expand Up @@ -82,7 +88,7 @@ - (void)testUseEmulatorCreatesOAuthProvider {
OCMVerify([self.mockOAuthProvider providerWithProviderID:@"google.com"]);
}

- (void)testSuccessfullLogin {
- (void)testSuccessfulLogin {
NSString *testIdToken = @"idToken";
NSString *testAccessToken = @"accessToken";

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

OCMExpect([_mockProvider configuredGoogleSignIn]).andReturn(mockSignIn);
OCMExpect([_mockProvider googleSignIn]).andReturn(mockSignIn);

//forward call to signIn delegate
OCMExpect([mockSignIn signIn]).andDo(^(NSInvocation *invocation) {
[mockSignInDelegate signIn:mockSignIn didSignInForUser:mockGoogleUser withError:nil];
// forward call to signIn delegate
OCMExpect([mockSignIn signInWithConfiguration:[OCMArg any]
presentingViewController:[OCMArg any]
hint:[OCMArg any]
callback:[OCMArg any]]).andDo(^(NSInvocation *invocation) {
void (^callback)(GIDGoogleUser *, NSError *) = nil;
[invocation getArgument:&callback atIndex:5];
callback(mockGoogleUser, nil);
});

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

_mockProvider = OCMPartialMock([[FUIGoogleAuth alloc] init]);
_mockProvider = OCMPartialMock([[FUIGoogleAuth alloc] init]);

id mockSignInDelegate = _mockProvider;
id mockSignIn = OCMClassMock([GIDSignIn class]);
id mockAuthentication = OCMClassMock([GIDAuthentication class]);
id mockGoogleUser = OCMClassMock([GIDGoogleUser class]);

OCMStub([_mockProvider clientID]).andReturn(@"clientID");

// mock accessToken
OCMExpect([mockGoogleUser authentication]).andReturn(mockAuthentication);
OCMExpect([mockAuthentication accessToken]).andReturn(testAccessToken);
Expand All @@ -162,11 +175,16 @@ - (void)testLegacyInitSuccessfulLogin {
OCMExpect([mockGoogleUser authentication]).andReturn(mockAuthentication);
OCMExpect([mockAuthentication idToken]).andReturn(testIdToken);

OCMExpect([_mockProvider configuredGoogleSignIn]).andReturn(mockSignIn);
OCMExpect([_mockProvider googleSignIn]).andReturn(mockSignIn);

//forward call to signIn delegate
OCMExpect([mockSignIn signIn]).andDo(^(NSInvocation *invocation) {
[mockSignInDelegate signIn:mockSignIn didSignInForUser:mockGoogleUser withError:nil];
// forward call to signIn delegate
OCMExpect([mockSignIn signInWithConfiguration:[OCMArg any]
presentingViewController:[OCMArg any]
hint:[OCMArg any]
callback:[OCMArg any]]).andDo(^(NSInvocation *invocation) {
void (^callback)(GIDGoogleUser *, NSError *) = nil;
[invocation getArgument:&callback atIndex:5];
callback(mockGoogleUser, nil);
});

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

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

OCMExpect([mockSignIn signIn]).andDo(^(NSInvocation *invocation) {
[mockSignInDelegate signIn:mockSignIn didSignInForUser:mockGoogleUser withError:signInError];
// forward call to signIn delegate
OCMExpect([mockSignIn signInWithConfiguration:[OCMArg any]
presentingViewController:[OCMArg any]
hint:[OCMArg any]
callback:[OCMArg any]]).andDo(^(NSInvocation *invocation) {
void (^callback)(GIDGoogleUser *, NSError *) = nil;
[invocation getArgument:&callback atIndex:5];
callback(mockGoogleUser, signInError);
});


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

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

OCMExpect([mockSignIn signIn]).andDo(^(NSInvocation *invocation) {
[mockSignInDelegate signIn:mockSignIn didSignInForUser:mockGoogleUser withError:signInError];
// forward call to signIn delegate
OCMExpect([mockSignIn signInWithConfiguration:[OCMArg any]
presentingViewController:[OCMArg any]
hint:[OCMArg any]
callback:[OCMArg any]]).andDo(^(NSInvocation *invocation) {
void (^callback)(GIDGoogleUser *, NSError *) = nil;
[invocation getArgument:&callback atIndex:5];
callback(mockGoogleUser, signInError);
});

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

- (void)testSignOut {
id mockSignIn = OCMClassMock([GIDSignIn class]);
OCMExpect([_mockProvider configuredGoogleSignIn]).andReturn(mockSignIn);
OCMExpect([_mockProvider googleSignIn]).andReturn(mockSignIn);
OCMExpect([mockSignIn signOut]);

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

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

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

OCMVerify([self.mockOAuthProvider getCredentialWithUIDelegate:nil completion:OCMOCK_ANY]);
OCMVerify(never(), [self.mockProvider configuredGoogleSignIn]);
OCMVerify(never(), [self.mockProvider googleSignIn]);
}


Expand Down
2 changes: 1 addition & 1 deletion FirebaseGoogleAuthUI/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ platform :ios, '10.0'
target 'FirebaseGoogleAuthUI' do
use_frameworks!

pod 'GoogleSignIn', '~> 5.0'
pod 'GoogleSignIn', '~> 6.0'
pod 'FirebaseAuthUI', :path => '../'

target 'FirebaseGoogleAuthUITests' do
Expand Down
10 changes: 5 additions & 5 deletions FirebaseGoogleAuthUI/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ PODS:
- GoogleUtilities/Environment (~> 7.2)
- nanopb (~> 2.30908.0)
- PromisesObjC (< 3.0, >= 1.2)
- GoogleSignIn (5.0.2):
- AppAuth (~> 1.2)
- GoogleSignIn (6.0.0):
- AppAuth (~> 1.4)
- GTMAppAuth (~> 1.0)
- GTMSessionFetcher/Core (~> 1.1)
- GoogleUtilities/AppDelegateSwizzler (7.5.0):
Expand Down Expand Up @@ -58,7 +58,7 @@ PODS:

DEPENDENCIES:
- FirebaseAuthUI (from `../`)
- GoogleSignIn (~> 5.0)
- GoogleSignIn (~> 6.0)
- OCMock

SPEC REPOS:
Expand Down Expand Up @@ -87,14 +87,14 @@ SPEC CHECKSUMS:
FirebaseCore: a6dba751680d7033b9d3831e1cfc95ead0605118
FirebaseCoreDiagnostics: 7e873baabcfaa9512f538554ae4fa0817aaafbdb
GoogleDataTransport: 85fd18ff3019bb85d3f2c551d04c481dedf71fc9
GoogleSignIn: 7137d297ddc022a7e0aa4619c86d72c909fa7213
GoogleSignIn: b7779a809e1dfb32ebb43131b10d8bfcd53c1383
GoogleUtilities: eea970f4a389963963bffe8d8fabe43540678b9c
GTMAppAuth: ad5c2b70b9a8689e1a04033c9369c4915bfcbe89
GTMSessionFetcher: 36689134877faeb055b27dfa4ccc9ceaa42e029e
nanopb: a0ba3315591a9ae0a16a309ee504766e90db0c96
OCMock: 29f6e52085b4e7d9b075cbf03ed7c3112f82f934
PromisesObjC: 68159ce6952d93e17b2dfe273b8c40907db5ba58

PODFILE CHECKSUM: 5b245dea8385cbe6f02f214577a97083894700bf
PODFILE CHECKSUM: 0ab8f1a707baefc68f0b4f5320060c1502798f29

COCOAPODS: 1.10.1
Loading