Search in sources :

Example 11 with Request

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

the class RealmContextFilterTest method filterShouldConsumeRealmFromRequestWithUriRealmAlias.

@Test
public void filterShouldConsumeRealmFromRequestWithUriRealmAlias() throws Exception {
    //Given
    Context context = mockContext(SUB_REALM_ALIAS + "/" + ENDPOINT_PATH_ELEMENT);
    Request request = createRequest(HOSTNAME, SUB_REALM_ALIAS + "/" + ENDPOINT_PATH_ELEMENT);
    mockDnsAlias(HOSTNAME, "/");
    mockRealmAlias(SUB_REALM_ALIAS, "/" + SUB_REALM);
    //When
    filter.filter(context, request, handler);
    //Then
    ArgumentCaptor<Context> contextCaptor = ArgumentCaptor.forClass(Context.class);
    verify(handler).handle(contextCaptor.capture(), eq(request));
    verifyRealmContext(contextCaptor.getValue(), "", "/" + SUB_REALM, null);
    verifyUriRouterContext(contextCaptor.getValue(), SUB_REALM_ALIAS);
}
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) 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) Test(org.testng.annotations.Test)

Example 12 with Request

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

the class RealmContextFilterTest method filterShouldFailToConsumeRealmFromRequestWithDnsAliasAndUriRealmAlias.

@Test
public void filterShouldFailToConsumeRealmFromRequestWithDnsAliasAndUriRealmAlias() throws Exception {
    //Given
    Context context = mockContext(SUB_REALM_ALIAS + "/" + ENDPOINT_PATH_ELEMENT);
    Request request = createRequest(DNS_ALIAS_HOSTNAME, SUB_REALM_ALIAS + "/" + ENDPOINT_PATH_ELEMENT);
    mockDnsAlias(DNS_ALIAS_HOSTNAME, "/" + DNS_ALIS_SUB_REALM);
    mockRealmAlias("/" + DNS_ALIS_SUB_REALM + "/" + SUB_REALM_ALIAS, "/" + DNS_ALIS_SUB_REALM + "/" + SUB_REALM);
    mockInvalidRealmAlias(SUB_REALM_ALIAS);
    //When
    filter.filter(context, request, handler);
    //Then
    ArgumentCaptor<Context> contextCaptor = ArgumentCaptor.forClass(Context.class);
    verify(handler).handle(contextCaptor.capture(), eq(request));
    verifyUriRouterContextForInvalidRealm(contextCaptor.getValue());
}
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) 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) Test(org.testng.annotations.Test)

Example 13 with Request

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

the class RealmContextFilterTest method filterShouldConsumeRealmFromRequest.

@Test
public void filterShouldConsumeRealmFromRequest() throws Exception {
    //Given
    Context context = mockContext(ENDPOINT_PATH_ELEMENT);
    Request request = createRequest(HOSTNAME, ENDPOINT_PATH_ELEMENT);
    mockDnsAlias(HOSTNAME, "/");
    //When
    filter.filter(context, request, handler);
    //Then
    ArgumentCaptor<Context> contextCaptor = ArgumentCaptor.forClass(Context.class);
    verify(handler).handle(contextCaptor.capture(), eq(request));
    verifyRealmContext(contextCaptor.getValue(), "", "/", null);
    verifyUriRouterContext(contextCaptor.getValue(), "");
}
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) 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) Test(org.testng.annotations.Test)

Example 14 with Request

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

the class RealmContextFilterTest method filterShouldConsumeRealmFromRequestWithDnsAliasAndOverrideRealm.

@Test
public void filterShouldConsumeRealmFromRequestWithDnsAliasAndOverrideRealm() throws Exception {
    //Given
    Context context = mockContext(ENDPOINT_PATH_ELEMENT);
    Request request = createRequest(DNS_ALIAS_HOSTNAME, ENDPOINT_PATH_ELEMENT + "?realm=" + OVERRIDE_REALM);
    mockDnsAlias(DNS_ALIAS_HOSTNAME, "/" + DNS_ALIS_SUB_REALM);
    mockRealmAlias(OVERRIDE_REALM, OVERRIDE_REALM);
    //When
    filter.filter(context, request, handler);
    //Then
    ArgumentCaptor<Context> contextCaptor = ArgumentCaptor.forClass(Context.class);
    verify(handler).handle(contextCaptor.capture(), eq(request));
    verifyRealmContext(contextCaptor.getValue(), "/" + DNS_ALIS_SUB_REALM, "", OVERRIDE_REALM);
    verifyUriRouterContext(contextCaptor.getValue(), "");
}
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) 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) Test(org.testng.annotations.Test)

Example 15 with Request

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

the class RealmContextFilterTest method filterShouldFailToConsumeRealmFromRequestWithInvalidUriRealm.

@Test
public void filterShouldFailToConsumeRealmFromRequestWithInvalidUriRealm() throws Exception {
    //Given
    Context context = mockContext(INVALID_SUB_REALM + "/" + ENDPOINT_PATH_ELEMENT);
    Request request = createRequest(HOSTNAME, INVALID_SUB_REALM + "/" + ENDPOINT_PATH_ELEMENT);
    mockDnsAlias(HOSTNAME, "/");
    mockInvalidRealmAlias(INVALID_SUB_REALM);
    //When
    filter.filter(context, request, handler);
    //Then
    ArgumentCaptor<Context> contextCaptor = ArgumentCaptor.forClass(Context.class);
    verify(handler).handle(contextCaptor.capture(), eq(request));
    verifyRealmContext(contextCaptor.getValue(), "", "/", null);
    verifyUriRouterContextForInvalidRealm(contextCaptor.getValue());
}
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) 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) 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