Search in sources :

Example 31 with RequestSpecBuilder

use of io.restassured.builder.RequestSpecBuilder in project rest-assured by rest-assured.

the class SpecificationBuilderITest method requestSpecBuilderSupportsSettingAuthentication.

@Test
public void requestSpecBuilderSupportsSettingAuthentication() throws Exception {
    final RequestSpecification spec = new RequestSpecBuilder().setAuth(basic("jetty", "jetty")).build();
    given().spec(spec).expect().statusCode(200).when().get("/secured/hello");
}
Also used : RequestSpecification(io.restassured.specification.RequestSpecification) RequestSpecBuilder(io.restassured.builder.RequestSpecBuilder) Test(org.junit.Test)

Example 32 with RequestSpecBuilder

use of io.restassured.builder.RequestSpecBuilder in project rest-assured by rest-assured.

the class SpecificationBuilderITest method supportsMergingMultiValueParametersWhenUsingRequestSpecBuilder.

@Test
public void supportsMergingMultiValueParametersWhenUsingRequestSpecBuilder() throws Exception {
    final RequestSpecification spec = new RequestSpecBuilder().addParam("list", "1", "2", "3").build();
    given().spec(spec).expect().body("list", equalTo("1,2,3")).when().get("/multiValueParam");
}
Also used : RequestSpecification(io.restassured.specification.RequestSpecification) RequestSpecBuilder(io.restassured.builder.RequestSpecBuilder) Test(org.junit.Test)

Example 33 with RequestSpecBuilder

use of io.restassured.builder.RequestSpecBuilder in project rest-assured by rest-assured.

the class SpecificationBuilderITest method supportsMergingMultiValueParametersUsingListWhenUsingRequestSpecBuilder.

@Test
public void supportsMergingMultiValueParametersUsingListWhenUsingRequestSpecBuilder() throws Exception {
    final RequestSpecification spec = new RequestSpecBuilder().addParam("list", asList("1", "2", "3")).build();
    given().spec(spec).expect().body("list", equalTo("1,2,3")).when().get("/multiValueParam");
}
Also used : RequestSpecification(io.restassured.specification.RequestSpecification) RequestSpecBuilder(io.restassured.builder.RequestSpecBuilder) Test(org.junit.Test)

Example 34 with RequestSpecBuilder

use of io.restassured.builder.RequestSpecBuilder in project rest-assured by rest-assured.

the class SpecificationBuilderITest method supportsSettingConfigWhenUsingRequestSpecBuilder.

@Test
public void supportsSettingConfigWhenUsingRequestSpecBuilder() throws Exception {
    final RequestSpecification spec = new RequestSpecBuilder().setConfig(newConfig().redirect(redirectConfig().followRedirects(false))).build();
    given().param("url", "/hello").spec(spec).expect().statusCode(302).header("Location", is("http://localhost:8080/hello")).when().get("/redirect");
}
Also used : RequestSpecification(io.restassured.specification.RequestSpecification) RequestSpecBuilder(io.restassured.builder.RequestSpecBuilder) Test(org.junit.Test)

Example 35 with RequestSpecBuilder

use of io.restassured.builder.RequestSpecBuilder in project rest-assured by rest-assured.

the class SpecificationBuilderITest method supportsMergesParametersWhenUsingRequestSpecBuilder.

@Test
public void supportsMergesParametersWhenUsingRequestSpecBuilder() throws Exception {
    final RequestSpecification spec = new RequestSpecBuilder().addParameter("firstName", "John").build();
    given().spec(spec).param("lastName", "Doe").expect().body("greeting.firstName", equalTo("John")).body("greeting.lastName", equalTo("Doe")).when().get("/greetXML");
}
Also used : RequestSpecification(io.restassured.specification.RequestSpecification) RequestSpecBuilder(io.restassured.builder.RequestSpecBuilder) Test(org.junit.Test)

Aggregations

RequestSpecBuilder (io.restassured.builder.RequestSpecBuilder)43 RequestSpecification (io.restassured.specification.RequestSpecification)40 Test (org.junit.Test)39 FilterableRequestSpecification (io.restassured.specification.FilterableRequestSpecification)7 Filter (io.restassured.filter.Filter)4 Header (io.restassured.http.Header)4 PrintStream (java.io.PrintStream)4 StringWriter (java.io.StringWriter)4 WriterOutputStream (org.apache.commons.io.output.WriterOutputStream)4 FilterContext (io.restassured.filter.FilterContext)3 Response (io.restassured.response.Response)3 FilterableResponseSpecification (io.restassured.specification.FilterableResponseSpecification)3 Headers (io.restassured.http.Headers)2 List (java.util.List)2 MutableObject (org.apache.commons.lang3.mutable.MutableObject)2 SecurityTest (com.capgemini.ntc.security.SecurityTest)1 ResponseBuilder (io.restassured.builder.ResponseBuilder)1 ResponseSpecBuilder (io.restassured.builder.ResponseSpecBuilder)1 LogConfig (io.restassured.config.LogConfig)1 Cookies (io.restassured.http.Cookies)1