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());
}
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);
}
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);
}
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);
}
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);
}
Aggregations