Search in sources :

Example 1 with NoSuchUserName

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();
}
Also used : WrongAnswer(UtilsImplementations.ForgotPasswordHandler.WrongAnswer) IForgotPasswordHandler(UtilsContracts.IForgotPasswordHandler) NoSuchUserName(UtilsImplementations.ForgotPasswordHandler.NoSuchUserName) ForgotPasswordData(BasicCommonClasses.ForgotPasswordData) CommandWrapper(ClientServerApi.CommandWrapper) Login(BasicCommonClasses.Login) IOException(java.io.IOException) Test(org.junit.Test)

Example 2 with NoSuchUserName

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();
    }
}
Also used : WrongAnswer(UtilsImplementations.ForgotPasswordHandler.WrongAnswer) IForgotPasswordHandler(UtilsContracts.IForgotPasswordHandler) NoSuchUserName(UtilsImplementations.ForgotPasswordHandler.NoSuchUserName) ForgotPasswordData(BasicCommonClasses.ForgotPasswordData) CommandWrapper(ClientServerApi.CommandWrapper) Login(BasicCommonClasses.Login) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

ForgotPasswordData (BasicCommonClasses.ForgotPasswordData)2 Login (BasicCommonClasses.Login)2 CommandWrapper (ClientServerApi.CommandWrapper)2 IForgotPasswordHandler (UtilsContracts.IForgotPasswordHandler)2 NoSuchUserName (UtilsImplementations.ForgotPasswordHandler.NoSuchUserName)2 WrongAnswer (UtilsImplementations.ForgotPasswordHandler.WrongAnswer)2 IOException (java.io.IOException)2 Test (org.junit.Test)2