use of UtilsImplementations.ForgotPasswordHandler.NoSuchUserName in project SmartCity-Market by TechnionYP5777.
the class ForgotPasswordTest method sendWrongAnswerWithNewPassword.
@Test
public void sendWrongAnswerWithNewPassword() {
ForgotPasswordData forgotPassData = new ForgotPasswordData(null, authQuestionAnswer + "bla");
Login ansAndPassContainer = new Login(worker.getUsername(), newPass, forgotPassData);
try {
Mockito.when(clientRequestHandler.sendRequestWithRespond(new CommandWrapper(WorkerDefs.loginCommandSenderId, CommandDescriptor.FORGOT_PASSWORD_SEND_ANSWER_WITH_NEW_PASSWORD, Serialization.serialize(ansAndPassContainer)).serialize())).thenReturn(new CommandWrapper(ResultDescriptor.SM_FOROGT_PASSWORD_WRONG_ANSWER, null).serialize());
} catch (IOException ¢) {
fail();
}
try {
((IForgotPasswordHandler) worker).sendAnswerAndNewPassword(authQuestionAnswer + "bla", newPass);
} catch (WrongAnswer e) {
//success
return;
} catch (NoSuchUserName e) {
fail();
}
fail();
}
use of UtilsImplementations.ForgotPasswordHandler.NoSuchUserName in project SmartCity-Market by TechnionYP5777.
the class ForgotPasswordTest method sendCorrectAnswerWithNewPassword.
@Test
public void sendCorrectAnswerWithNewPassword() {
ForgotPasswordData forgotPassData = new ForgotPasswordData(null, authQuestionAnswer);
Login ansAndPassContainer = new Login(worker.getUsername(), newPass, forgotPassData);
try {
Mockito.when(clientRequestHandler.sendRequestWithRespond(new CommandWrapper(WorkerDefs.loginCommandSenderId, CommandDescriptor.FORGOT_PASSWORD_SEND_ANSWER_WITH_NEW_PASSWORD, Serialization.serialize(ansAndPassContainer)).serialize())).thenReturn(new CommandWrapper(ResultDescriptor.SM_OK, Serialization.serialize(true)).serialize());
} catch (IOException ¢) {
fail();
}
try {
((IForgotPasswordHandler) worker).sendAnswerAndNewPassword(authQuestionAnswer, newPass);
} catch (NoSuchUserName | WrongAnswer e) {
fail();
}
}
Aggregations