use of com.nike.riposte.server.http.RequestInfo in project riposte by Nike-Inc.
the class BasicAuthSecurityValidatorTest method validateFirstTokenIsNotBasic.
@Test(expected = Unauthorized401Exception.class)
public void validateFirstTokenIsNotBasic() {
RequestInfo mockRequest = mock(RequestInfo.class);
doReturn(mock(HttpHeaders.class)).when(mockRequest).getHeaders();
when(mockRequest.getHeaders().get("Authorization")).thenReturn(calcAuthHeader(USERNAME, PASSWORD).replaceFirst("Basic", "NotBasic"));
underTest.validateSecureRequestForEndpoint(mockRequest, mockEndpoint1);
}
use of com.nike.riposte.server.http.RequestInfo in project riposte by Nike-Inc.
the class BasicAuthSecurityValidatorTest method validateMissingPassword.
@Test(expected = Unauthorized401Exception.class)
public void validateMissingPassword() {
RequestInfo mockRequest = mock(RequestInfo.class);
doReturn(mock(HttpHeaders.class)).when(mockRequest).getHeaders();
when(mockRequest.getHeaders().get("Authorization")).thenReturn(calcAuthHeader(USERNAME, null));
underTest.validateSecureRequestForEndpoint(mockRequest, mockEndpoint1);
}
use of com.nike.riposte.server.http.RequestInfo in project riposte by Nike-Inc.
the class BasicAuthSecurityValidatorTest method validateMissingColonSeparator.
@Test(expected = Unauthorized401Exception.class)
public void validateMissingColonSeparator() {
RequestInfo mockRequest = mock(RequestInfo.class);
doReturn(mock(HttpHeaders.class)).when(mockRequest).getHeaders();
when(mockRequest.getHeaders().get("Authorization")).thenReturn("Basic " + Base64.encodeBase64String(USERNAME.getBytes()));
underTest.validateSecureRequestForEndpoint(mockRequest, mockEndpoint1);
}
use of com.nike.riposte.server.http.RequestInfo in project riposte by Nike-Inc.
the class BasicAuthSecurityValidatorTest method validateMissingUsername.
@Test(expected = Unauthorized401Exception.class)
public void validateMissingUsername() {
RequestInfo mockRequest = mock(RequestInfo.class);
doReturn(mock(HttpHeaders.class)).when(mockRequest).getHeaders();
when(mockRequest.getHeaders().get("Authorization")).thenReturn(calcAuthHeader(null, PASSWORD));
underTest.validateSecureRequestForEndpoint(mockRequest, mockEndpoint1);
}
use of com.nike.riposte.server.http.RequestInfo in project riposte by Nike-Inc.
the class AllowAllTheThingsCORSFilterTest method filterRequestLastChunkWithOptionalShortCircuitResponse_always_returns_null.
@DataProvider(value = { "OPTIONS", "GET", "POST", "PUT" }, splitBy = "\\|")
@Test
public void filterRequestLastChunkWithOptionalShortCircuitResponse_always_returns_null(String httpMethodString) {
// given
HttpMethod method = HttpMethod.valueOf(httpMethodString);
doReturn(method).when(requestMock).getMethod();
// when
Pair<RequestInfo<?>, Optional<ResponseInfo<?>>> result = filter.filterRequestLastChunkWithOptionalShortCircuitResponse(requestMock, ctxMock);
// then
assertThat(result).isNull();
}
Aggregations