use of com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUserPool in project aws-sdk-android by aws-amplify.
the class CognitoIdentityProviderForgotPasswordTest method forgotPasswordInBackgroundThreadInvalidUser.
@Test
public void forgotPasswordInBackgroundThreadInvalidUser() throws Exception {
testPool = new CognitoUserPool(appContext, TEST_USER_POOL, TEST_CLIENT_ID, TEST_CLIENT_SECRET, mockCSIClient);
testUser = testPool.getUser(TEST_USER_NAME);
// Set mock result for the change password request API call
InvalidParameterException exception = new InvalidParameterException("password change request failed");
doThrow(exception).when(mockCSIClient).forgotPassword(any(ForgotPasswordRequest.class));
// Except to fail
final FlowTracker tracker;
tracker = new FlowTracker("onFailure");
tracker.activate();
testUser.forgotPasswordInBackground(new ForgotPasswordHandler() {
public void onSuccess() {
// Check the flow
assertTrue(tracker.check("onSuccess"));
}
public void getResetCode(ForgotPasswordContinuation var1) {
assertTrue(tracker.check("getResetCode"));
tracker.setNext("onSuccess");
doReturn(TEST_CONFIRM_PASSWORD_RESPONSE).when(mockCSIClient).confirmForgotPassword(any(ConfirmForgotPasswordRequest.class));
var1.setPassword(TEST_USER_PASSWORD);
var1.setVerificationCode(TEST_CODE);
var1.continueTask();
}
public void onFailure(Exception var1) {
assertTrue(tracker.check("onFailure"));
}
});
}
use of com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUserPool in project aws-sdk-android by aws-amplify.
the class CognitoIdentityProviderForgotPasswordTest method confirmPasswordInCurrentThread.
@Test
public void confirmPasswordInCurrentThread() throws Exception {
testPool = new CognitoUserPool(appContext, TEST_USER_POOL, TEST_CLIENT_ID, TEST_CLIENT_SECRET, mockCSIClient);
testUser = testPool.getUser(TEST_USER_NAME);
final FlowTracker tracker;
tracker = new FlowTracker("onSuccess");
tracker.activate();
doReturn(TEST_CONFIRM_PASSWORD_RESPONSE).when(mockCSIClient).confirmForgotPassword(any(ConfirmForgotPasswordRequest.class));
testUser.confirmPassword(TEST_CODE, TEST_USER_PASSWORD, new ForgotPasswordHandler() {
public void onSuccess() {
// Check the flow
assertTrue(tracker.check("onSuccess"));
}
public void getResetCode(ForgotPasswordContinuation var1) {
assertTrue(tracker.check("getResetCode"));
// Except to fail
tracker.setNext("onFailure");
}
public void onFailure(Exception var1) {
assertTrue(tracker.check("onFailure"));
}
});
}
use of com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUserPool in project aws-sdk-android by aws-amplify.
the class CognitoIdentityProviderForgotPasswordTest method forgotPasswordInBackground.
@Test
public void forgotPasswordInBackground() throws Exception {
testPool = new CognitoUserPool(appContext, TEST_USER_POOL, TEST_CLIENT_ID, TEST_CLIENT_SECRET, mockCSIClient);
testUser = testPool.getUser(TEST_USER_NAME);
final FlowTracker tracker;
tracker = new FlowTracker("getResetCode");
tracker.activate();
doReturn(TEST_FORGOT_PASSWORD_RESPONSE).when(mockCSIClient).forgotPassword(any(ForgotPasswordRequest.class));
testUser.forgotPasswordInBackground(new ForgotPasswordHandler() {
public void onSuccess() {
// Check the flow
assertTrue(tracker.check("onSuccess"));
}
public void getResetCode(ForgotPasswordContinuation var1) {
assertTrue(tracker.check("getResetCode"));
tracker.setNext("onSuccess");
doReturn(TEST_CONFIRM_PASSWORD_RESPONSE).when(mockCSIClient).confirmForgotPassword(any(ConfirmForgotPasswordRequest.class));
var1.setPassword(TEST_USER_PASSWORD);
var1.setVerificationCode(TEST_CODE);
var1.continueTask();
}
public void onFailure(Exception var1) {
assertTrue(tracker.check("onFailure"));
}
});
}
use of com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUserPool in project aws-sdk-android by aws-amplify.
the class CognitoIdentityProviderForgotPasswordTest method forgotPasswordInBackgroundThreadWrongCode.
@Test
public void forgotPasswordInBackgroundThreadWrongCode() throws Exception {
testPool = new CognitoUserPool(appContext, TEST_USER_POOL, TEST_CLIENT_ID, TEST_CLIENT_SECRET, mockCSIClient);
testUser = testPool.getUser(TEST_USER_NAME);
final FlowTracker tracker;
tracker = new FlowTracker("getResetCode");
tracker.activate();
doReturn(TEST_FORGOT_PASSWORD_RESPONSE).when(mockCSIClient).forgotPassword(any(ForgotPasswordRequest.class));
testUser.forgotPasswordInBackground(new ForgotPasswordHandler() {
public void onSuccess() {
// Check the flow
assertTrue(tracker.check("onSuccess"));
}
public void getResetCode(ForgotPasswordContinuation var1) {
assertTrue(tracker.check("getResetCode"));
// Except to fail
tracker.setNext("onFailure");
InvalidParameterException exception = new InvalidParameterException("password change request failed");
doThrow(exception).when(mockCSIClient).confirmForgotPassword(any(ConfirmForgotPasswordRequest.class));
var1.setPassword(TEST_USER_PASSWORD);
var1.setVerificationCode(TEST_CODE);
var1.continueTask();
}
public void onFailure(Exception var1) {
assertTrue(tracker.check("onFailure"));
}
});
}
use of com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUserPool in project aws-sdk-android by aws-amplify.
the class CognitoIdentityProviderForgotPasswordTest method init.
@Before
public void init() {
// Initialization functions
MockitoAnnotations.initMocks(this);
testPool = new CognitoUserPool(appContext, TEST_USER_POOL, TEST_CLIENT_ID, TEST_CLIENT_SECRET, mockCSIClient);
testUser = testPool.getUser(TEST_USER_NAME);
// Set Forgot password result
TEST_FORGOT_PASSWORD_RESPONSE = new ForgotPasswordResult();
TEST_FORGOT_PASSWORD_RESPONSE.setCodeDeliveryDetails(new CodeDeliveryDetailsType().withDestination("TestDestination").withDeliveryMedium("TestMedium").withAttributeName("TestAttribute"));
}
Aggregations