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
5 changes: 5 additions & 0 deletions packages/google_sign_in/google_sign_in_ios/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 6.1.0

* Updates to `GoogleSignIn` 9.0.
* Adds support for the `nonce` parameter.

## 6.0.1

* Returns configuration errors as `PlatformException`s in Dart instead of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ - (void)testSignIn {
[self configureMock:[self.mockSignIn expect]
forSignInWithHint:nil
additionalScopes:@[]
nonce:nil
completion:[OCMArg invokeBlockWithArgs:mockSignInResult, [NSNull null], nil]];

XCTestExpectation *expectation = [self expectationWithDescription:@"completion called"];
Expand Down Expand Up @@ -290,6 +291,7 @@ - (void)testSignInWithScopeHint {
serverClientId:nil
hostedDomain:nil]
error:&initializationError];
XCTAssertNil(initializationError);

id mockUser = OCMClassMock([GIDGoogleUser class]);
OCMStub([mockUser userID]).andReturn(@"mockID");
Expand All @@ -302,6 +304,7 @@ - (void)testSignInWithScopeHint {
additionalScopes:[OCMArg checkWithBlock:^BOOL(NSArray<NSString *> *scopes) {
return [[NSSet setWithArray:scopes] isEqualToSet:[NSSet setWithArray:requestedScopes]];
}]
nonce:nil
completion:[OCMArg invokeBlockWithArgs:mockSignInResult, [NSNull null], nil]];

XCTestExpectation *expectation = [self expectationWithDescription:@"completion called"];
Expand All @@ -318,6 +321,40 @@ - (void)testSignInWithScopeHint {
OCMVerifyAll(self.mockSignIn);
}

- (void)testSignInWithNonce {
FlutterError *initializationError;
[self.plugin configureWithParameters:[FSIPlatformConfigurationParams makeWithClientId:nil
serverClientId:nil
hostedDomain:nil]
error:&initializationError];
XCTAssertNil(initializationError);

id mockUser = OCMClassMock([GIDGoogleUser class]);
OCMStub([mockUser userID]).andReturn(@"mockID");
id mockSignInResult = OCMClassMock([GIDSignInResult class]);
OCMStub([mockSignInResult user]).andReturn(mockUser);

NSString *nonce = @"A nonce";
[self configureMock:[self.mockSignIn expect]
forSignInWithHint:nil
additionalScopes:OCMOCK_ANY
nonce:nonce
completion:[OCMArg invokeBlockWithArgs:mockSignInResult, [NSNull null], nil]];

XCTestExpectation *expectation = [self expectationWithDescription:@"completion called"];
[self.plugin signInWithScopeHint:@[]
nonce:nonce
completion:^(FSISignInResult *result, FlutterError *error) {
XCTAssertNil(error);
XCTAssertNil(result.error);
XCTAssertEqualObjects(result.success.user.userId, @"mockID");
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:5.0 handler:nil];

OCMVerifyAll(self.mockSignIn);
}

- (void)testSignInAlreadyGranted {
id mockUser = OCMClassMock([GIDGoogleUser class]);
OCMStub([mockUser userID]).andReturn(@"mockID");
Expand All @@ -327,6 +364,7 @@ - (void)testSignInAlreadyGranted {
[self configureMock:[self.mockSignIn stub]
forSignInWithHint:nil
additionalScopes:OCMOCK_ANY
nonce:nil
completion:[OCMArg invokeBlockWithArgs:mockSignInResult, [NSNull null], nil]];

NSError *sdkError = [NSError errorWithDomain:kGIDSignInErrorDomain
Expand Down Expand Up @@ -355,6 +393,7 @@ - (void)testSignInError {
[self configureMock:[self.mockSignIn stub]
forSignInWithHint:nil
additionalScopes:OCMOCK_ANY
nonce:nil
completion:[OCMArg invokeBlockWithArgs:[NSNull null], sdkError, nil]];

XCTestExpectation *expectation = [self expectationWithDescription:@"completion called"];
Expand All @@ -375,6 +414,7 @@ - (void)testSignInExceptionReturnsError {
OCMExpect([self configureMock:self.mockSignIn
forSignInWithHint:OCMOCK_ANY
additionalScopes:OCMOCK_ANY
nonce:nil
completion:OCMOCK_ANY])
.andThrow([NSException exceptionWithName:@"MockName" reason:@"MockReason" userInfo:nil]);

Expand Down Expand Up @@ -642,17 +682,20 @@ - (void)configureMock:(id)mock
- (void)configureMock:(id)mock
forSignInWithHint:(NSString *)hint
additionalScopes:(NSArray<NSString *> *)additionalScopes
nonce:(nullable NSString *)nonce
completion:(nullable void (^)(GIDSignInResult *_Nullable signInResult,
NSError *_Nullable error))completion {
#if TARGET_OS_OSX
[mock signInWithPresentingWindow:OCMOCK_ANY
hint:hint
additionalScopes:additionalScopes
nonce:nonce
completion:completion];
#else
[mock signInWithPresentingViewController:[OCMArg isKindOfClass:[FlutterViewController class]]
hint:hint
additionalScopes:additionalScopes
nonce:nonce
completion:completion];
#endif
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ Enables Google Sign-In in Flutter apps.
s.public_header_files = 'google_sign_in_ios/Sources/google_sign_in_ios/include/**/*.h'
s.module_map = 'google_sign_in_ios/Sources/google_sign_in_ios/include/FLTGoogleSignInPlugin.modulemap'

# AppAuth and GTMSessionFetcher are GoogleSignIn transitive dependencies.
# Depend on versions which defines modules.
s.dependency 'AppAuth', '>= 1.7.4'
# GTMSessionFetcher is a GoogleSignIn transitive dependency, added here as a
# direct dependency to ensure a version which defines modules.
s.dependency 'GTMSessionFetcher', '>= 3.4.0'
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GoogleSignIn now depends on AppAuth 2.x, so we don't need to set a version floor for that one any more. The GTMSessionFetcher dependency there is still only 3.3+ though, so we still need this one.

s.dependency 'GoogleSignIn', '~> 8.0'
s.dependency 'GoogleSignIn', '~> 9.0'
s.static_framework = true
s.ios.dependency 'Flutter'
s.osx.dependency 'FlutterMacOS'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ let package = Package(
dependencies: [
.package(
url: "https://github.com/google/GoogleSignIn-iOS.git",
from: "8.0.0")
from: "9.0.0")
],
targets: [
.target(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,18 +276,17 @@ - (void)signInWithHint:(nullable NSString *)hint
nonce:(nullable NSString *)nonce
completion:(void (^)(GIDSignInResult *_Nullable signInResult,
NSError *_Nullable error))completion {
// TODO(stuartmorgan): Add the nonce parameter to the calls below once it's available; it was
// added after 8.0, and based on https://github.com/google/GoogleSignIn-iOS/releases appears to
// be slated for an 8.1 release. See https://github.com/flutter/flutter/issues/85439.
#if TARGET_OS_OSX
[self.signIn signInWithPresentingWindow:self.registrar.view.window
hint:hint
additionalScopes:additionalScopes
nonce:nonce
completion:completion];
#else
[self.signIn signInWithPresentingViewController:[self topViewController]
hint:hint
additionalScopes:additionalScopes
nonce:nonce
completion:completion];
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion packages/google_sign_in/google_sign_in_ios/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: google_sign_in_ios
description: iOS implementation of the google_sign_in plugin.
repository: https://github.com/flutter/packages/tree/main/packages/google_sign_in/google_sign_in_ios
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+google_sign_in%22
version: 6.0.1
version: 6.1.0

environment:
sdk: ^3.6.0
Expand Down