use of org.forgerock.http.protocol.Request in project OpenAM by OpenRock.
the class RealmContextFilterTest method filterShouldConsumeRealmFromRequestWithUriRealmAliasAndOverrideRealm.
@Test
public void filterShouldConsumeRealmFromRequestWithUriRealmAliasAndOverrideRealm() throws Exception {
//Given
Context context = mockContext(SUB_REALM_ALIAS + "/" + ENDPOINT_PATH_ELEMENT);
Request request = createRequest(HOSTNAME, SUB_REALM_ALIAS + "/" + ENDPOINT_PATH_ELEMENT + "?realm=" + OVERRIDE_REALM);
mockDnsAlias(HOSTNAME, "/");
mockRealmAlias(SUB_REALM_ALIAS, "/" + 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(), "", "/" + SUB_REALM, OVERRIDE_REALM);
verifyUriRouterContext(contextCaptor.getValue(), SUB_REALM_ALIAS);
}
use of org.forgerock.http.protocol.Request in project OpenAM by OpenRock.
the class RealmContextFilterTest method getUpdateRequest.
private Request getUpdateRequest() {
Request request = newJsonHttpRequest("PUT");
request.getHeaders().put("If-Match", "*");
request.setEntity(new String("{}"));
return withContentType(request);
}
use of org.forgerock.http.protocol.Request in project OpenAM by OpenRock.
the class RealmContextFilterTest method filterShouldConsumeRealmFromRequestWithDnsAliasAndUriRealm.
@Test
public void filterShouldConsumeRealmFromRequestWithDnsAliasAndUriRealm() throws Exception {
//Given
Context context = mockContext(SUB_REALM + "/" + ENDPOINT_PATH_ELEMENT);
Request request = createRequest(DNS_ALIAS_HOSTNAME, SUB_REALM + "/" + ENDPOINT_PATH_ELEMENT);
mockDnsAlias(DNS_ALIAS_HOSTNAME, "/" + DNS_ALIS_SUB_REALM);
mockRealmAlias("/" + DNS_ALIS_SUB_REALM + "/" + SUB_REALM, "/" + DNS_ALIS_SUB_REALM + "/" + 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(), "/" + DNS_ALIS_SUB_REALM, "/" + SUB_REALM, null);
verifyUriRouterContext(contextCaptor.getValue(), SUB_REALM);
}
use of org.forgerock.http.protocol.Request 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);
}
use of org.forgerock.http.protocol.Request in project OpenAM by OpenRock.
the class RealmContextFilterTest method filterShouldConsumeRealmFromRequestWithOverrideRealmAlias.
@Test
public void filterShouldConsumeRealmFromRequestWithOverrideRealmAlias() throws Exception {
//Given
Context context = mockContext(ENDPOINT_PATH_ELEMENT);
Request request = createRequest(HOSTNAME, ENDPOINT_PATH_ELEMENT + "?realm=" + OVERRIDE_REALM_ALIAS);
mockDnsAlias(HOSTNAME, "/");
mockRealmAlias(OVERRIDE_REALM_ALIAS, 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(), "/", "", OVERRIDE_REALM);
verifyUriRouterContext(contextCaptor.getValue(), "");
}
Aggregations