Search in sources :

Example 51 with RequestSpecification

use of io.restassured.specification.RequestSpecification 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);
}
Also used : Headers(io.restassured.http.Headers) RequestSpecification(io.restassured.specification.RequestSpecification) RequestSpecBuilder(io.restassured.builder.RequestSpecBuilder) Test(org.junit.Test) SecurityTest(com.capgemini.ntc.security.SecurityTest)

Example 52 with RequestSpecification

use of io.restassured.specification.RequestSpecification in project devonfw-testing by devonfw.

the class CacheControlTest method testHeader.

@Test
@Parameters(method = "addParameters")
public void testHeader(SessionEnum session, EnvironmentParam origin, SubUrlEnum path, Method method, String contentType, String body, int statusCode) {
    RequestSpecification rs = getSessionManager().initBuilder(session).setBaseUri(origin.getValue()).setBasePath(path.getValue()).setBody(body).addHeader("content-type", contentType).build();
    given(rs).when().request(method).then().statusCode(statusCode).header("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate").header("Pragma", "no-cache").header("Expires", "0");
}
Also used : RequestSpecification(io.restassured.specification.RequestSpecification) Parameters(junitparams.Parameters) Test(org.junit.Test) SecurityTest(com.capgemini.ntc.security.SecurityTest)

Example 53 with RequestSpecification

use of io.restassured.specification.RequestSpecification in project devonfw-testing by devonfw.

the class XContentTypeOptionsTest method testHeader.

@Test
@Parameters(method = "addParameters")
public void testHeader(SessionEnum session, EnvironmentParam origin, SubUrlEnum path) {
    RequestSpecification rs = getSessionManager().initBuilder(session).setBaseUri(origin.getValue()).setBasePath(path.getValue()).build();
    given(rs).when().get().then().statusCode(200).header("X-Content-Type-Options", "nosniff");
}
Also used : RequestSpecification(io.restassured.specification.RequestSpecification) Parameters(junitparams.Parameters) Test(org.junit.Test) SecurityTest(com.capgemini.ntc.security.SecurityTest)

Example 54 with RequestSpecification

use of io.restassured.specification.RequestSpecification in project spring-cloud-netflix by spring-cloud.

the class AbstractDocumentationTests method document.

protected RequestSpecification document(String name, Object body) {
    RestDocumentationFilter filter = filter(name);
    RequestSpecification assured = RestAssured.given(spec(body, filter));
    return assured.filter(filter);
}
Also used : RestDocumentationFilter(org.springframework.restdocs.restassured3.RestDocumentationFilter) RequestSpecification(io.restassured.specification.RequestSpecification)

Example 55 with RequestSpecification

use of io.restassured.specification.RequestSpecification in project vertigo by KleeGroup.

the class WebServiceManagerTest method doPaginedSearch.

private String doPaginedSearch(final Map<String, Object> criteriaContact, final Integer top, final Integer skip, final String sortFieldName, final Boolean sortDesc, final String listServerToken, final int expectedSize, final String firstContactName, final String lastContactName, final boolean isAuto) {
    final RequestSpecification given = given().filter(loggedSessionFilter);
    final String wsUrl = isAuto ? "/test/_searchAutoPagined" : "/test/_searchQueryPagined";
    if (top != null) {
        given.queryParam("top", top);
    }
    if (skip != null) {
        given.queryParam("skip", skip);
    }
    if (sortFieldName != null) {
        given.queryParam("sortFieldName", sortFieldName);
    }
    if (sortDesc != null) {
        given.queryParam("sortDesc", sortDesc);
    }
    if (listServerToken != null) {
        given.queryParam("listServerToken", listServerToken);
    }
    ResponseSpecification responseSpecification = given.body(criteriaContact).expect().body("size()", Matchers.equalTo(expectedSize));
    if (expectedSize > 0) {
        responseSpecification = responseSpecification.body("get(0).name", Matchers.equalTo(firstContactName)).body("get(" + (expectedSize - 1) + ").name", Matchers.equalTo(lastContactName));
    }
    final String newListServerToken = responseSpecification.statusCode(HttpStatus.SC_OK).when().post(wsUrl).header("listServerToken");
    return newListServerToken;
}
Also used : ResponseSpecification(io.restassured.specification.ResponseSpecification) RequestSpecification(io.restassured.specification.RequestSpecification)

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