use of org.simbasecurity.core.audit.AuditLogEvent in project simba-os by cegeka.
the class NewPasswordCommandTest method execute_PasswordConfirmationIsDifferentThenPassword_ThrowsException.
@Test
public void execute_PasswordConfirmationIsDifferentThenPassword_ThrowsException() throws Exception {
when(contextMock.getNewPassword()).thenReturn(Optional.of("newPassword"));
when(contextMock.getNewPasswordConfirmation()).thenReturn("differentPassword");
when(contextMock.getUserName()).thenReturn("someUsername");
when(contextMock.getToken()).thenReturn(Optional.of("token"));
when(contextMock.getEmail()).thenReturn(Optional.of("email"));
doThrow(new SimbaException(PASSWORDS_DONT_MATCH)).when(credentialServiceMock).changePassword("someUsername", "newPassword", "differentPassword");
AuditLogEvent auditLogEvent = mock(AuditLogEvent.class);
when(auditLogFactory.createEventForSessionForFailure(contextMock, PASSWORD_NOT_VALID)).thenReturn(auditLogEvent);
Command.State state = newPasswordCommand.execute(contextMock);
assertThat(state).isEqualTo(FINISH);
verify(credentialServiceMock).changePassword("someUsername", "newPassword", "differentPassword");
verify(auditMock).log(auditLogEvent);
verify(contextMock).redirectToNewPassword("token", "email", "PASSWORDS_DONT_MATCH");
}
use of org.simbasecurity.core.audit.AuditLogEvent in project simba-os by cegeka.
the class DatabaseAuditLogProviderTest method auditEventIsPersisted_digestNotEnabled.
@Test
public void auditEventIsPersisted_digestNotEnabled() {
SSOToken ssoToken = new SSOToken();
AuditLogEvent event = new AuditLogEvent(AuditLogEventCategory.SESSION, "username", ssoToken, "remoteIP", "message", "userAgent", "hostServerName", "surname", "firstname", "requestURL", "CHAINID");
provider.log(event);
jdbcTemplate.query("SELECT * FROM SIMBA_AUDIT_LOG WHERE ssoToken=?", getRowMapper(), ssoToken.getToken());
}
use of org.simbasecurity.core.audit.AuditLogEvent in project simba-os by cegeka.
the class DatabaseDigestAuditLogProviderTest method auditEventIsPersisted.
@Test
public void auditEventIsPersisted() {
SSOToken ssoToken = new SSOToken();
AuditLogEvent event = new AuditLogEvent(AuditLogEventCategory.SESSION, "username", ssoToken, "remoteIP", "message", "userAgent", "hostServerName", "surname", "firstname", "requestURL", "CHAINID");
provider.log(event);
jdbcTemplate.query("SELECT * FROM SIMBA_AUDIT_LOG WHERE ssoToken=?", getRowMapper(), ssoToken.getToken());
}
use of org.simbasecurity.core.audit.AuditLogEvent in project simba-os by cegeka.
the class SessionServiceImplTest method testPurgeExpiredSessions.
@Test
public void testPurgeExpiredSessions() {
Session expiredSession = createSessionMock(true);
Session unexpiredSession = createSessionMock(false);
when(sessionRepository.findAll()).thenReturn(Arrays.asList(expiredSession, unexpiredSession));
service.purgeExpiredSessions();
verify(sessionRepository).remove(expiredSession);
verify(sessionRepository, never()).remove(unexpiredSession);
verify(audit).log(captor.capture());
AuditLogEvent resultAuditLogEvent = captor.getValue();
assertEquals(AuditLogEventCategory.SESSION, resultAuditLogEvent.getCategory());
assertEquals("Purged expired session", resultAuditLogEvent.getMessage());
}
use of org.simbasecurity.core.audit.AuditLogEvent in project simba-os by cegeka.
the class DatabaseAuditLogProviderTest method auditEventIsPersisted_digestEnabled.
@Test
public void auditEventIsPersisted_digestEnabled() {
when(configurationServiceMock.getValue(SimbaConfigurationParameter.AUDIT_LOG_INTEGRITY_ENABLED)).thenReturn(Boolean.TRUE);
SSOToken ssoToken = new SSOToken();
AuditLogEvent event = new AuditLogEvent(AuditLogEventCategory.SESSION, "username", ssoToken, "remoteIP", "message", "userAgent", "hostServerName", "surname", "firstname", "requestURL", "CHAINID");
provider.log(event);
jdbcTemplate.query("SELECT * FROM SIMBA_AUDIT_LOG WHERE ssoToken=?", getRowMapper(false), ssoToken.getToken());
}
Aggregations