Search in sources :

Example 11 with RequestSpecBuilder

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

the class FilterITest method defaultFiltersDontAccumluate.

/**
 * Regression Test for 197
 */
@Test
public void defaultFiltersDontAccumluate() {
    CountingFilter myFilter = new CountingFilter();
    try {
        RestAssured.config = RestAssuredConfig.newConfig();
        RestAssured.filters(myFilter);
        RequestSpecification spec = new RequestSpecBuilder().build();
        given().get("/greetJSON?firstName=John&lastName=Doe");
        assertThat(myFilter.counter, equalTo(1));
        given().spec(spec).get("/greetJSON?firstName=Johan&lastName=Doe");
        assertThat(myFilter.counter, equalTo(2));
    } finally {
        RestAssured.reset();
    }
}
Also used : FilterableRequestSpecification(io.restassured.specification.FilterableRequestSpecification) RequestSpecification(io.restassured.specification.RequestSpecification) RequestSpecBuilder(io.restassured.builder.RequestSpecBuilder) Test(org.junit.Test)

Example 12 with RequestSpecBuilder

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

the class HeaderConfigITest method request_spec_overwrites_headers_when_configured_in_header_config.

@Test
public void request_spec_overwrites_headers_when_configured_in_header_config() {
    RequestSpecification specification = new RequestSpecBuilder().addHeader("header1", "value2").build();
    List<Header> list = given().config(RestAssuredConfig.config().headerConfig(HeaderConfig.headerConfig().overwriteHeadersWithName("header1"))).header("header1", "value1").spec(specification).when().get("/multiHeaderReflect").then().extract().headers().getList("header1");
    assertThat(list, hasSize(1));
    assertThat(list.get(0).getValue(), equalTo("value2"));
}
Also used : Header(io.restassured.http.Header) RequestSpecification(io.restassured.specification.RequestSpecification) RequestSpecBuilder(io.restassured.builder.RequestSpecBuilder) Test(org.junit.Test)

Example 13 with RequestSpecBuilder

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

the class HeaderConfigITest method request_spec_merges_headers_by_default.

@Test
public void request_spec_merges_headers_by_default() {
    RequestSpecification specification = new RequestSpecBuilder().addHeader("header1", "value2").build();
    List<Header> list = given().header("header1", "value1").spec(specification).when().get("/multiHeaderReflect").then().extract().headers().getList("header1");
    assertThat(list, hasSize(2));
}
Also used : Header(io.restassured.http.Header) RequestSpecification(io.restassured.specification.RequestSpecification) RequestSpecBuilder(io.restassured.builder.RequestSpecBuilder) Test(org.junit.Test)

Example 14 with RequestSpecBuilder

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

the class SSLITest method supports_overriding_truststore_in_request_specification.

@Test
public void supports_overriding_truststore_in_request_specification() {
    final RequestSpecification spec = new RequestSpecBuilder().setTrustStore("/jetty_localhost_client.jks", "wrong pw").build();
    RestAssured.given().spec(spec).trustStore("/jetty_localhost_client.jks", "test1234").expect().spec(helloWorldSpec()).when().get("https://localhost:8443/hello");
}
Also used : RequestSpecification(io.restassured.specification.RequestSpecification) RequestSpecBuilder(io.restassured.builder.RequestSpecBuilder) Test(org.junit.Test)

Example 15 with RequestSpecBuilder

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

the class SSLITest method supports_setting_truststore_in_request_specification.

@Test
public void supports_setting_truststore_in_request_specification() {
    final RequestSpecification spec = new RequestSpecBuilder().setTrustStore("/jetty_localhost_client.jks", "test1234").build();
    RestAssured.given().spec(spec).expect().spec(helloWorldSpec()).when().get("https://localhost:8443/hello");
}
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