use of org.simbasecurity.core.audit.AuditLogEvent in project simba-os by cegeka.
the class ValidateRequestParametersCommandTest method testExecute_EMPTY_USERNAME.
@Test
public void testExecute_EMPTY_USERNAME() throws Exception {
when(contextMock.getUserName()).thenReturn(null);
assertEquals(State.FINISH, command.execute(contextMock));
verify(contextMock).redirectWithCredentialError(SimbaMessageKey.EMPTY_USERNAME);
verify(auditMock).log(captor.capture());
AuditLogEvent resultAuditLogEvent = captor.getValue();
assertEquals(AuditLogEventCategory.AUTHENTICATION, resultAuditLogEvent.getCategory());
assertEquals("not yet logged in", resultAuditLogEvent.getUsername());
assertEquals(CLIENT_IP, FAILURE + EMPTY_USERNAME, resultAuditLogEvent.getMessage());
}
use of org.simbasecurity.core.audit.AuditLogEvent in project simba-os by cegeka.
the class URLRuleCheckCommandTest method continueWhenAccessIsAllowed.
@Test
public void continueWhenAccessIsAllowed() throws Exception {
when(authorizationServiceMock.isURLRuleAllowed(USERNAME, REQUEST_URL, REQUEST_METHOD)).thenReturn(new PolicyDecision(true, Long.MAX_VALUE));
assertEquals(State.CONTINUE, command.execute(contextMock));
verify(auditMock).log(captor.capture());
AuditLogEvent resultAuditLogEvent = captor.getValue();
assertEquals(AuditLogEventCategory.AUTHOR, resultAuditLogEvent.getCategory());
assertEquals(AuditMessages.SUCCESS + AuditMessages.CHECK_URL_RULE, resultAuditLogEvent.getMessage());
verifyZeroInteractions(auditMock);
verify(contextMock, never()).redirectToAccessDenied();
}
use of org.simbasecurity.core.audit.AuditLogEvent in project simba-os by cegeka.
the class CheckShowChangePasswordCommandTest method redirectToChangePasswordPageWhenIsShowChangePassword.
@Test
public void redirectToChangePasswordPageWhenIsShowChangePassword() throws Exception {
when(chainContextMock.isShowChangePasswordRequest()).thenReturn(true);
State state = command.execute(chainContextMock);
verify(chainContextMock).redirectToChangePasswordDirect();
verify(auditMock).log(captor.capture());
AuditLogEvent resultAuditLogEvent = captor.getValue();
assertEquals(AuditLogEventCategory.AUTHENTICATION, resultAuditLogEvent.getCategory());
assertEquals(REDIRECT_TO_CHANGE_PASSWORD, resultAuditLogEvent.getMessage());
assertEquals(FINISH, state);
}
use of org.simbasecurity.core.audit.AuditLogEvent in project simba-os by cegeka.
the class CheckAccountBlockedCommandTest method testExecute_AccountNotBlocked.
@Test
public void testExecute_AccountNotBlocked() throws Exception {
when(contextMock.getUserName()).thenReturn(USER_NAME);
when(credentialServiceMock.checkUserStatus(USER_NAME, Status.BLOCKED)).thenReturn(false);
assertEquals(State.CONTINUE, command.execute(contextMock));
verify(auditMock).log(captor.capture());
AuditLogEvent resultAuditLogEvent = captor.getValue();
assertEquals(AuditLogEventCategory.AUTHENTICATION, resultAuditLogEvent.getCategory());
assertEquals(SUCCESS + CHECK_ACCOUNT_BLOCKED, resultAuditLogEvent.getMessage());
}
use of org.simbasecurity.core.audit.AuditLogEvent in project simba-os by cegeka.
the class CheckAccountBlockedCommandTest method testExecute_AccountBlocked.
@Test
public void testExecute_AccountBlocked() throws Exception {
when(contextMock.getUserName()).thenReturn(USER_NAME);
when(contextMock.getClientIpAddress()).thenReturn(CLIENT_IP);
when(credentialServiceMock.checkUserStatus(USER_NAME, Status.BLOCKED)).thenReturn(true);
assertEquals(State.FINISH, command.execute(contextMock));
verify(auditMock).log(captor.capture());
AuditLogEvent resultAuditLogEvent = captor.getValue();
assertEquals(AuditLogEventCategory.AUTHENTICATION, resultAuditLogEvent.getCategory());
assertEquals(FAILURE + DENIED_ACCESS_TO_BLOCKED_ACCOUNT, resultAuditLogEvent.getMessage());
verify(contextMock).redirectWithCredentialError(SimbaMessageKey.ACCOUNT_BLOCKED);
}
Aggregations