use of BasicCommonClasses.ForgotPasswordData 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 BasicCommonClasses.ForgotPasswordData in project SmartCity-Market by TechnionYP5777.
the class SQLDatabaseConnectionTest method testAddRemoveWorker.
@Test
public void testAddRemoveWorker() {
SQLDatabaseConnection sqlConnection = new SQLDatabaseConnection();
String result = null;
//test add worker
try {
sqlConnection.addWorker(null, new Login(workerName, workerName), new ForgotPasswordData("", ""));
result = sqlConnection.getWorkersList(null);
} catch (CriticalError | ClientNotConnected | ClientAlreadyExist e) {
fail();
}
assert result != null;
HashMap<String, Boolean> map = Serialization.deserializeWorkersHashMap(result);
assert map != null;
assert map.containsKey(workerName);
assertEquals(false, map.get(workerName));
//test remove worker
try {
sqlConnection.removeWorker(null, workerName);
result = sqlConnection.getWorkersList(null);
} catch (CriticalError | ClientNotConnected | ClientNotExist e) {
fail();
}
assert result != null;
map = Serialization.deserializeWorkersHashMap(result);
assert map != null;
assert !map.containsKey(workerName);
}
use of BasicCommonClasses.ForgotPasswordData in project SmartCity-Market by TechnionYP5777.
the class CustomerRegistration_FinalStepScreen method registerButtonPressed.
@FXML
void registerButtonPressed(ActionEvent __) {
ICustomer customer = InjectionFactory.getInstance(Customer.class);
ICustomerProfile iProfile = TempCustomerProfilePassingData.customerProfile;
CustomerProfile profile = new CustomerProfile(iProfile.getUserName(), TempCustomerProfilePassingData.password, iProfile.getFirstName(), iProfile.getLastName(), iProfile.getPhoneNumber(), iProfile.getEmailAddress(), iProfile.getCity(), iProfile.getStreet(), iProfile.getBirthdate(), iProfile.getAllergens(), new ForgotPasswordData(TempCustomerProfilePassingData.sequrityQuestion, TempCustomerProfilePassingData.sequrityAnswer));
try {
customer.registerNewCustomer(profile);
AbstractApplicationScreen.setScene("/CustomerLoginScreen/CustomerLoginScreen.fxml");
TempCustomerProfilePassingData.clear();
} catch (SMException e) {
log.fatal(e);
log.debug(StackTraceUtil.getStackTrace(e));
e.showInfoToUser();
}
}
use of BasicCommonClasses.ForgotPasswordData in project SmartCity-Market by TechnionYP5777.
the class SQLDatabaseConnectionTest method testWorkerCanSetSecurityQA.
@Test
public void testWorkerCanSetSecurityQA() {
SQLDatabaseConnection sqlConnection = new SQLDatabaseConnection();
ForgotPasswordData p = new ForgotPasswordData("question", "answer");
String result = null;
try {
sqlConnection.addWorker(null, new Login(workerName, workerName), new ForgotPasswordData("", ""));
} catch (CriticalError | ClientAlreadyExist | ClientNotConnected e) {
fail();
}
try {
sqlConnection.setSecurityQAWorker(workerName, p);
result = sqlConnection.getSecurityQuestionWorker(workerName);
assertTrue(sqlConnection.verifySecurityAnswerWorker(workerName, "answer"));
assertEquals("question", result);
} catch (CriticalError | ClientNotExist e1) {
fail();
} finally {
try {
sqlConnection.removeWorker(null, workerName);
} catch (CriticalError | ClientNotExist | ClientNotConnected e) {
e.printStackTrace();
}
}
}
use of BasicCommonClasses.ForgotPasswordData in project SmartCity-Market by TechnionYP5777.
the class SQLDatabaseConnectionTest method testWorkerCanLoginWithNewPassword.
@Test
public void testWorkerCanLoginWithNewPassword() {
SQLDatabaseConnection sqlConnection = new SQLDatabaseConnection();
try {
sqlConnection.addWorker(null, new Login(workerName, workerName), new ForgotPasswordData("", ""));
} catch (CriticalError | ClientAlreadyExist | ClientNotConnected e) {
fail();
}
try {
sqlConnection.setPasswordWorker(workerName, "newPass");
//try to login with new password
int sessionID = sqlConnection.loginWorker(workerName, "newPass");
sqlConnection.logout(sessionID, workerName);
} catch (CriticalError | ClientNotExist | AuthenticationError | ClientAlreadyConnected | NumberOfConnectionsExceeded | ClientNotConnected e1) {
fail();
} finally {
try {
sqlConnection.removeWorker(null, workerName);
} catch (CriticalError | ClientNotExist | ClientNotConnected e) {
e.printStackTrace();
}
}
}
Aggregations