use of io.restassured.authentication.AuthenticationScheme in project rest-assured by rest-assured.
the class OAuthITest method oauth2_works_with_non_preemptive_header_signing.
@Test
public void oauth2_works_with_non_preemptive_header_signing() {
final String accessToken = "accessToken";
given().auth().oauth2(accessToken).filter(new Filter() {
public Response filter(FilterableRequestSpecification requestSpec, FilterableResponseSpecification responseSpec, FilterContext ctx) {
AuthenticationScheme scheme = requestSpec.getAuthenticationScheme();
assertThat(scheme, instanceOf(PreemptiveOAuth2HeaderScheme.class));
assertThat(((PreemptiveOAuth2HeaderScheme) scheme).getAccessToken(), equalTo(accessToken));
return new ResponseBuilder().setBody("ok").setStatusCode(200).build();
}
}).when().get("/somewhere").then().statusCode(200);
}
Aggregations