use of org.forgerock.json.resource.CreateRequest in project OpenAM by OpenRock.
the class RealmContextFilterTest method filterShouldConsumeRealmFromRequestWithDnsAlias.
@Test
public void filterShouldConsumeRealmFromRequestWithDnsAlias() throws Exception {
//Given
Context context = mockContext(ENDPOINT_PATH_ELEMENT);
Request request = createRequest(DNS_ALIAS_HOSTNAME, ENDPOINT_PATH_ELEMENT);
mockDnsAlias(DNS_ALIAS_HOSTNAME, "/" + DNS_ALIS_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, "", null);
verifyUriRouterContext(contextCaptor.getValue(), "");
}
use of org.forgerock.json.resource.CreateRequest 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);
}
use of org.forgerock.json.resource.CreateRequest 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());
}
use of org.forgerock.json.resource.CreateRequest 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(), "");
}
use of org.forgerock.json.resource.CreateRequest 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(), "");
}
Aggregations