Search in sources :

Example 1 with ServerCall

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");
}
Also used : HttpRequest(org.restlet.engine.adapter.HttpRequest) Series(org.restlet.util.Series) OAuth2Request(org.forgerock.oauth2.core.OAuth2Request) Header(org.restlet.data.Header) ServerCall(org.restlet.engine.adapter.ServerCall) AccessTokenVerifier(org.forgerock.oauth2.core.AccessTokenVerifier) Test(org.testng.annotations.Test)

Aggregations

AccessTokenVerifier (org.forgerock.oauth2.core.AccessTokenVerifier)1 OAuth2Request (org.forgerock.oauth2.core.OAuth2Request)1 Header (org.restlet.data.Header)1 HttpRequest (org.restlet.engine.adapter.HttpRequest)1 ServerCall (org.restlet.engine.adapter.ServerCall)1 Series (org.restlet.util.Series)1 Test (org.testng.annotations.Test)1