Search in sources :

Example 31 with RequestSpecification

use of io.restassured.specification.RequestSpecification in project rest-assured by rest-assured.

the class SpecificationBuilderITest method supportsSpecifyingParametersInRequestSpecBuilder.

@Test
public void supportsSpecifyingParametersInRequestSpecBuilder() throws Exception {
    final RequestSpecification spec = new RequestSpecBuilder().addParameter("firstName", "John").addParam("lastName", "Doe").build();
    given().spec(spec).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)

Example 32 with RequestSpecification

use of io.restassured.specification.RequestSpecification in project rest-assured by rest-assured.

the class SpecificationBuilderITest method supportsMergingMultiValueFormParametersWhenUsingRequestSpecBuilder.

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

Example 33 with RequestSpecification

use of io.restassured.specification.RequestSpecification in project rest-assured by rest-assured.

the class SpecificationBuilderITest method supportsMergingMultiValueFormParametersUsingListWhenUsingRequestSpecBuilder.

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

Example 34 with RequestSpecification

use of io.restassured.specification.RequestSpecification in project rest-assured by rest-assured.

the class SpecificationBuilderITest method supportsSpecifyingQueryParametersInRequestSpecBuilderWhenGet.

@Test
public void supportsSpecifyingQueryParametersInRequestSpecBuilderWhenGet() throws Exception {
    final RequestSpecification spec = new RequestSpecBuilder().addQueryParameter("firstName", "John").addQueryParam("lastName", "Doe").build();
    given().spec(spec).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)

Example 35 with RequestSpecification

use of io.restassured.specification.RequestSpecification in project rest-assured by rest-assured.

the class SSLITest method allows_specifying_trust_store_statically_with_request_builder.

@Test
public void allows_specifying_trust_store_statically_with_request_builder() throws Exception {
    // Load the trust store
    InputStream trustStoreStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("jetty_localhost_client.jks");
    KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
    trustStore.load(trustStoreStream, "test1234".toCharArray());
    // Set the truststore on the global config
    RestAssured.config = RestAssured.config().sslConfig(SSLConfig.sslConfig().trustStore(trustStore).and().allowAllHostnames());
    final RequestSpecification spec = new RequestSpecBuilder().build();
    RestAssured.given().spec(spec).get("https://localhost:8443/hello").then().spec(helloWorldSpec());
}
Also used : InputStream(java.io.InputStream) RequestSpecification(io.restassured.specification.RequestSpecification) RequestSpecBuilder(io.restassured.builder.RequestSpecBuilder) KeyStore(java.security.KeyStore) Test(org.junit.Test)

Aggregations

RequestSpecification (io.restassured.specification.RequestSpecification)55 Test (org.junit.Test)47 RequestSpecBuilder (io.restassured.builder.RequestSpecBuilder)40 FilterableRequestSpecification (io.restassured.specification.FilterableRequestSpecification)7 SecurityTest (com.capgemini.ntc.security.SecurityTest)6 ResponseSpecification (io.restassured.specification.ResponseSpecification)5 Filter (io.restassured.filter.Filter)4 Parameters (junitparams.Parameters)4 FilterContext (io.restassured.filter.FilterContext)3 Header (io.restassured.http.Header)3 Response (io.restassured.response.Response)3 FilterableResponseSpecification (io.restassured.specification.FilterableResponseSpecification)3 PrintStream (java.io.PrintStream)3 StringWriter (java.io.StringWriter)3 WriterOutputStream (org.apache.commons.io.output.WriterOutputStream)3 RestDocumentationFilter (org.springframework.restdocs.restassured3.RestDocumentationFilter)3 Headers (io.restassured.http.Headers)2 List (java.util.List)2 MutableObject (org.apache.commons.lang3.mutable.MutableObject)2 JsonParseException (com.fasterxml.jackson.core.JsonParseException)1