use of org.simbasecurity.core.chain.Command.State in project simba-os by cegeka.
the class ChangePasswordCommandTest method testPasswordReset_passwordNotValid.
@Test
public void testPasswordReset_passwordNotValid() throws Exception {
String simbaURL = "simbaURL";
String requestURL = "requestURL";
when(chainContextMock.getSimbaWebURL()).thenReturn(simbaURL);
when(chainContextMock.getRequestURL()).thenReturn(requestURL);
when(chainContextMock.getClientIpAddress()).thenReturn(IP_ADDRESS);
when(chainContextMock.getUserName()).thenReturn(USERNAME);
when(chainContextMock.getRequestParameter(AuthenticationConstants.NEW_PASSWORD)).thenReturn(NEW_PASSWORD);
when(chainContextMock.getRequestParameter(AuthenticationConstants.NEW_PASSWORD_CONFIRMATION)).thenReturn(NEW_PASSWORD);
doThrow(new SimbaException(PASSWORD_INVALID_LENGTH)).when(credentialServiceMock).changePassword(USERNAME, NEW_PASSWORD, NEW_PASSWORD);
when(chainContextMock.isChangePasswordRequest()).thenReturn(Boolean.TRUE);
State state = command.execute(chainContextMock);
verify(auditMock).log(captor.capture());
AuditLogEvent resultAuditLogEvent = captor.getValue();
assertEquals(AuditLogEventCategory.SESSION, resultAuditLogEvent.getCategory());
assertEquals(AuditMessages.FAILURE + AuditMessages.PASSWORD_NOT_VALID, resultAuditLogEvent.getMessage());
verify(chainContextMock).redirectWithCredentialError(PASSWORD_INVALID_LENGTH);
assertEquals(State.FINISH, state);
}
use of org.simbasecurity.core.chain.Command.State in project simba-os by cegeka.
the class ChangePasswordCommandTest method testPasswordReset_notPasswordResetRequest.
@Test
public void testPasswordReset_notPasswordResetRequest() throws Exception {
when(chainContextMock.isChangePasswordRequest()).thenReturn(Boolean.FALSE);
State state = command.execute(chainContextMock);
assertEquals(State.CONTINUE, state);
}
use of org.simbasecurity.core.chain.Command.State in project simba-os by cegeka.
the class CheckClientIPCommandTest method redirectIfClientIpDifferentFromIpStoredInSession.
@Test
public void redirectIfClientIpDifferentFromIpStoredInSession() throws Exception {
when(sessionMock.getClientIpAddress()).thenReturn(OTHER_IP_ADDRESS);
Command.State state = command.execute(chainContextMock);
assertEquals(State.FINISH, state);
verify(chainContextMock).redirectToLogin();
}
use of org.simbasecurity.core.chain.Command.State in project simba-os by cegeka.
the class CheckShowChangePasswordCommandTest method redirectToChangePasswordPageWhenIsShowChangePassword.
@Test
public void redirectToChangePasswordPageWhenIsShowChangePassword() throws Exception {
when(chainContextMock.isShowChangePasswordRequest()).thenReturn(true);
State state = command.execute(chainContextMock);
verify(chainContextMock).redirectToChangePasswordDirect();
verify(auditMock).log(captor.capture());
AuditLogEvent resultAuditLogEvent = captor.getValue();
assertEquals(AuditLogEventCategory.AUTHENTICATION, resultAuditLogEvent.getCategory());
assertEquals(REDIRECT_TO_CHANGE_PASSWORD, resultAuditLogEvent.getMessage());
assertEquals(FINISH, state);
}
use of org.simbasecurity.core.chain.Command.State in project simba-os by cegeka.
the class EnterApplicationCommandTest method doFilterAndFinishOnExecute.
@Test
public void doFilterAndFinishOnExecute() throws Exception {
SSOToken ssoToken = new SSOToken();
when(chainContextMock.getRequestSSOToken()).thenReturn(ssoToken);
State state = enterApplicationCommand.execute(chainContextMock);
assertThat(state).isEqualTo(State.FINISH);
verify(chainContextMock).activateAction(ActionType.DO_FILTER_AND_SET_PRINCIPAL);
verify(auditLogEventFactory).createEventForAuthenticationForSuccess(chainContextMock, AuditMessages.ENTER_APPLICATION);
verify(auditMock).log(any(AuditLogEvent.class));
}
Aggregations