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");
}
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);
}
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");
}
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");
}
Aggregations