use of com.amplifyframework.auth.AuthUser in project amplify-android by aws-amplify.
the class RxAuthBindingTest method testGetCurrentUser.
/**
* Getting the current user should just pass through to the delegate, to return whatever
* it would.
*/
@Test
public void testGetCurrentUser() {
AuthUser expected = new AuthUser(RandomString.string(), RandomString.string());
when(delegate.getCurrentUser()).thenReturn(expected);
assertEquals(expected, auth.getCurrentUser());
}
use of com.amplifyframework.auth.AuthUser in project amplify-android by aws-amplify.
the class AuthComponentTest method getCurrentUser.
/**
* Tests that the getCurrentUser method of the Auth wrapper of AWSMobileClient (AMC) returns a new
* AWSCognitoAuthUser object containing the userId property in the plugin and the username from AMC.getUsername().
*/
@Test
public void getCurrentUser() {
doAnswer(invocation -> USERNAME).when(mobileClient).getUsername();
AuthUser user = authCategory.getCurrentUser();
assertEquals(USER_SUB, user.getUserId());
assertEquals(USERNAME, user.getUsername());
}
use of com.amplifyframework.auth.AuthUser in project amplify-android by aws-amplify.
the class AWSCognitoAuthPlugin method convertSignUpResult.
private AuthSignUpResult convertSignUpResult(@NonNull SignUpResult result, @NonNull String username) {
UserCodeDeliveryDetails details = Objects.requireNonNull(result).getUserCodeDeliveryDetails();
AuthCodeDeliveryDetails newDetails = details != null ? new AuthCodeDeliveryDetails(details.getDestination(), AuthCodeDeliveryDetails.DeliveryMedium.fromString(details.getDeliveryMedium()), details.getAttributeName()) : null;
return new AuthSignUpResult(true, new AuthNextSignUpStep(result.getConfirmationState() ? AuthSignUpStep.DONE : AuthSignUpStep.CONFIRM_SIGN_UP_STEP, Collections.emptyMap(), newDetails), result.getUserSub() != null ? new AuthUser(result.getUserSub(), username) : null);
}
Aggregations