Search in sources :

Example 1 with State

use of org.simbasecurity.core.chain.Command.State in project simba-os by cegeka.

the class CreateEIDUserCommandTest method execute_CreateNewUser.

@Test
public void execute_CreateNewUser() throws Exception {
    when(chainContextMock.getSAMLUser()).thenReturn(samlUser);
    when(userServiceMock.findByName(INSZ)).thenReturn(null);
    State state = createEIDUserCommand.execute(chainContextMock);
    assertEquals(State.CONTINUE, state);
    verify(userServiceMock).create(userCaptor.capture(), roleListCaptor.capture());
    verify(chainContextMock).setUserPrincipal(INSZ);
    User user = userCaptor.getValue();
    assertEquals(INSZ, user.getUserName());
    assertEquals(FIRSTNAME, user.getFirstName());
    assertEquals(LASTNAME, user.getName());
    assertEquals(Language.nl_NL, user.getLanguage());
    assertFalse(user.isChangePasswordOnNextLogon());
    assertFalse(user.isPasswordChangeRequired());
    List<String> roleList = roleListCaptor.getValue();
    assertEquals(1, roleList.size());
    assertEquals("guest", roleList.iterator().next());
}
Also used : User(org.simbasecurity.core.domain.User) State(org.simbasecurity.core.chain.Command.State) Test(org.junit.Test)

Example 2 with State

use of org.simbasecurity.core.chain.Command.State in project simba-os by cegeka.

the class SAMLLogoutCommandTest method testExecute_SAMLLogoutResponse.

@Test
public void testExecute_SAMLLogoutResponse() throws Exception {
    when(samlResponseHandler.isLogoutResponse()).thenReturn(true);
    State state = samlLogoutCommand.execute(chainContext);
    verify(chainContext).redirectToLogout();
    assertEquals(State.FINISH, state);
}
Also used : State(org.simbasecurity.core.chain.Command.State) Test(org.junit.Test)

Example 3 with State

use of org.simbasecurity.core.chain.Command.State in project simba-os by cegeka.

the class ValidateSAMLParametersCommandTest method testExecute_Valid.

@Test
public void testExecute_Valid() throws Exception {
    when(samlResponseHandlerMock.isValid()).thenReturn(true);
    State state = command.execute(chainContextMock);
    verify(auditMock).log(captor.capture());
    AuditLogEvent resultAuditLogEvent = captor.getValue();
    assertEquals(AuditLogEventCategory.AUTHENTICATION, resultAuditLogEvent.getCategory());
    assertEquals(AuditMessages.SUCCESS + AuditMessages.VALID_SAML_RESPONSE, resultAuditLogEvent.getMessage());
    assertEquals(State.CONTINUE, state);
}
Also used : State(org.simbasecurity.core.chain.Command.State) Test(org.junit.Test)

Example 4 with State

use of org.simbasecurity.core.chain.Command.State in project simba-os by cegeka.

the class ValidateSAMLParametersCommandTest method testExecute_Invalid.

@Test
public void testExecute_Invalid() throws Exception {
    when(samlResponseHandlerMock.isValid()).thenReturn(false);
    State state = command.execute(chainContextMock);
    verify(chainContextMock).redirectToAccessDenied();
    verify(auditMock).log(captor.capture());
    AuditLogEvent resultAuditLogEvent = captor.getValue();
    assertEquals(AuditLogEventCategory.AUTHENTICATION, resultAuditLogEvent.getCategory());
    assertEquals(AuditMessages.FAILURE + AuditMessages.INVALID_SAML_RESPONSE, resultAuditLogEvent.getMessage());
    assertEquals(State.FINISH, state);
}
Also used : State(org.simbasecurity.core.chain.Command.State) Test(org.junit.Test)

Example 5 with State

use of org.simbasecurity.core.chain.Command.State in project simba-os by cegeka.

the class CheckPasswordExpiredCommandTest method testExecute_notMustChangePassword_continue.

@Test
public void testExecute_notMustChangePassword_continue() throws Exception {
    when(credentialServiceMock.mustChangePasswordOnNextLogon(USER_NAME)).thenReturn(Boolean.FALSE);
    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)

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