use of org.simbasecurity.core.chain.Command.State in project simba-os by cegeka.
the class CheckPasswordExpiredCommandTest method testExecute_mustChangePasswordAndRequestIsDirectlyToSimba_redirectToChangePasswordWithSuccesURLAsTarget.
@Test
public void testExecute_mustChangePasswordAndRequestIsDirectlyToSimba_redirectToChangePasswordWithSuccesURLAsTarget() throws Exception {
when(credentialServiceMock.mustChangePasswordOnNextLogon(USER_NAME)).thenReturn(Boolean.TRUE);
when(credentialServiceMock.getSuccessURL(USER_NAME)).thenReturn("successURL");
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 LogoutCommandTest method onLogoutRequestRemoveSessionAndRedirectAndDeleteCookie.
@Test
public void onLogoutRequestRemoveSessionAndRedirectAndDeleteCookie() throws Exception {
SSOToken sSOToken = new SSOToken("token");
when(chainContext.getUserName()).thenReturn(USERNAME);
when(chainContext.getClientIpAddress()).thenReturn(CLIENT_IP);
when(chainContext.isLogoutRequest()).thenReturn(true);
Session sessionMock = mock(Session.class);
when(chainContext.getCurrentSession()).thenReturn(sessionMock);
when(chainContext.getRequestSSOToken()).thenReturn(sSOToken);
State state = logoutCommand.execute(chainContext);
assertEquals(State.FINISH, state);
verify(sessionService).removeSession(isA(Session.class));
verify(chainContext).activateAction(ActionType.DELETE_COOKIE);
verify(chainContext).redirectToLogout();
verify(auditMock).log(captor.capture());
AuditLogEvent resultAuditLogEvent = captor.getValue();
assertEquals(AuditLogEventCategory.SESSION, resultAuditLogEvent.getCategory());
assertEquals(AuditMessages.SUCCESS + AuditMessages.LOGGED_OUT + ": SSOToken=" + sSOToken, resultAuditLogEvent.getMessage());
}
use of org.simbasecurity.core.chain.Command.State in project simba-os by cegeka.
the class CreateEIDUserCommandTest method execute_UpdateExistingUser.
@Test
public void execute_UpdateExistingUser() throws Exception {
User user = new UserEntity(INSZ);
when(chainContextMock.getSAMLUser()).thenReturn(samlUser);
when(userServiceMock.findByName(INSZ)).thenReturn(user);
State state = createEIDUserCommand.execute(chainContextMock);
assertEquals(State.CONTINUE, state);
verify(chainContextMock).setUserPrincipal(INSZ);
assertEquals(INSZ, user.getUserName());
assertEquals(FIRSTNAME, user.getFirstName());
assertEquals(LASTNAME, user.getName());
assertEquals(Language.fromISO639Code(NL), user.getLanguage());
}
use of org.simbasecurity.core.chain.Command.State in project simba-os by cegeka.
the class ChangePasswordCommandTest method testPasswordChangeDuringSessionRedirectToPasswordChanged.
@Test
public void testPasswordChangeDuringSessionRedirectToPasswordChanged() throws Exception {
Session sessionMock = mock(Session.class);
when(chainContextMock.getCurrentSession()).thenReturn(sessionMock);
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());
verify(chainContextMock).redirectToPasswordChanged();
assertEquals(State.FINISH, state);
}
use of org.simbasecurity.core.chain.Command.State in project simba-os by cegeka.
the class CheckClientIPCommandTest method continueWithoutActionsIfClientIpEqualsIpStoredInSession.
@Test
public void continueWithoutActionsIfClientIpEqualsIpStoredInSession() throws Exception {
when(sessionMock.getClientIpAddress()).thenReturn(IP_ADDRESS);
State state = command.execute(chainContextMock);
verify(chainContextMock, times(0)).activateAction(isA(ActionType.class));
assertEquals(State.CONTINUE, state);
}
Aggregations