use of org.simbasecurity.core.chain.Command.State in project simba-os by cegeka.
the class CheckPasswordExpiredCommandTest method testExecute_mustChangePasswordAndRequestNotDirectlyToSimba_redirectToChangePasswordWithRequestURLAsTarget.
@Test
public void testExecute_mustChangePasswordAndRequestNotDirectlyToSimba_redirectToChangePasswordWithRequestURLAsTarget() throws Exception {
when(credentialServiceMock.mustChangePasswordOnNextLogon(USER_NAME)).thenReturn(Boolean.TRUE);
when(contextMock.getRequestURL()).thenReturn("requestURL");
when(contextMock.getSimbaWebURL()).thenReturn("simbaWebURL");
State state = command.execute(contextMock);
assertEquals(State.FINISH, state);
verify(auditMock).log(captor.capture());
AuditLogEvent resultAuditLogEvent = captor.getValue();
assertEquals(AuditLogEventCategory.AUTHENTICATION, resultAuditLogEvent.getCategory());
assertEquals(MUST_CHANGE_PASSWORD, resultAuditLogEvent.getMessage());
verify(contextMock).redirectToChangePasswordWithFilter();
}
use of org.simbasecurity.core.chain.Command.State in project simba-os by cegeka.
the class CheckPasswordExpiredCommandTest method testExecute_isChangePasswordRequest_continue.
@Test
public void testExecute_isChangePasswordRequest_continue() throws Exception {
when(contextMock.isChangePasswordRequest()).thenReturn(Boolean.TRUE);
State result = command.execute(contextMock);
verify(auditMock).log(captor.capture());
AuditLogEvent resultAuditLogEvent = captor.getValue();
assertEquals(AuditLogEventCategory.AUTHENTICATION, resultAuditLogEvent.getCategory());
assertEquals(SUCCESS + CHECK_PASSWORD_EXPIRED, resultAuditLogEvent.getMessage());
assertEquals(State.CONTINUE, result);
}
use of org.simbasecurity.core.chain.Command.State in project simba-os by cegeka.
the class SAMLLogoutCommandTest method testExecute_noSAMLLogoutResponse.
@Test
public void testExecute_noSAMLLogoutResponse() throws Exception {
when(samlResponseHandler.isLogoutResponse()).thenReturn(false);
State state = samlLogoutCommand.execute(chainContext);
assertEquals(State.CONTINUE, state);
}
use of org.simbasecurity.core.chain.Command.State in project simba-os by cegeka.
the class ChangePasswordCommandTest method testPasswordChangeOk.
@Test
public void testPasswordChangeOk() throws Exception {
when(chainContextMock.isChangePasswordRequest()).thenReturn(Boolean.TRUE);
when(chainContextMock.getUserName()).thenReturn(USERNAME);
when(chainContextMock.getClientIpAddress()).thenReturn(IP_ADDRESS);
when(chainContextMock.getRequestParameter(AuthenticationConstants.PASSWORD)).thenReturn(OLD_PASSWORD);
when(chainContextMock.getRequestParameter(AuthenticationConstants.NEW_PASSWORD)).thenReturn(NEW_PASSWORD);
State state = command.execute(chainContextMock);
verify(auditMock).log(captor.capture());
AuditLogEvent resultAuditLogEvent = captor.getValue();
assertEquals(AuditLogEventCategory.SESSION, resultAuditLogEvent.getCategory());
assertEquals(AuditMessages.SUCCESS + AuditMessages.PASSWORD_CHANGED, resultAuditLogEvent.getMessage());
assertEquals(State.CONTINUE, state);
}
use of org.simbasecurity.core.chain.Command.State in project simba-os by cegeka.
the class LogoutCommandTest method continuesIfNotLogoutRequest.
@Test
public void continuesIfNotLogoutRequest() throws Exception {
when(chainContext.isLogoutRequest()).thenReturn(false);
State state = logoutCommand.execute(chainContext);
assertEquals(State.CONTINUE, state);
}
Aggregations