Search in sources :

Example 6 with ResourceResponse

use of org.forgerock.json.resource.ResourceResponse in project OpenAM by OpenRock.

the class AuditFilterTest method shouldReturnNullForUpdateSuccess.

@Test
public void shouldReturnNullForUpdateSuccess() {
    UpdateRequest updateRequest = mock(UpdateRequest.class);
    ResourceResponse resourceResponse = mock(ResourceResponse.class);
    JsonValue filterResponse = auditFilter.getUpdateSuccessDetail(updateRequest, resourceResponse);
    assertThat(filterResponse).isEqualTo(null);
}
Also used : ResourceResponse(org.forgerock.json.resource.ResourceResponse) UpdateRequest(org.forgerock.json.resource.UpdateRequest) JsonValue(org.forgerock.json.JsonValue) Test(org.testng.annotations.Test)

Example 7 with ResourceResponse

use of org.forgerock.json.resource.ResourceResponse in project OpenAM by OpenRock.

the class AuditFilterTest method shouldAuditSuccessForResults.

@Test
public void shouldAuditSuccessForResults() throws Exception {
    ResourceResponse response = mock(ResourceResponse.class);
    Promise<ResourceResponse, ResourceException> myPromise = Promises.newResultPromise(response);
    given(filterChain.handleUpdate(any(Context.class), any(UpdateRequest.class))).willReturn(myPromise);
    given(auditorFactory.create(context, updateRequest)).willReturn(auditor);
    AuditFilter auditFilter = new AuditFilter(debug, auditorFactory);
    auditFilter.filterUpdate(context, updateRequest, filterChain);
    verify(auditor).auditAccessSuccess(null);
}
Also used : Context(org.forgerock.services.context.Context) ResourceResponse(org.forgerock.json.resource.ResourceResponse) UpdateRequest(org.forgerock.json.resource.UpdateRequest) ResourceException(org.forgerock.json.resource.ResourceException) Test(org.testng.annotations.Test)

Example 8 with ResourceResponse

use of org.forgerock.json.resource.ResourceResponse in project OpenAM by OpenRock.

the class AuditFilterTest method shouldReturnNullForReadSuccess.

@Test
public void shouldReturnNullForReadSuccess() {
    ReadRequest readRequest = mock(ReadRequest.class);
    ResourceResponse resourceResponse = mock(ResourceResponse.class);
    JsonValue filterResponse = auditFilter.getReadSuccessDetail(readRequest, resourceResponse);
    assertThat(filterResponse).isEqualTo(null);
}
Also used : ResourceResponse(org.forgerock.json.resource.ResourceResponse) JsonValue(org.forgerock.json.JsonValue) ReadRequest(org.forgerock.json.resource.ReadRequest) Test(org.testng.annotations.Test)

Example 9 with ResourceResponse

use of org.forgerock.json.resource.ResourceResponse in project OpenAM by OpenRock.

the class AuditFilterTest method shouldReturnNullForPatchSuccess.

@Test
public void shouldReturnNullForPatchSuccess() {
    PatchRequest patchRequest = mock(PatchRequest.class);
    ResourceResponse resourceResponse = mock(ResourceResponse.class);
    JsonValue filterResponse = auditFilter.getPatchSuccessDetail(patchRequest, resourceResponse);
    assertThat(filterResponse).isEqualTo(null);
}
Also used : ResourceResponse(org.forgerock.json.resource.ResourceResponse) JsonValue(org.forgerock.json.JsonValue) PatchRequest(org.forgerock.json.resource.PatchRequest) Test(org.testng.annotations.Test)

Example 10 with ResourceResponse

use of org.forgerock.json.resource.ResourceResponse in project OpenAM by OpenRock.

the class KbaResource method readInstance.

@Override
public Promise<ResourceResponse, ResourceException> readInstance(Context context, ReadRequest readRequest) {
    String realm = RealmContext.getRealm(context);
    JsonValue kbaJson = configHandler.getConfig(realm, KbaBuilder.class);
    ResourceResponse response = Responses.newResourceResponse("1", "1.0", kbaJson);
    return Promises.newResultPromise(response);
}
Also used : ResourceResponse(org.forgerock.json.resource.ResourceResponse) JsonValue(org.forgerock.json.JsonValue)

Aggregations

ResourceResponse (org.forgerock.json.resource.ResourceResponse)227 ResourceException (org.forgerock.json.resource.ResourceException)171 Test (org.testng.annotations.Test)154 JsonValue (org.forgerock.json.JsonValue)123 Context (org.forgerock.services.context.Context)83 RealmContext (org.forgerock.openam.rest.RealmContext)72 Subject (javax.security.auth.Subject)57 SSOTokenContext (org.forgerock.openam.rest.resource.SSOTokenContext)48 Responses.newResourceResponse (org.forgerock.json.resource.Responses.newResourceResponse)44 CreateRequest (org.forgerock.json.resource.CreateRequest)41 ClientContext (org.forgerock.services.context.ClientContext)41 ArrayList (java.util.ArrayList)38 EntitlementException (com.sun.identity.entitlement.EntitlementException)30 ReadRequest (org.forgerock.json.resource.ReadRequest)30 NotFoundException (org.forgerock.json.resource.NotFoundException)29 UpdateRequest (org.forgerock.json.resource.UpdateRequest)29 Matchers.anyString (org.mockito.Matchers.anyString)28 HashSet (java.util.HashSet)27 BadRequestException (org.forgerock.json.resource.BadRequestException)26 DeleteRequest (org.forgerock.json.resource.DeleteRequest)26