AuditServiceImplTest.java revision 4d83f4bb61c2789f1f180645696388d812315496
/*
* The contents of this file are subject to the terms of the Common Development and
* Distribution License (the License). You may not use this file except in compliance with the
* License.
*
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2014-2015 ForgeRock AS.
*/
/**
* Test the audit service.
*/
public class AuditServiceImplTest {
@Test
public void testAuditServiceActivation() throws Exception {
//given
//when
//if test fails it will throw an exception
}
@Test
public void testAuditServiceCreate() throws Exception {
//given
.transactionId("transactionId")
.eventName("eventName")
.authentication("testuser@forgerock.com")
.toEvent();
final CreateRequest createRequest = Requests.newCreateRequest(TEST_AUDIT_TOPIC, auditEvent.getValue());
//when
new RootContext(), createRequest);
//then
.isNotNull()
.succeeded();
}
@Test
public void testAuditServiceRead() throws Exception {
//given
//when
Promise<ResourceResponse, ResourceException> promise = auditService.handleRead(new RootContext(), readRequest);
//then
.isNotNull()
.isInstanceOf(NotSupportedException.class);
}
@Test
public void testAuditServiceUpdate() throws Exception {
//given
final UpdateRequest updateRequest =
Requests.newUpdateRequest(TEST_AUDIT_TOPIC, ID, new JsonValue(new LinkedHashMap<String, Object>()));
//when
new RootContext(), updateRequest);
//then
.isNotNull()
.isInstanceOf(NotSupportedException.class);
}
@Test
public void testAuditServiceDelete() throws Exception {
//given
//when
new RootContext(), deleteRequest);
//then
.isNotNull()
.isInstanceOf(NotSupportedException.class);
}
@Test
public void testAuditServicePatch() throws Exception {
//given
final PatchRequest patchRequest =
//when
new RootContext(), patchRequest);
//then
.isNotNull()
.isInstanceOf(NotSupportedException.class);
}
@Test
public void testAuditServiceUnknownAction() throws Exception {
//given
final ActionRequest actionRequest = Requests.newActionRequest(TEST_AUDIT_TOPIC, ID, "unknownAction");
//when
//then
.isInstanceOf(BadRequestException.class);
}
@Test
public void testActionForChangedFields() throws Exception {
//given - depends on 'mail' being configured as a watched field.
)),
))
)
);
ActionRequest changedFieldsRequest = Requests.newActionRequest(TEST_AUDIT_TOPIC, ID, getChangedWatchedFields.name());
// when
// then
}
@Test
public void testActionForChangedPassword() throws Exception {
// given
)),
))
)
);
ActionRequest changedPasswordRequest = Requests.newActionRequest(TEST_AUDIT_TOPIC, ID, getChangedPasswordFields.name());
//when
//then
}
@Test
public void testAuditServiceQuery() throws Exception {
//given
//when
Promise<QueryResponse, ResourceException> promise = auditService.handleQuery(new RootContext(), queryRequest,
//then
.isNotNull()
.isInstanceOf(NotSupportedException.class);
}
@Test
public void testExceptionFormatter() throws Exception {
//given
.transactionId("transactionId")
.eventName("eventName")
.authentication("testuser@forgerock.com")
.toEvent();
final CreateRequest createRequest = Requests.newCreateRequest(TEST_AUDIT_TOPIC, auditEvent.getValue());
//when
new RootContext(), createRequest);
//then
}
@Test
public void testAvailableHandlersAction() throws Exception {
//when
//then
// { "type": "object", "properties": { "message": { "type": "string" } } }
final JsonValue expectedConfig;
}
}
}
return auditService;
}
static class TestAuditEventBuilder<T extends TestAuditEventBuilder<T>>
extends AuditEventBuilder<T> {
@SuppressWarnings("rawtypes")
public static TestAuditEventBuilder<?> testAuditEventBuilder() {
return new TestAuditEventBuilder();
}
return self();
}
}
}