use of io.restassured.builder.RequestSpecBuilder in project rest-assured by rest-assured.
the class AcceptHeaderITest method accept_headers_are_overwritten_from_request_spec_by_default.
@Test
public void accept_headers_are_overwritten_from_request_spec_by_default() {
RequestSpecification spec = new RequestSpecBuilder().setAccept(ContentType.JSON).build();
final MutableObject<List<String>> headers = new MutableObject<List<String>>();
RestAssured.given().accept("text/jux").spec(spec).body("{ \"message\" : \"hello world\"}").filter(new Filter() {
public Response filter(FilterableRequestSpecification requestSpec, FilterableResponseSpecification responseSpec, FilterContext ctx) {
headers.setValue(requestSpec.getHeaders().getValues("Accept"));
return ctx.next(requestSpec, responseSpec);
}
}).when().post("/jsonBodyAcceptHeader").then().body(equalTo("hello world"));
assertThat(headers.getValue(), contains("application/json, application/javascript, text/javascript, text/json"));
}
use of io.restassured.builder.RequestSpecBuilder in project rest-assured by rest-assured.
the class AuthenticationITest method formAuthenticationUsingSpringAuthConfDefinedInRequestSpec.
@Test
public void formAuthenticationUsingSpringAuthConfDefinedInRequestSpec() throws Exception {
final RequestSpecification specification = new RequestSpecBuilder().setAuth(form("John", "Doe", FormAuthConfig.springSecurity())).build();
given().spec(specification).expect().statusCode(200).body(equalTo("OK")).when().get("/formAuth");
}
use of io.restassured.builder.RequestSpecBuilder in project devonfw-testing by devonfw.
the class TokenValidTest method testNoneAlgorithmToken.
@Test
public void testNoneAlgorithmToken() {
Headers authHeaders = getSessionManager().getAuthHeaders(SessionEnum.WAITER);
String validToken = authHeaders.getValue(AUTH_HEADER);
String invalidToken = generateNoneAlgToken(validToken);
RequestSpecification rs = new RequestSpecBuilder().addHeader(AUTH_HEADER, invalidToken).setBaseUri(EnvironmentParam.SECURITY_SERVER_ORIGIN.getValue()).setBasePath(SubUrlEnum.ORDER_SEARCH.getValue()).addHeader("Content-Type", "application/json").setBody("{\"pagination\":{\"size\":8,\"page\":1,\"total\":1},\"sort\":[]}").build();
given(rs).when().post().then().statusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
}
Aggregations