use of org.restlet.engine.adapter.ServerCall in project OpenAM by OpenRock.
the class RestletHeaderAccessTokenVerifierTest method shouldCheckHttpHeader.
@Test
public void shouldCheckHttpHeader() throws Exception {
// Given
ServerCall serverCall = mock(ServerCall.class);
HttpRequest request = mock(HttpRequest.class);
OAuth2Request req = new RestletOAuth2Request(null, request);
when(request.getHttpCall()).thenReturn(serverCall);
Series<Header> requestHeaders = new Series<Header>(Header.class);
requestHeaders.add(new Header(HeaderConstants.HEADER_AUTHORIZATION, "Bearer freddy"));
when(request.getHttpCall().getRequestHeaders()).thenReturn(requestHeaders);
// When
AccessTokenVerifier.TokenState result = verifier.verify(req);
// Then
assertThat(result.isValid()).isFalse();
verify(tokenStore).readAccessToken(req, "freddy");
}
Aggregations