use of org.simbasecurity.core.audit.AuditLogEvent 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.audit.AuditLogEvent in project simba-os by cegeka.
the class JaasLoginCommandTest method failedLogin_IncreasesInvalidLoginCount.
@Test
public void failedLogin_IncreasesInvalidLoginCount() throws Exception {
TestLoginModule.setValues(false, true, false, false);
when(credentialServiceMock.checkUserStatus(USER_NAME, Status.ACTIVE)).thenReturn(true);
assertEquals(State.FINISH, jaasLoginCommand.execute(contextMock));
verify(auditMock).log(captor.capture());
AuditLogEvent resultAuditLogEvent = captor.getValue();
assertEquals(AuditLogEventCategory.AUTHENTICATION, resultAuditLogEvent.getCategory());
verify(contextMock).redirectWithCredentialError(SimbaMessageKey.LOGIN_FAILED);
verify(credentialServiceMock).increaseInvalidLoginCountAndBlockAccount(USER_NAME);
}
use of org.simbasecurity.core.audit.AuditLogEvent in project simba-os by cegeka.
the class ValidateRequestParametersCommandTest method testExecute_EMPTY_PASSWORD.
@Test
public void testExecute_EMPTY_PASSWORD() throws Exception {
when(contextMock.getRequestParameter(AuthenticationConstants.PASSWORD)).thenReturn(null);
assertEquals(State.FINISH, command.execute(contextMock));
verify(contextMock).redirectWithCredentialError(SimbaMessageKey.EMPTY_PASSWORD);
verify(auditMock).log(captor.capture());
AuditLogEvent resultAuditLogEvent = captor.getValue();
assertEquals(AuditLogEventCategory.AUTHENTICATION, resultAuditLogEvent.getCategory());
assertEquals(FAILURE + EMPTY_PASSWORD, resultAuditLogEvent.getMessage());
}
use of org.simbasecurity.core.audit.AuditLogEvent in project simba-os by cegeka.
the class ValidateRequestParametersCommandTest method testExecute.
@Test
public void testExecute() throws Exception {
assertEquals(State.CONTINUE, command.execute(contextMock));
verify(auditMock).log(captor.capture());
AuditLogEvent resultAuditLogEvent = captor.getValue();
assertEquals(AuditLogEventCategory.AUTHENTICATION, resultAuditLogEvent.getCategory());
assertEquals(SUCCESS + VALID_REQUEST_PARAM, resultAuditLogEvent.getMessage());
}
use of org.simbasecurity.core.audit.AuditLogEvent in project simba-os by cegeka.
the class URLRuleCheckCommandTest method redirectWhenAccessIsDisallowed.
@Test
public void redirectWhenAccessIsDisallowed() throws Exception {
when(authorizationServiceMock.isURLRuleAllowed(USERNAME, REQUEST_URL, REQUEST_METHOD)).thenReturn(new PolicyDecision(false, Long.MAX_VALUE));
assertEquals(State.FINISH, command.execute(contextMock));
verify(auditMock).log(captor.capture());
AuditLogEvent resultAuditLogEvent = captor.getValue();
assertEquals(AuditLogEventCategory.AUTHOR, resultAuditLogEvent.getCategory());
assertEquals(AuditMessages.FAILURE + AuditMessages.ACCESS_DENIED + REQUEST_URL, resultAuditLogEvent.getMessage());
verify(contextMock).redirectToAccessDenied();
}
Aggregations