Search in sources :

Example 21 with AuditEvent

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

the class AbstractRestletAccessAuditFilterTest method shouldCaptureRequestBodyProperties.

@Test
public void shouldCaptureRequestBodyProperties() throws Exception {
    // Given
    auditFilter = new RestletAccessAuditFilterTest(restlet, eventPublisher, eventFactory, RestletBodyAuditor.jsonAuditor("fred"), RestletBodyAuditor.jsonAuditor("gary"));
    Request request = new Request();
    request.setDate(new Date());
    Response response = new Response(request);
    request.setEntity(new JsonRepresentation((Map<String, Object>) object(field("fred", "v"), field("gary", 7))));
    when(eventPublisher.isAuditing(anyString(), anyString(), any(EventName.class))).thenReturn(true);
    // When
    auditFilter.beforeHandle(request, response);
    // Then
    ArgumentCaptor<AuditEvent> captor = ArgumentCaptor.forClass(AuditEvent.class);
    verify(eventPublisher).tryPublish(anyString(), captor.capture());
    assertThat(captor.getValue().getValue()).isObject().hasObject("request").hasObject("detail").contains("fred", "v");
}
Also used : Response(org.restlet.Response) Request(org.restlet.Request) AuditEvent(org.forgerock.audit.events.AuditEvent) JsonRepresentation(org.restlet.ext.json.JsonRepresentation) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Date(java.util.Date) Test(org.testng.annotations.Test)

Example 22 with AuditEvent

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

the class AuditEventPublisherImplTest method shouldSuppressExceptionsOnPublish.

@Test
public void shouldSuppressExceptionsOnPublish() throws Exception {
    // Given
    AuditEvent auditEvent = getAuditEvent(FAILURE_SUPPRESSED_REALM);
    givenSuppressedFailureAuditService();
    // When
    auditEventPublisher.tryPublish("unknownTopic", auditEvent);
}
Also used : AuditEvent(org.forgerock.audit.events.AuditEvent) Test(org.testng.annotations.Test)

Example 23 with AuditEvent

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

the class AMActivityAuditEventBuilderTest method canBuildAccessAuditEventWithContext.

@Test
public void canBuildAccessAuditEventWithContext() throws Exception {
    AuditEvent activityEvent = new AMActivityAuditEventBuilder().timestamp(1436389263629L).eventName(AM_SESSION_CREATED).component(SESSION).transactionId("ad1f26e3-1ced-418d-b6ec-c8488411a625").userId("id=demo,ou=user,dc=openam,dc=forgerock,dc=org").trackingId("12345").runAs("cn=dsameuser,ou=DSAME Users,dc=openam,dc=forgerock,dc=org").objectId("/sessions/uniqueSessionAlias").operation("CREATE").toEvent();
    assertJsonValue(activityEvent.getValue(), "/activity-event.json");
}
Also used : AuditEvent(org.forgerock.audit.events.AuditEvent) Test(org.testng.annotations.Test)

Example 24 with AuditEvent

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

the class AMActivityAuditEventBuilderTest method canBuildAccessAuditEventWithContexts.

@Test
public void canBuildAccessAuditEventWithContexts() throws Exception {
    AuditEvent activityEvent = new AMActivityAuditEventBuilder().timestamp(1436389263629L).eventName(AM_SESSION_CREATED).component(SESSION).transactionId("ad1f26e3-1ced-418d-b6ec-c8488411a625").userId("id=demo,ou=user,dc=openam,dc=forgerock,dc=org").trackingId("12345").runAs("cn=dsameuser,ou=DSAME Users,dc=openam,dc=forgerock,dc=org").objectId("/sessions/uniqueSessionAlias").operation("CREATE").toEvent();
    assertJsonValue(activityEvent.getValue(), "/activity-event.json");
}
Also used : AuditEvent(org.forgerock.audit.events.AuditEvent) Test(org.testng.annotations.Test)

Aggregations

AuditEvent (org.forgerock.audit.events.AuditEvent)24 Test (org.testng.annotations.Test)13 JsonValue (org.forgerock.json.JsonValue)6 Map (java.util.Map)3 AMAccessAuditEventBuilder (org.forgerock.openam.audit.AMAccessAuditEventBuilder)3 Context (org.forgerock.services.context.Context)3 Date (java.util.Date)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 Request (org.restlet.Request)2 Response (org.restlet.Response)2 JsonRepresentation (org.restlet.ext.json.JsonRepresentation)2 LogExtracts (com.sun.identity.log.service.AgentLogParser.LogExtracts)1 URL (java.net.URL)1 List (java.util.List)1 AuditServiceBuilder (org.forgerock.audit.AuditServiceBuilder)1 AuditEventHandler (org.forgerock.audit.events.handlers.AuditEventHandler)1 Handler (org.forgerock.http.Handler)1 Request (org.forgerock.http.protocol.Request)1 SessionContext (org.forgerock.http.session.SessionContext)1 AMAuditServiceConfiguration (org.forgerock.openam.audit.configuration.AMAuditServiceConfiguration)1