-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[google_sign_in] Implement disconnect
for Android
#9991
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
stuartmorgan-g
wants to merge
3
commits into
flutter:main
Choose a base branch
from
stuartmorgan-g:google-sign-in-android-disconnect
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
## 7.1.0 | ||
|
||
* Adds support for `disconnect`. | ||
|
||
## 7.0.5 | ||
|
||
* Adds support for `hostedDomain` when authenticating. | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ | |
import com.google.android.gms.auth.api.identity.AuthorizationClient; | ||
import com.google.android.gms.auth.api.identity.AuthorizationRequest; | ||
import com.google.android.gms.auth.api.identity.AuthorizationResult; | ||
import com.google.android.gms.auth.api.identity.RevokeAccessRequest; | ||
import com.google.android.gms.common.api.ApiException; | ||
import com.google.android.gms.common.api.Status; | ||
import com.google.android.gms.tasks.OnSuccessListener; | ||
|
@@ -71,6 +72,7 @@ public class GoogleSignInTest { | |
@Mock CustomCredential mockGenericCredential; | ||
@Mock GoogleIdTokenCredential mockGoogleCredential; | ||
@Mock Task<AuthorizationResult> mockAuthorizationTask; | ||
@Mock Task<Void> mockRevokeAccessTask; | ||
|
||
private GoogleSignInPlugin flutterPlugin; | ||
// Technically this is not the plugin, but in practice almost all of the functionality is in this | ||
|
@@ -88,6 +90,8 @@ public void setUp() { | |
.thenReturn(GoogleIdTokenCredential.TYPE_GOOGLE_ID_TOKEN_CREDENTIAL); | ||
when(mockAuthorizationTask.addOnSuccessListener(any())).thenReturn(mockAuthorizationTask); | ||
when(mockAuthorizationTask.addOnFailureListener(any())).thenReturn(mockAuthorizationTask); | ||
when(mockRevokeAccessTask.addOnSuccessListener(any())).thenReturn(mockRevokeAccessTask); | ||
when(mockRevokeAccessTask.addOnFailureListener(any())).thenReturn(mockRevokeAccessTask); | ||
when(mockAuthorizationIntent.getIntentSender()).thenReturn(mockAuthorizationIntentSender); | ||
when(mockActivityPluginBinding.getActivity()).thenReturn(mockActivity); | ||
|
||
|
@@ -1144,4 +1148,34 @@ public void clearCredentialState_reportsFailure() { | |
|
||
callbackCaptor.getValue().onError(mock(ClearCredentialException.class)); | ||
} | ||
|
||
@Test | ||
public void revokeAccess_callsClient() { | ||
final List<String> scopes = new ArrayList<>(List.of("openid")); | ||
final String accountEmail = "[email protected]"; | ||
PlatformRevokeAccessRequest params = new PlatformRevokeAccessRequest(accountEmail, scopes); | ||
when(mockAuthorizationClient.revokeAccess(any())).thenReturn(mockRevokeAccessTask); | ||
plugin.revokeAccess( | ||
params, | ||
ResultCompat.asCompatCallback( | ||
reply -> { | ||
return null; | ||
})); | ||
|
||
ArgumentCaptor<RevokeAccessRequest> requestCaptor = | ||
ArgumentCaptor.forClass(RevokeAccessRequest.class); | ||
verify(mockAuthorizationClient).revokeAccess(requestCaptor.capture()); | ||
|
||
@SuppressWarnings("unchecked") | ||
ArgumentCaptor<OnSuccessListener<Void>> callbackCaptor = | ||
ArgumentCaptor.forClass(OnSuccessListener.class); | ||
verify(mockRevokeAccessTask).addOnSuccessListener(callbackCaptor.capture()); | ||
callbackCaptor.getValue().onSuccess(null); | ||
|
||
RevokeAccessRequest request = requestCaptor.getValue(); | ||
assertEquals(scopes.size(), request.getScopes().size()); | ||
assertEquals(scopes.get(0), request.getScopes().get(0).getScopeUri()); | ||
// Account is mostly opaque, so just verify that one was set. | ||
assertNotNull(request.getAccount()); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.