Search in sources :

Example 1 with SignOutOptions

use of com.amazonaws.mobile.client.SignOutOptions in project amplify-android by aws-amplify.

the class AuthComponentTest method signOutWithBrowserPackage.

/**
 * Tests that signOut called with options specifying an override for the browser package to use for signing out
 * of a web UI sign in experience has the proper options set.
 * @throws AuthException test fails if this gets thrown since method should succeed
 */
@Test
public void signOutWithBrowserPackage() throws AuthException {
    String browserPackage = "org.mozilla.firefox";
    doAnswer(invocation -> {
        Callback<Void> callback = invocation.getArgument(1);
        callback.onResult(null);
        return null;
    }).when(mobileClient).signOut(any(), any());
    synchronousAuth.signOut(AWSCognitoAuthSignOutOptions.builder().browserPackage(browserPackage).build());
    ArgumentCaptor<SignOutOptions> signOutOptionsCaptor = ArgumentCaptor.forClass(SignOutOptions.class);
    verify(mobileClient).signOut(signOutOptionsCaptor.capture(), any());
    assertFalse(signOutOptionsCaptor.getValue().isSignOutGlobally());
    assertTrue(signOutOptionsCaptor.getValue().isInvalidateTokens());
    assertEquals(browserPackage, signOutOptionsCaptor.getValue().getBrowserPackage());
}
Also used : SignOutOptions(com.amazonaws.mobile.client.SignOutOptions) AWSCognitoAuthSignOutOptions(com.amplifyframework.auth.cognito.options.AWSCognitoAuthSignOutOptions) RandomString(com.amplifyframework.testutils.random.RandomString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Aggregations

SignOutOptions (com.amazonaws.mobile.client.SignOutOptions)1 AWSCognitoAuthSignOutOptions (com.amplifyframework.auth.cognito.options.AWSCognitoAuthSignOutOptions)1 RandomString (com.amplifyframework.testutils.random.RandomString)1 Test (org.junit.Test)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1