use of org.forgerock.http.Handler in project OpenAM by OpenRock.
the class CrestProtocolEnforcementFilterTest method requestWithIncorrectProtocolMinorVersionShouldReturnBadRequestResponse.
@Test
public void requestWithIncorrectProtocolMinorVersionShouldReturnBadRequestResponse() throws IOException {
//Given
Context context = mock(Context.class);
Request request = new Request();
Handler next = mock(Handler.class);
request.getHeaders().put(AcceptApiVersionHeader.valueOf("protocol=1.1"));
//When
Response response = filter.filter(context, request, next).getOrThrowUninterruptibly();
//Then
assertThat(getUnsupportedMinorVersionExceptionJson(version(1, 1))).isEqualTo(response.getEntity().getJson());
assertThat(AcceptApiVersionHeader.valueOf(request).getProtocolVersion()).isEqualTo(version(1, 1));
verify(next, never()).handle(context, request);
}
use of org.forgerock.http.Handler 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.Handler in project OpenAM by OpenRock.
the class AbstractHttpAccessAuditFilterTest method mockHandler.
private Handler mockHandler(Context context, Request request, Status status) {
Handler handler = mock(Handler.class);
Promise<Response, NeverThrowsException> promise = newResultPromise(new Response(status));
given(handler.handle(context, request)).willReturn(promise);
return handler;
}
Aggregations