Search in sources :

Example 1 with AuditLogEvent

use of org.simbasecurity.core.audit.AuditLogEvent in project simba-os by cegeka.

the class CheckShowChangePasswordCommandTest method continueOtherwise.

@Test
public void continueOtherwise() throws Exception {
    when(chainContextMock.isShowChangePasswordRequest()).thenReturn(false);
    command.execute(chainContextMock);
    verify(chainContextMock).isShowChangePasswordRequest();
    verify(chainContextMock).getUserName();
    verify(chainContextMock).getClientIpAddress();
    verify(auditMock).log(captor.capture());
    AuditLogEvent resultAuditLogEvent = captor.getValue();
    assertEquals(AuditLogEventCategory.AUTHENTICATION, resultAuditLogEvent.getCategory());
    assertEquals(SUCCESS + CHECK_SHOW_PASSWORD, resultAuditLogEvent.getMessage());
}
Also used : AuditLogEvent(org.simbasecurity.core.audit.AuditLogEvent) Test(org.junit.Test)

Example 2 with AuditLogEvent

use of org.simbasecurity.core.audit.AuditLogEvent 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)

Example 3 with AuditLogEvent

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

Example 4 with AuditLogEvent

use of org.simbasecurity.core.audit.AuditLogEvent in project simba-os by cegeka.

the class ExcludeResourceCommandTest method testExecute_resourceExcluded_finishDoFilterSetPrincipal.

@Test
public void testExecute_resourceExcluded_finishDoFilterSetPrincipal() throws Exception {
    when(mockExcludedResourceService.isResourceExcluded(DUMMY_URL)).thenReturn(TRUE);
    assertEquals(State.FINISH, command.execute(contextMock));
    verify(contextMock).activateAction(ActionType.DO_FILTER_AND_SET_PRINCIPAL);
    verify(auditMock).log(captor.capture());
    AuditLogEvent resultAuditLogEvent = captor.getValue();
    assertEquals(AuditLogEventCategory.AUTHENTICATION, resultAuditLogEvent.getCategory());
    assertEquals(SUCCESS + "Resource excluded [" + DUMMY_URL + "]", resultAuditLogEvent.getMessage());
}
Also used : AuditLogEvent(org.simbasecurity.core.audit.AuditLogEvent) Test(org.junit.Test)

Example 5 with AuditLogEvent

use of org.simbasecurity.core.audit.AuditLogEvent in project simba-os by cegeka.

the class JaasLoginCommandTest method successfulLogin.

@Test
public void successfulLogin() throws Exception {
    TestLoginModule.setValues(false, true, true, false);
    assertEquals(State.CONTINUE, jaasLoginCommand.execute(contextMock));
    verify(auditMock).log(captor.capture());
    AuditLogEvent resultAuditLogEvent = captor.getValue();
    assertEquals(AuditLogEventCategory.AUTHENTICATION, resultAuditLogEvent.getCategory());
}
Also used : AuditLogEvent(org.simbasecurity.core.audit.AuditLogEvent) Test(org.junit.Test)

Aggregations

AuditLogEvent (org.simbasecurity.core.audit.AuditLogEvent)36 Test (org.junit.Test)32 Command (org.simbasecurity.core.chain.Command)9 User (org.simbasecurity.core.domain.User)8 State (org.simbasecurity.core.chain.Command.State)6 UserTestBuilder.aDefaultUser (org.simbasecurity.core.domain.UserTestBuilder.aDefaultUser)6 SSOToken (org.simbasecurity.api.service.thrift.SSOToken)4 Token (org.simbasecurity.core.domain.communication.token.Token)3 URL (java.net.URL)2 PolicyDecision (org.simbasecurity.api.service.thrift.PolicyDecision)2 Session (org.simbasecurity.core.domain.Session)2 EmailAddress (org.simbasecurity.core.domain.user.EmailAddress)2 TemplateWithLinks (org.simbasecurity.core.service.communication.mail.template.TemplateWithLinks)2 Optional (java.util.Optional)1 Audit (org.simbasecurity.core.audit.Audit)1 AuditLogEventFactory (org.simbasecurity.core.audit.AuditLogEventFactory)1 ChainContext (org.simbasecurity.core.chain.ChainContext)1 CONTINUE (org.simbasecurity.core.chain.Command.State.CONTINUE)1 FINISH (org.simbasecurity.core.chain.Command.State.FINISH)1 UserTestBuilder.aUser (org.simbasecurity.core.domain.UserTestBuilder.aUser)1