GoogleAuthProvider extends AuthProvider { public void setScopes(@NonNull Scope... scope) { this.scopes = scope; } GoogleAuthProvider(@NonNull String serverClientId, @NonNull AuthenticationAPIClient client);  GoogleAuthProvider(@NonNull String connectionName, @NonNull String serverClientId, @NonNull AuthenticationAPIClient client); void setRequiredPermissions(@NonNull String[] androidPermissions); void rememberLastLogin(boolean rememberLastLogin); void setScopes(@NonNull Scope... scope); @Override boolean authorize(int requestCode, int resultCode, @Nullable Intent intent); @Override boolean authorize(@Nullable Intent intent); @Override String[] getRequiredAndroidPermissions(); @Override void stop(); @Override void clearSession();  }
@Test public void shouldNotCallAuth0OAuthEndpointWhenSomeScopesWereRejected() throws Exception { provider.setScopes(new Scope("some-scope")); provider.start(activity, callback, PERMISSION_REQ_CODE, AUTH_REQ_CODE); when(client.loginWithOAuthAccessToken(TOKEN, CONNECTION_NAME)).thenReturn(authenticationRequest); provider.googleCallback.onSuccess(createGoogleSignInAccountFromToken(TOKEN, Collections.<Scope>emptySet())); verify(client, VerificationModeFactory.noMoreInteractions()).loginWithOAuthAccessToken(TOKEN, CONNECTION_NAME); }
@Test public void shouldFailWithExceptionWhenSomeScopesWereRejected() throws Exception { provider.setScopes(new Scope("some-scope")); provider.start(activity, callback, PERMISSION_REQ_CODE, AUTH_REQ_CODE); when(client.loginWithOAuthAccessToken(TOKEN, CONNECTION_NAME)).thenReturn(authenticationRequest); final Set<Scope> scopes = Collections.emptySet(); provider.googleCallback.onSuccess(createGoogleSignInAccountFromToken(TOKEN, scopes)); verify(callback).onFailure(any(AuthenticationException.class)); }