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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations