Search in sources :

Example 11 with RequestHandler

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

the class RealmContextFilterTest method filterShouldConsumeRealmFromCRUDPAQRequest.

@Test(dataProvider = "CRUDPAQ")
public void filterShouldConsumeRealmFromCRUDPAQRequest(Request request, String postURIString) throws Exception {
    //Given
    RequestHandler requestHandler = mock(RequestHandler.class);
    String path = ENDPOINT_PATH_ELEMENT;
    Context context = mockContext(path);
    request.setUri(createRequestURI(HOSTNAME, path, postURIString));
    mockDnsAlias(HOSTNAME, "/");
    //When
    Handler httpHandler = getHttpHandler(requestHandler);
    httpHandler.handle(context, request).getOrThrowUninterruptibly();
    //Then
    ArgumentCaptor<Context> contextCaptor = ArgumentCaptor.forClass(Context.class);
    ArgumentCaptor<org.forgerock.json.resource.Request> requestCaptor = ArgumentCaptor.forClass(org.forgerock.json.resource.Request.class);
    collectCRUDPAQArguments(requestHandler, contextCaptor, requestCaptor);
    verifyRealmContext(contextCaptor.getValue(), "", "/", null);
    verifyUriRouterContext(contextCaptor.getValue(), "");
    verifyResolvedResourcePath(requestCaptor.getValue(), ENDPOINT_PATH_ELEMENT);
}
Also used : RootContext(org.forgerock.services.context.RootContext) UriRouterContext(org.forgerock.http.routing.UriRouterContext) Context(org.forgerock.services.context.Context) AttributesContext(org.forgerock.services.context.AttributesContext) RequestHandler(org.forgerock.json.resource.RequestHandler) CreateRequest(org.forgerock.json.resource.CreateRequest) ActionRequest(org.forgerock.json.resource.ActionRequest) ReadRequest(org.forgerock.json.resource.ReadRequest) DeleteRequest(org.forgerock.json.resource.DeleteRequest) UpdateRequest(org.forgerock.json.resource.UpdateRequest) PatchRequest(org.forgerock.json.resource.PatchRequest) Request(org.forgerock.http.protocol.Request) QueryRequest(org.forgerock.json.resource.QueryRequest) RequestHandler(org.forgerock.json.resource.RequestHandler) QueryResponseHandler(org.forgerock.openam.rest.query.QueryResponseHandler) Handler(org.forgerock.http.Handler) Test(org.testng.annotations.Test)

Aggregations

RequestHandler (org.forgerock.json.resource.RequestHandler)11 ReadRequest (org.forgerock.json.resource.ReadRequest)8 Context (org.forgerock.services.context.Context)8 Test (org.testng.annotations.Test)6 ActionRequest (org.forgerock.json.resource.ActionRequest)5 CreateRequest (org.forgerock.json.resource.CreateRequest)5 DeleteRequest (org.forgerock.json.resource.DeleteRequest)5 PatchRequest (org.forgerock.json.resource.PatchRequest)5 QueryRequest (org.forgerock.json.resource.QueryRequest)5 UpdateRequest (org.forgerock.json.resource.UpdateRequest)5 RootContext (org.forgerock.services.context.RootContext)4 AuthorizationResult (org.forgerock.authz.filter.api.AuthorizationResult)3 Handler (org.forgerock.http.Handler)3 Request (org.forgerock.http.protocol.Request)3 UriRouterContext (org.forgerock.http.routing.UriRouterContext)3 ResourceException (org.forgerock.json.resource.ResourceException)3 QueryResponseHandler (org.forgerock.openam.rest.query.QueryResponseHandler)3 AttributesContext (org.forgerock.services.context.AttributesContext)3 QueryResourceHandler (org.forgerock.json.resource.QueryResourceHandler)2 ResourceResponse (org.forgerock.json.resource.ResourceResponse)2