use of io.gravitee.common.http.HttpHeaders in project gravitee-gateway by gravitee-io.
the class JWTAuthenticationHandlerTest method shouldNotHandleRequest_noAuthorizationHeader.
@Test
public void shouldNotHandleRequest_noAuthorizationHeader() {
Request request = mock(Request.class);
when(request.headers()).thenReturn(new HttpHeaders());
boolean handle = authenticationHandler.canHandle(request);
Assert.assertFalse(handle);
}
use of io.gravitee.common.http.HttpHeaders in project gravitee-gateway by gravitee-io.
the class OAuth2AuthenticationHandlerTest method shouldHandleRequest_ignoreCaseAuthorizationHeader.
@Test
public void shouldHandleRequest_ignoreCaseAuthorizationHeader() {
HttpHeaders headers = new HttpHeaders();
Request request = mock(Request.class);
when(request.headers()).thenReturn(headers);
headers.add(HttpHeaders.AUTHORIZATION, "BeaRer xxx-xx-xxx-xx-xx");
boolean handle = authenticationHandler.canHandle(request);
Assert.assertTrue(handle);
}
use of io.gravitee.common.http.HttpHeaders in project gravitee-gateway by gravitee-io.
the class OAuth2AuthenticationHandlerTest method shouldNotHandleRequest_noBearerValue.
@Test
public void shouldNotHandleRequest_noBearerValue() {
HttpHeaders headers = new HttpHeaders();
Request request = mock(Request.class);
when(request.headers()).thenReturn(headers);
headers.add(HttpHeaders.AUTHORIZATION, OAuth2AuthenticationHandler.BEARER_AUTHORIZATION_TYPE + " ");
boolean handle = authenticationHandler.canHandle(request);
Assert.assertFalse(handle);
}
use of io.gravitee.common.http.HttpHeaders in project gravitee-gateway by gravitee-io.
the class OAuth2AuthenticationHandlerTest method shouldNotHandleRequest_noAuthorizationHeader.
@Test
public void shouldNotHandleRequest_noAuthorizationHeader() {
Request request = mock(Request.class);
when(request.headers()).thenReturn(new HttpHeaders());
boolean handle = authenticationHandler.canHandle(request);
Assert.assertFalse(handle);
}
use of io.gravitee.common.http.HttpHeaders in project gravitee-gateway by gravitee-io.
the class ReactorTest method processRequest_startedApi.
@Test
public void processRequest_startedApi() throws Exception {
Request request = mock(Request.class);
when(request.method()).thenReturn(HttpMethod.GET);
when(request.headers()).thenReturn(new HttpHeaders());
when(request.headers()).thenReturn(new HttpHeaders());
when(request.path()).thenReturn("/team");
when(request.metrics()).thenReturn(Metrics.on(System.currentTimeMillis()).build());
when(handlerResolver.resolve(any(Request.class))).thenReturn(new AbstractReactorHandler() {
@Override
public Reactable reactable() {
return new Reactable() {
@Override
public Object item() {
return null;
}
@Override
public String contextPath() {
return "";
}
@Override
public boolean enabled() {
return true;
}
@Override
public Set dependencies(Class type) {
return null;
}
@Override
public Map<String, Object> properties() {
return null;
}
};
}
@Override
protected void doHandle(Request request, Response response, Handler<Response> handler) {
Response proxyResponse = mock(Response.class);
when(proxyResponse.headers()).thenReturn(new HttpHeaders());
when(proxyResponse.status()).thenReturn(HttpStatusCode.OK_200);
handler.handle(proxyResponse);
}
});
final CountDownLatch lock = new CountDownLatch(1);
Response proxyResponse = mock(Response.class);
when(proxyResponse.headers()).thenReturn(new HttpHeaders());
reactor.route(request, proxyResponse, response -> {
Assert.assertEquals(HttpStatusCode.OK_200, response.status());
lock.countDown();
});
Assert.assertEquals(true, lock.await(10000, TimeUnit.MILLISECONDS));
}
Aggregations