use of org.forgerock.openam.audit.configuration.AMAuditServiceConfiguration in project OpenAM by OpenRock.
the class AuditServiceProviderImplTest method shouldNotRegisterHandlersWhenRealmAuditServiceDisabled.
@Test
public void shouldNotRegisterHandlersWhenRealmAuditServiceDisabled() throws Exception {
// Given
auditServiceConfig = new AMAuditServiceConfiguration(false);
// When
configListener.realmConfigurationChanged("anyRealm");
// Then
assertThat(provider.getAuditService("anyRealm").getRegisteredHandler("Mock Handler")).isNull();
}
use of org.forgerock.openam.audit.configuration.AMAuditServiceConfiguration 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);
}
use of org.forgerock.openam.audit.configuration.AMAuditServiceConfiguration in project OpenAM by OpenRock.
the class AuditEventPublisherImplTest method shouldFallBackToDefaultAuditServiceWhenRealmHasShutDown.
@Test
public void shouldFallBackToDefaultAuditServiceWhenRealmHasShutDown() throws Exception {
// Given
AuditEvent auditEvent = getAuditEvent("deadRealm");
givenDefaultAuditService();
when(mockHandler.publishEvent(any(Context.class), eq("access"), auditEventCaptor.capture())).thenReturn(dummyPromise);
AMAuditServiceConfiguration serviceConfig = new AMAuditServiceConfiguration(true);
AuditServiceBuilder builder = AuditServiceBuilder.newAuditService().withConfiguration(serviceConfig).withAuditEventHandler(mock(AuditEventHandler.class));
AMAuditService auditService = new RealmAuditServiceProxy(builder.build(), mock(AMAuditService.class), serviceConfig);
auditService.startup();
auditService.shutdown();
when(auditServiceProvider.getAuditService("deadRealm")).thenReturn(auditService);
// When
auditEventPublisher.tryPublish("access", auditEvent);
// Then
assertThat(auditEventCaptor.getValue()).isEqualTo(auditEvent.getValue());
}
use of org.forgerock.openam.audit.configuration.AMAuditServiceConfiguration in project OpenAM by OpenRock.
the class AuditServiceProviderImpl method refreshDefaultAuditService.
private void refreshDefaultAuditService() {
AMAuditServiceConfiguration configuration = configProvider.getDefaultConfiguration();
AuditServiceBuilder builder = AuditServiceBuilder.newAuditService().withEventTopicsMetaData(eventTopicsMetaData).withConfiguration(configuration);
if (configuration.isAuditEnabled()) {
configureEventHandlers(builder, configProvider.getDefaultEventHandlerConfigurations());
}
try {
defaultAuditService.setDelegate(builder.build(), configuration);
} catch (ServiceUnavailableException e) {
debug.error("Default Audit Service configuration failed.", e);
}
}
use of org.forgerock.openam.audit.configuration.AMAuditServiceConfiguration in project OpenAM by OpenRock.
the class AbstractRestletAccessAuditFilterTest method setUp.
@BeforeMethod
public void setUp() throws Exception {
restlet = mock(Restlet.class);
AMAuditServiceConfiguration serviceConfig = new AMAuditServiceConfiguration(true);
AuditServiceBuilder builder = AuditServiceBuilder.newAuditService().withConfiguration(serviceConfig);
AMAuditService auditService = new DefaultAuditServiceProxy(builder.build(), serviceConfig);
auditService.startup();
auditServiceProvider = mock(AuditServiceProvider.class);
when(auditServiceProvider.getDefaultAuditService()).thenReturn(auditService);
eventFactory = new AuditEventFactory();
eventPublisher = mock(AuditEventPublisher.class);
auditFilter = new RestletAccessAuditFilterTest(restlet, eventPublisher, eventFactory, null, null);
}
Aggregations