Search in sources :

Example 6 with HttpHeaders

use of io.gravitee.common.http.HttpHeaders in project gravitee-gateway by gravitee-io.

the class JWTAuthenticationHandlerTest method shouldHandleRequest_validAuthorizationHeader.

@Test
public void shouldHandleRequest_validAuthorizationHeader() {
    HttpHeaders headers = new HttpHeaders();
    Request request = mock(Request.class);
    when(request.headers()).thenReturn(headers);
    headers.add(HttpHeaders.AUTHORIZATION, JWTAuthenticationHandler.BEARER_AUTHORIZATION_TYPE + " xxx-xx-xxx-xx-xx");
    boolean handle = authenticationHandler.canHandle(request);
    Assert.assertTrue(handle);
}
Also used : HttpHeaders(io.gravitee.common.http.HttpHeaders) Request(io.gravitee.gateway.api.Request) Test(org.junit.Test)

Example 7 with HttpHeaders

use of io.gravitee.common.http.HttpHeaders in project gravitee-gateway by gravitee-io.

the class JWTAuthenticationHandlerTest 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, JWTAuthenticationHandler.BEARER_AUTHORIZATION_TYPE + " ");
    boolean handle = authenticationHandler.canHandle(request);
    Assert.assertFalse(handle);
}
Also used : HttpHeaders(io.gravitee.common.http.HttpHeaders) Request(io.gravitee.gateway.api.Request) Test(org.junit.Test)

Example 8 with HttpHeaders

use of io.gravitee.common.http.HttpHeaders in project gravitee-gateway by gravitee-io.

the class JWTAuthenticationHandlerTest method shouldNotHandleRequest_invalidAuthorizationHeader.

@Test
public void shouldNotHandleRequest_invalidAuthorizationHeader() {
    HttpHeaders headers = new HttpHeaders();
    Request request = mock(Request.class);
    when(request.headers()).thenReturn(headers);
    headers.add(HttpHeaders.AUTHORIZATION, "");
    boolean handle = authenticationHandler.canHandle(request);
    Assert.assertFalse(handle);
}
Also used : HttpHeaders(io.gravitee.common.http.HttpHeaders) Request(io.gravitee.gateway.api.Request) Test(org.junit.Test)

Example 9 with HttpHeaders

use of io.gravitee.common.http.HttpHeaders in project gravitee-gateway by gravitee-io.

the class KeylessAuthenticationHandlerTest method shouldHandleRequest.

@Test
public void shouldHandleRequest() {
    Request request = mock(Request.class);
    when(request.headers()).thenReturn(new HttpHeaders());
    boolean handle = authenticationHandler.canHandle(request);
    Assert.assertTrue(handle);
}
Also used : HttpHeaders(io.gravitee.common.http.HttpHeaders) Request(io.gravitee.gateway.api.Request) Test(org.junit.Test)

Example 10 with HttpHeaders

use of io.gravitee.common.http.HttpHeaders in project gravitee-gateway by gravitee-io.

the class OAuth2AuthenticationHandlerTest method shouldHandleRequest_validAuthorizationHeader.

@Test
public void shouldHandleRequest_validAuthorizationHeader() {
    HttpHeaders headers = new HttpHeaders();
    Request request = mock(Request.class);
    when(request.headers()).thenReturn(headers);
    headers.add(HttpHeaders.AUTHORIZATION, OAuth2AuthenticationHandler.BEARER_AUTHORIZATION_TYPE + " xxx-xx-xxx-xx-xx");
    boolean handle = authenticationHandler.canHandle(request);
    Assert.assertTrue(handle);
}
Also used : HttpHeaders(io.gravitee.common.http.HttpHeaders) Request(io.gravitee.gateway.api.Request) Test(org.junit.Test)

Aggregations

HttpHeaders (io.gravitee.common.http.HttpHeaders)24 Test (org.junit.Test)20 Request (io.gravitee.gateway.api.Request)17 LinkedMultiValueMap (io.gravitee.common.util.LinkedMultiValueMap)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 HttpStatusCode (io.gravitee.common.http.HttpStatusCode)1 MultiValueMap (io.gravitee.common.util.MultiValueMap)1 HttpClientSslOptions (io.gravitee.definition.model.HttpClientSslOptions)1 HttpProxy (io.gravitee.definition.model.HttpProxy)1 HttpEndpoint (io.gravitee.definition.model.endpoint.HttpEndpoint)1 Response (io.gravitee.gateway.api.Response)1 AbstractReactorHandler (io.gravitee.gateway.reactor.handler.AbstractReactorHandler)1 EndpointRule (io.gravitee.gateway.services.healthcheck.EndpointRule)1 EndpointStatusDecorator (io.gravitee.gateway.services.healthcheck.EndpointStatusDecorator)1 EvaluationException (io.gravitee.gateway.services.healthcheck.eval.EvaluationException)1 AssertionEvaluation (io.gravitee.gateway.services.healthcheck.eval.assertion.AssertionEvaluation)1 EvaluableHttpResponse (io.gravitee.gateway.services.healthcheck.http.el.EvaluableHttpResponse)1 Request (io.gravitee.reporter.api.common.Request)1 Response (io.gravitee.reporter.api.common.Response)1