Search in sources :

Example 16 with State

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();
}
Also used : AuditLogEvent(org.simbasecurity.core.audit.AuditLogEvent) State(org.simbasecurity.core.chain.Command.State) Test(org.junit.Test)

Example 17 with State

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);
}
Also used : AuditLogEvent(org.simbasecurity.core.audit.AuditLogEvent) State(org.simbasecurity.core.chain.Command.State) Test(org.junit.Test)

Example 18 with State

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);
}
Also used : State(org.simbasecurity.core.chain.Command.State) Test(org.junit.Test)

Example 19 with 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);
}
Also used : State(org.simbasecurity.core.chain.Command.State) Test(org.junit.Test)

Example 20 with 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);
}
Also used : State(org.simbasecurity.core.chain.Command.State) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)20 State (org.simbasecurity.core.chain.Command.State)20 AuditLogEvent (org.simbasecurity.core.audit.AuditLogEvent)7 SSOToken (org.simbasecurity.api.service.thrift.SSOToken)2 Session (org.simbasecurity.core.domain.Session)2 User (org.simbasecurity.core.domain.User)2 ActionType (org.simbasecurity.api.service.thrift.ActionType)1 Command (org.simbasecurity.core.chain.Command)1 UserEntity (org.simbasecurity.core.domain.UserEntity)1 SimbaException (org.simbasecurity.core.exception.SimbaException)1