Search in sources :

Example 46 with Request

use of org.forgerock.http.protocol.Request in project OpenAM by OpenRock.

the class RestRouterIT method shouldReadChfEndpointOnRealmHandlerWithRootRealm.

@Test
public void shouldReadChfEndpointOnRealmHandlerWithRootRealm() throws Exception {
    //Given
    Context context = mockRequiredContexts();
    Request request = newRequest("GET", "/json/authenticate");
    //When
    handler.handle(context, request);
    //Then
    verify(authenticateResource).get();
}
Also used : RootContext(org.forgerock.services.context.RootContext) RequestAuditContext(org.forgerock.services.context.RequestAuditContext) HttpContext(org.forgerock.json.resource.http.HttpContext) SessionContext(org.forgerock.http.session.SessionContext) SSOTokenContext(org.forgerock.openam.rest.resource.SSOTokenContext) AttributesContext(org.forgerock.services.context.AttributesContext) SecurityContext(org.forgerock.services.context.SecurityContext) Context(org.forgerock.services.context.Context) Request(org.forgerock.http.protocol.Request) ReadRequest(org.forgerock.json.resource.ReadRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) Test(org.testng.annotations.Test)

Example 47 with Request

use of org.forgerock.http.protocol.Request in project OpenAM by OpenRock.

the class RestRouterIT method newRequest.

private Request newRequest(String method, String uri) throws URISyntaxException {
    Request request = new Request().setMethod(method).setUri(URI.create(uri));
    request.getUri().setHost("HOSTNAME");
    return request;
}
Also used : Request(org.forgerock.http.protocol.Request) ReadRequest(org.forgerock.json.resource.ReadRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest)

Example 48 with Request

use of org.forgerock.http.protocol.Request in project OpenAM by OpenRock.

the class RestRouterIT method shouldNotBePossibleToReachInternalResourceViaChf.

@Test
public void shouldNotBePossibleToReachInternalResourceViaChf() throws Exception {
    // Given
    Context context = mockContext();
    Request request = newRequest("GET", "/json/internal");
    // When
    Promise<Response, NeverThrowsException> promise = handler.handle(context, request);
    // Then
    Response response = promise.get();
    assertThat(response.getStatus()).isEqualTo(Status.NOT_FOUND);
    verifyZeroInteractions(internalResource);
}
Also used : RootContext(org.forgerock.services.context.RootContext) RequestAuditContext(org.forgerock.services.context.RequestAuditContext) HttpContext(org.forgerock.json.resource.http.HttpContext) SessionContext(org.forgerock.http.session.SessionContext) SSOTokenContext(org.forgerock.openam.rest.resource.SSOTokenContext) AttributesContext(org.forgerock.services.context.AttributesContext) SecurityContext(org.forgerock.services.context.SecurityContext) Context(org.forgerock.services.context.Context) Responses.newResourceResponse(org.forgerock.json.resource.Responses.newResourceResponse) Response(org.forgerock.http.protocol.Response) ResourceResponse(org.forgerock.json.resource.ResourceResponse) NeverThrowsException(org.forgerock.util.promise.NeverThrowsException) Request(org.forgerock.http.protocol.Request) ReadRequest(org.forgerock.json.resource.ReadRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) Test(org.testng.annotations.Test)

Example 49 with Request

use of org.forgerock.http.protocol.Request in project OpenAM by OpenRock.

the class HttpRouterProviderTest method shouldAddRoutesToRouter.

@Test(dataProvider = "routeRequestsData")
public void shouldAddRoutesToRouter(String requestUri, Handler exceptedHandler) {
    //Given
    Context context = new RootContext();
    Request request = new Request().setUri(URI.create(requestUri));
    Router router = httpRouterProvider.get();
    //When
    router.handle(context, request);
    //Then
    verify(exceptedHandler).handle(any(Context.class), eq(request));
}
Also used : RootContext(org.forgerock.services.context.RootContext) Context(org.forgerock.services.context.Context) RootContext(org.forgerock.services.context.RootContext) Request(org.forgerock.http.protocol.Request) Router(org.forgerock.http.routing.Router) Test(org.testng.annotations.Test)

Example 50 with Request

use of org.forgerock.http.protocol.Request in project OpenAM by OpenRock.

the class AbstractHttpAccessAuditFilterTest method shouldGetUserIdForAccessAttemptIfNotSet.

@Test
public void shouldGetUserIdForAccessAttemptIfNotSet() {
    //Given
    Request request = new Request();
    AuditRequestContext.putProperty(USER_ID, null);
    //When
    String userId = auditFilter.getUserIdForAccessAttempt(request);
    //Then
    assertThat(userId).isEmpty();
}
Also used : Request(org.forgerock.http.protocol.Request) Test(org.testng.annotations.Test)

Aggregations

Request (org.forgerock.http.protocol.Request)51 Test (org.testng.annotations.Test)45 Context (org.forgerock.services.context.Context)36 RootContext (org.forgerock.services.context.RootContext)33 AttributesContext (org.forgerock.services.context.AttributesContext)30 ReadRequest (org.forgerock.json.resource.ReadRequest)29 ActionRequest (org.forgerock.json.resource.ActionRequest)21 CreateRequest (org.forgerock.json.resource.CreateRequest)21 DeleteRequest (org.forgerock.json.resource.DeleteRequest)21 PatchRequest (org.forgerock.json.resource.PatchRequest)21 QueryRequest (org.forgerock.json.resource.QueryRequest)21 UpdateRequest (org.forgerock.json.resource.UpdateRequest)21 UriRouterContext (org.forgerock.http.routing.UriRouterContext)19 Response (org.forgerock.http.protocol.Response)14 SessionContext (org.forgerock.http.session.SessionContext)11 Handler (org.forgerock.http.Handler)10 RequestAuditContext (org.forgerock.services.context.RequestAuditContext)9 HttpServletRequest (javax.servlet.http.HttpServletRequest)8 HttpContext (org.forgerock.json.resource.http.HttpContext)7 SSOTokenContext (org.forgerock.openam.rest.resource.SSOTokenContext)7