Search in sources :

Example 1 with AuditEventHandlerConfiguration

use of org.forgerock.openam.audit.configuration.AuditEventHandlerConfiguration in project OpenAM by OpenRock.

the class AuditServiceProviderImplTest method setUp.

@BeforeMethod
protected void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    Map<String, Set<String>> configAttributes = new HashMap<>();
    configAttributes.put("handlerFactory", singleton(MockAuditEventHandlerFactory.class.getName()));
    configAttributes.put("topics", singleton("access"));
    configAttributes.put("enabled", singleton("true"));
    AuditEventHandlerConfiguration configuration = AuditEventHandlerConfiguration.builder().withName("Mock Handler").withAttributes(configAttributes).withEventTopicsMetaData(EventTopicsMetaDataBuilder.coreTopicSchemas().build()).build();
    handlerConfigs.add(configuration);
    configAttributes = new HashMap<>();
    configAttributes.put("handlerFactory", singleton("no.such.class"));
    configAttributes.put("topics", singleton("access"));
    configAttributes.put("enabled", singleton("true"));
    configuration = AuditEventHandlerConfiguration.builder().withName("No such handler").withAttributes(configAttributes).withEventTopicsMetaData(EventTopicsMetaDataBuilder.coreTopicSchemas().build()).build();
    handlerConfigs.add(configuration);
    auditServiceConfig = new AMAuditServiceConfiguration(true);
    provider = new AuditServiceProviderImpl(new MockAuditServiceConfigurationProvider(), mockShutdownManager);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) AuditEventHandlerConfiguration(org.forgerock.openam.audit.configuration.AuditEventHandlerConfiguration) AMAuditServiceConfiguration(org.forgerock.openam.audit.configuration.AMAuditServiceConfiguration) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with AuditEventHandlerConfiguration

use of org.forgerock.openam.audit.configuration.AuditEventHandlerConfiguration 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 3 with AuditEventHandlerConfiguration

use of org.forgerock.openam.audit.configuration.AuditEventHandlerConfiguration 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 4 with AuditEventHandlerConfiguration

use of org.forgerock.openam.audit.configuration.AuditEventHandlerConfiguration 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 5 with AuditEventHandlerConfiguration

use of org.forgerock.openam.audit.configuration.AuditEventHandlerConfiguration 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

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