Search in sources :

Example 1 with AuditEventHandler

use of org.forgerock.audit.events.handlers.AuditEventHandler in project OpenAM by OpenRock.

the class CsvAuditEventHandlerFactoryTest method shouldCreateCsvEventHandler.

@Test
private void shouldCreateCsvEventHandler() throws AuditException {
    // Given
    Map<String, Set<String>> configAttributes = new HashMap<>();
    configAttributes.put("enabled", singleton("true"));
    configAttributes.put("topics", singleton("access"));
    configAttributes.put("location", singleton(logDirName));
    configAttributes.put("bufferingEnabled", singleton("true"));
    configAttributes.put("bufferingAutoFlush", singleton("false"));
    AuditEventHandlerConfiguration configuration = AuditEventHandlerConfiguration.builder().withName("CSV Handler").withAttributes(configAttributes).withEventTopicsMetaData(eventTopicsMetaData).build();
    // When
    AuditEventHandler handler = factory.create(configuration);
    // Then
    assertThat(handler).isInstanceOf(CsvAuditEventHandler.class);
    assertThat(handler.getName()).isEqualTo("CSV Handler");
    assertThat(handler.getHandledTopics()).containsExactly("access");
    assertThat(handler.isEnabled()).isTrue();
}
Also used : Set(java.util.Set) HashMap(java.util.HashMap) AuditEventHandlerConfiguration(org.forgerock.openam.audit.configuration.AuditEventHandlerConfiguration) AuditEventHandler(org.forgerock.audit.events.handlers.AuditEventHandler) CsvAuditEventHandler(org.forgerock.audit.handlers.csv.CsvAuditEventHandler) Test(org.testng.annotations.Test)

Example 2 with AuditEventHandler

use of org.forgerock.audit.events.handlers.AuditEventHandler in project OpenAM by OpenRock.

the class CsvAuditEventHandlerFactoryTest method shouldCreateCsvEventHandlerWhenDisabled.

@Test
private void shouldCreateCsvEventHandlerWhenDisabled() throws AuditException {
    // Given
    Map<String, Set<String>> configAttributes = new HashMap<>();
    configAttributes.put("enabled", singleton("false"));
    configAttributes.put("topics", singleton("access"));
    configAttributes.put("location", singleton(logDirName));
    configAttributes.put("bufferingEnabled", singleton("true"));
    configAttributes.put("bufferingAutoFlush", singleton("false"));
    AuditEventHandlerConfiguration configuration = AuditEventHandlerConfiguration.builder().withName("CSV Handler").withAttributes(configAttributes).withEventTopicsMetaData(eventTopicsMetaData).build();
    // When
    AuditEventHandler handler = factory.create(configuration);
    // Then
    assertThat(handler).isInstanceOf(CsvAuditEventHandler.class);
    assertThat(handler.getName()).isEqualTo("CSV Handler");
    assertThat(handler.getHandledTopics()).containsExactly("access");
    assertThat(handler.isEnabled()).isFalse();
}
Also used : Set(java.util.Set) HashMap(java.util.HashMap) AuditEventHandlerConfiguration(org.forgerock.openam.audit.configuration.AuditEventHandlerConfiguration) AuditEventHandler(org.forgerock.audit.events.handlers.AuditEventHandler) CsvAuditEventHandler(org.forgerock.audit.handlers.csv.CsvAuditEventHandler) Test(org.testng.annotations.Test)

Example 3 with AuditEventHandler

use of org.forgerock.audit.events.handlers.AuditEventHandler in project OpenAM by OpenRock.

the class JdbcAuditEventHandlerFactoryTest method shouldCreateJdbcEventHandler.

@Test
private void shouldCreateJdbcEventHandler() throws AuditException {
    // Given
    AuditEventHandlerConfiguration configuration = AuditEventHandlerConfiguration.builder().withName("JDBC Handler").withAttributes(configAttributes).withEventTopicsMetaData(eventTopicsMetaData).build();
    // When
    AuditEventHandler handler = factory.create(configuration);
    // Then
    assertThat(handler).isInstanceOf(JdbcAuditEventHandler.class);
    assertThat(handler.getName()).isEqualTo("JDBC Handler");
    assertThat(handler.getHandledTopics()).containsExactly("access");
    assertThat(handler.isEnabled()).isTrue();
}
Also used : AuditEventHandlerConfiguration(org.forgerock.openam.audit.configuration.AuditEventHandlerConfiguration) AuditEventHandler(org.forgerock.audit.events.handlers.AuditEventHandler) JdbcAuditEventHandler(org.forgerock.audit.handlers.jdbc.JdbcAuditEventHandler) Test(org.testng.annotations.Test)

Example 4 with AuditEventHandler

use of org.forgerock.audit.events.handlers.AuditEventHandler in project OpenAM by OpenRock.

the class SyslogAuditEventHandlerFactoryTest method shouldCreateSyslogEventHandler.

@Test
private void shouldCreateSyslogEventHandler() throws AuditException {
    // Given
    AuditEventHandlerConfiguration configuration = AuditEventHandlerConfiguration.builder().withName("Syslog Handler").withAttributes(configAttributes).withEventTopicsMetaData(eventTopicsMetaData).build();
    // When
    AuditEventHandler handler = factory.create(configuration);
    // Then
    assertThat(handler).isInstanceOf(SyslogAuditEventHandler.class);
    assertThat(handler.getName()).isEqualTo("Syslog Handler");
    assertThat(handler.getHandledTopics()).containsExactly("access");
    assertThat(handler.isEnabled()).isTrue();
}
Also used : AuditEventHandlerConfiguration(org.forgerock.openam.audit.configuration.AuditEventHandlerConfiguration) AuditEventHandler(org.forgerock.audit.events.handlers.AuditEventHandler) SyslogAuditEventHandler(org.forgerock.audit.handlers.syslog.SyslogAuditEventHandler) Test(org.testng.annotations.Test)

Aggregations

AuditEventHandler (org.forgerock.audit.events.handlers.AuditEventHandler)4 AuditEventHandlerConfiguration (org.forgerock.openam.audit.configuration.AuditEventHandlerConfiguration)4 Test (org.testng.annotations.Test)4 HashMap (java.util.HashMap)2 Set (java.util.Set)2 CsvAuditEventHandler (org.forgerock.audit.handlers.csv.CsvAuditEventHandler)2 JdbcAuditEventHandler (org.forgerock.audit.handlers.jdbc.JdbcAuditEventHandler)1 SyslogAuditEventHandler (org.forgerock.audit.handlers.syslog.SyslogAuditEventHandler)1