Search in sources :

Example 11 with HttpHeaders

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

the class OAuth2AuthenticationHandlerTest 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 12 with HttpHeaders

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

the class TransactionHandlerTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    when(request.headers()).thenReturn(new HttpHeaders());
    when(response.headers()).thenReturn(new HttpHeaders());
    when(request.metrics()).thenReturn(Metrics.on(System.currentTimeMillis()).build());
}
Also used : HttpHeaders(io.gravitee.common.http.HttpHeaders) Before(org.junit.Before)

Example 13 with HttpHeaders

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

the class ApiKeyAuthenticationHandlerTest method shouldNotHandleRequest.

@Test
public void shouldNotHandleRequest() {
    Request request = mock(Request.class);
    when(request.headers()).thenReturn(new HttpHeaders());
    MultiValueMap<String, String> parameters = mock(MultiValueMap.class);
    when(request.parameters()).thenReturn(parameters);
    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 14 with HttpHeaders

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

the class VertxProxyConnection method writeHeaders.

private void writeHeaders() {
    HttpHeaders headers = proxyRequest.headers();
    // Copy headers to upstream
    headers.forEach(httpClientRequest::putHeader);
    // Check chunk flag on the request if there are some content to push and if transfer_encoding is set
    // with chunk value
    long contentLength = headers.contentLength();
    if (contentLength > 0 || headers.contentType() != null) {
        if (contentLength == -1) {
            // No content-length... so let's go for chunked transfer-encoding
            httpClientRequest.setChunked(true);
        }
    }
    headersWritten = true;
}
Also used : HttpHeaders(io.gravitee.common.http.HttpHeaders)

Example 15 with HttpHeaders

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

the class JWTAuthenticationHandlerTest method shouldNotHandleRequest_noBearerAuthorizationHeader.

@Test
public void shouldNotHandleRequest_noBearerAuthorizationHeader() {
    HttpHeaders headers = new HttpHeaders();
    Request request = mock(Request.class);
    when(request.headers()).thenReturn(headers);
    headers.add(HttpHeaders.AUTHORIZATION, "Basic xxx-xx-xxx-xx-xx");
    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)

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