Search in sources :

Example 26 with RequestInfo

use of com.nike.riposte.server.http.RequestInfo in project riposte by Nike-Inc.

the class BasicAuthSecurityValidatorTest method validateHappyPath.

@Test
public void validateHappyPath() {
    RequestInfo mockRequest = mock(RequestInfo.class);
    doReturn(mock(HttpHeaders.class)).when(mockRequest).getHeaders();
    when(mockRequest.getHeaders().get("Authorization")).thenReturn(calcAuthHeader(USERNAME, PASSWORD));
    underTest.validateSecureRequestForEndpoint(mockRequest, mockEndpoint1);
}
Also used : HttpHeaders(io.netty.handler.codec.http.HttpHeaders) RequestInfo(com.nike.riposte.server.http.RequestInfo) Test(org.junit.Test)

Example 27 with RequestInfo

use of com.nike.riposte.server.http.RequestInfo in project riposte by Nike-Inc.

the class BasicAuthSecurityValidatorTest method validateNonBase64Encoded.

@Test(expected = Unauthorized401Exception.class)
public void validateNonBase64Encoded() {
    RequestInfo mockRequest = mock(RequestInfo.class);
    doReturn(mock(HttpHeaders.class)).when(mockRequest).getHeaders();
    when(mockRequest.getHeaders().get("Authorization")).thenReturn("Basic " + USERNAME + ":" + PASSWORD);
    underTest.validateSecureRequestForEndpoint(mockRequest, mockEndpoint1);
}
Also used : HttpHeaders(io.netty.handler.codec.http.HttpHeaders) RequestInfo(com.nike.riposte.server.http.RequestInfo) Test(org.junit.Test)

Example 28 with RequestInfo

use of com.nike.riposte.server.http.RequestInfo in project riposte by Nike-Inc.

the class BasicAuthSecurityValidatorTest method validateInvalidUsername.

@Test(expected = Unauthorized401Exception.class)
public void validateInvalidUsername() {
    RequestInfo mockRequest = mock(RequestInfo.class);
    doReturn(mock(HttpHeaders.class)).when(mockRequest).getHeaders();
    when(mockRequest.getHeaders().get("Authorization")).thenReturn(calcAuthHeader("blah", PASSWORD));
    underTest.validateSecureRequestForEndpoint(mockRequest, mockEndpoint1);
}
Also used : HttpHeaders(io.netty.handler.codec.http.HttpHeaders) RequestInfo(com.nike.riposte.server.http.RequestInfo) Test(org.junit.Test)

Example 29 with RequestInfo

use of com.nike.riposte.server.http.RequestInfo in project riposte by Nike-Inc.

the class BasicAuthSecurityValidatorTest method validateTooManySpaces.

@Test(expected = Unauthorized401Exception.class)
public void validateTooManySpaces() {
    RequestInfo mockRequest = mock(RequestInfo.class);
    doReturn(mock(HttpHeaders.class)).when(mockRequest).getHeaders();
    when(mockRequest.getHeaders().get("Authorization")).thenReturn(calcAuthHeader(USERNAME, PASSWORD) + " foo");
    underTest.validateSecureRequestForEndpoint(mockRequest, mockEndpoint1);
}
Also used : HttpHeaders(io.netty.handler.codec.http.HttpHeaders) RequestInfo(com.nike.riposte.server.http.RequestInfo) Test(org.junit.Test)

Example 30 with RequestInfo

use of com.nike.riposte.server.http.RequestInfo in project riposte by Nike-Inc.

the class BasicAuthSecurityValidatorTest method validateMissingBasicString.

@Test(expected = Unauthorized401Exception.class)
public void validateMissingBasicString() {
    RequestInfo mockRequest = mock(RequestInfo.class);
    doReturn(mock(HttpHeaders.class)).when(mockRequest).getHeaders();
    when(mockRequest.getHeaders().get("Authorization")).thenReturn("blah");
    underTest.validateSecureRequestForEndpoint(mockRequest, mockEndpoint1);
}
Also used : HttpHeaders(io.netty.handler.codec.http.HttpHeaders) RequestInfo(com.nike.riposte.server.http.RequestInfo) Test(org.junit.Test)

Aggregations

RequestInfo (com.nike.riposte.server.http.RequestInfo)39 Test (org.junit.Test)30 HttpHeaders (io.netty.handler.codec.http.HttpHeaders)13 HttpProcessingState (com.nike.riposte.server.http.HttpProcessingState)10 ResponseInfo (com.nike.riposte.server.http.ResponseInfo)9 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)6 PipelineContinuationBehavior (com.nike.riposte.server.handler.base.PipelineContinuationBehavior)6 DataProvider (com.tngtech.java.junit.dataprovider.DataProvider)6 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)6 Pair (com.nike.internal.util.Pair)5 RequestInfoForLogging (com.nike.backstopper.handler.RequestInfoForLogging)4 Endpoint (com.nike.riposte.server.http.Endpoint)4 HttpMethod (io.netty.handler.codec.http.HttpMethod)4 LastHttpContent (io.netty.handler.codec.http.LastHttpContent)4 Optional (java.util.Optional)4 Assertions.catchThrowable (org.assertj.core.api.Assertions.catchThrowable)4 LastOutboundMessageSendFullResponseInfo (com.nike.riposte.server.channelpipeline.message.LastOutboundMessageSendFullResponseInfo)3 ChannelAttributes (com.nike.riposte.server.channelpipeline.ChannelAttributes)2 BaseInboundHandlerWithTracingAndMdcSupport (com.nike.riposte.server.handler.base.BaseInboundHandlerWithTracingAndMdcSupport)2 ProxyRouterProcessingState (com.nike.riposte.server.http.ProxyRouterProcessingState)2