Search in sources :

Example 6 with SessionFilter

use of io.restassured.filter.session.SessionFilter in project rest-assured by rest-assured.

the class AuthenticationITest method reusingSameSessionFilterInDifferentRequestsAppliesTheSessionIdToTheNewRequest.

@Test
public void reusingSameSessionFilterInDifferentRequestsAppliesTheSessionIdToTheNewRequest() throws Exception {
    final SessionFilter sessionFilter = new SessionFilter();
    given().auth().form("John", "Doe").filter(sessionFilter).expect().statusCode(200).body(equalTo("OK")).when().get("/formAuth");
    given().filter(sessionFilter).expect().statusCode(200).body(equalTo("OK")).when().get("/formAuth");
}
Also used : SessionFilter(io.restassured.filter.session.SessionFilter) Test(org.junit.Test)

Example 7 with SessionFilter

use of io.restassured.filter.session.SessionFilter in project ddf by codice.

the class JettySessionManagementTest method sessionsAreReusable.

@Test
public void sessionsAreReusable() {
    SessionFilter sessionFilter = new SessionFilter();
    String sessionId = RestAssured.given().filter(sessionFilter).get(String.format("http://localhost:%s/context1/newSession", port)).then().statusCode(is(SC_OK)).extract().sessionId();
    assertThat(sessionId, is(not(nullValue())));
    RestAssured.given().filter(sessionFilter).get(String.format("http://localhost:%s/context1/existingSession", port)).then().statusCode(is(SC_OK));
}
Also used : SessionFilter(io.restassured.filter.session.SessionFilter) Test(org.junit.Test)

Example 8 with SessionFilter

use of io.restassured.filter.session.SessionFilter in project dhis2-core by dhis2.

the class ConfigurationExtension method defaultRequestSpecification.

private RequestSpecification defaultRequestSpecification() {
    RequestSpecBuilder requestSpecification = new RequestSpecBuilder();
    requestSpecification.addFilter(new CookieFilter());
    requestSpecification.addFilter(new SessionFilter());
    requestSpecification.addFilter(new AuthFilter());
    requestSpecification.setContentType(ContentType.JSON);
    return requestSpecification.build();
}
Also used : CookieFilter(io.restassured.filter.cookie.CookieFilter) SessionFilter(io.restassured.filter.session.SessionFilter) RequestSpecBuilder(io.restassured.builder.RequestSpecBuilder)

Aggregations

SessionFilter (io.restassured.filter.session.SessionFilter)8 Test (org.junit.Test)7 FormAuthConfig (io.restassured.authentication.FormAuthConfig)1 RequestSpecBuilder (io.restassured.builder.RequestSpecBuilder)1 CookieFilter (io.restassured.filter.cookie.CookieFilter)1