Search in sources :

Example 1 with Request

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

the class RestRouterIT method shouldReadChfEndpointOnRootHandler.

@Test
public void shouldReadChfEndpointOnRootHandler() throws Exception {
    //Given
    Context context = mockContext();
    Request request = newRequest("GET", "/json/dashboard");
    //When
    handler.handle(context, request);
    //Then
    verify(dashboardResource).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 2 with Request

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

the class RestRouterIT method shouldReadCrestEndpointOnRealmHandlerWithSubRealm.

@Test
public void shouldReadCrestEndpointOnRealmHandlerWithSubRealm() throws Exception {
    //Given
    Context context = mockRequiredContexts();
    Request request = newRequest("GET", "/json/subrealm/users/demo");
    auditingOff();
    mockRealm("/subrealm");
    //When
    handler.handle(context, request);
    //Then
    ArgumentCaptor<Context> contextCaptor = ArgumentCaptor.forClass(Context.class);
    verify(usersResource).readInstance(contextCaptor.capture(), eq("demo"), any(ReadRequest.class));
    assertThat(contextCaptor.getValue().asContext(RealmContext.class).getResolvedRealm()).isEqualTo("/subrealm");
}
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) ReadRequest(org.forgerock.json.resource.ReadRequest) Test(org.testng.annotations.Test)

Example 3 with Request

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

the class RestRouterIT method shouldReadChfEndpointOnRealmHandlerWithSubRealm.

@Test
public void shouldReadChfEndpointOnRealmHandlerWithSubRealm() throws Exception {
    //Given
    Context context = mockContext();
    Request request = newRequest("GET", "/json/subrealm/authenticate");
    mockRealm("/subrealm");
    //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 4 with Request

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

the class RestRouterIT method shouldReadCrestEndpointOnRootHandler.

@Test
public void shouldReadCrestEndpointOnRootHandler() throws Exception {
    //Given
    Context context = mockRequiredContexts();
    Request request = newRequest("GET", "/json/config");
    auditingOff();
    //When
    handler.handle(context, request);
    //Then
    verify(configResource).readInstance(any(Context.class), any(ReadRequest.class));
}
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) ReadRequest(org.forgerock.json.resource.ReadRequest) Test(org.testng.annotations.Test)

Example 5 with Request

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

the class RestRouterIT method shouldReadCrestEndpointOnRealmHandlerWithRootRealm.

@Test
public void shouldReadCrestEndpointOnRealmHandlerWithRootRealm() throws Exception {
    //Given
    Context context = mockRequiredContexts();
    Request request = newRequest("GET", "/json/users/demo");
    auditingOff();
    //When
    handler.handle(context, request);
    //Then
    ArgumentCaptor<Context> contextCaptor = ArgumentCaptor.forClass(Context.class);
    verify(usersResource).readInstance(contextCaptor.capture(), eq("demo"), any(ReadRequest.class));
    assertThat(contextCaptor.getValue().asContext(RealmContext.class).getResolvedRealm()).isEqualTo("/");
}
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) ReadRequest(org.forgerock.json.resource.ReadRequest) 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