Search in sources :

Example 1 with SessionFilter

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

the class JettySessionManagementTest method sessionsMaintainAttributesBetweenContexts.

@Test
public void sessionsMaintainAttributesBetweenContexts() {
    SessionFilter sessionFilter = new SessionFilter();
    logIntoBothContexts(sessionFilter);
    RestAssured.given().filter(sessionFilter).get(String.format("http://localhost:%s/context1/addSessionAttribute", port)).then().statusCode(is(SC_OK));
    RestAssured.given().filter(sessionFilter).get(String.format("http://localhost:%s/context2/checkSessionAttribute", port)).then().statusCode(is(SC_OK));
}
Also used : SessionFilter(io.restassured.filter.session.SessionFilter) Test(org.junit.Test)

Example 2 with SessionFilter

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

the class JettySessionManagementTest method sessionAreNotUsableWhenInvalidated.

@Test
public void sessionAreNotUsableWhenInvalidated() {
    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));
    RestAssured.given().filter(sessionFilter).get(String.format("http://localhost:%s/context1/invalidateSession", port)).then().statusCode(is(SC_OK));
    RestAssured.given().filter(sessionFilter).get(String.format("http://localhost:%s/context1/existingSession", port)).then().statusCode(is(SC_BAD_REQUEST));
}
Also used : SessionFilter(io.restassured.filter.session.SessionFilter) Test(org.junit.Test)

Example 3 with SessionFilter

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

the class JettySessionManagementTest method sessionsAreRefreshedAcrossContexts.

@Test
public void sessionsAreRefreshedAcrossContexts() throws InterruptedException {
    SessionFilter sessionFilter = new SessionFilter();
    logIntoBothContexts(sessionFilter);
    RestAssured.given().filter(sessionFilter).get(String.format("http://localhost:%s/context1/existingSession", port)).then().statusCode(is(SC_OK));
    Thread.sleep((SCAVENGE_INTERVAL_SECONDS + 1) * 1000);
    RestAssured.given().filter(sessionFilter).get(String.format("http://localhost:%s/context2/existingSession", port)).then().statusCode(is(SC_OK));
    Thread.sleep((SCAVENGE_INTERVAL_SECONDS + 1) * 1000);
    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 4 with SessionFilter

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

the class AuthenticationITest method sessionFilterRecordsAndProvidesTheSessionIdWhenSessionNameIsNotDefault.

@Test
public void sessionFilterRecordsAndProvidesTheSessionIdWhenSessionNameIsNotDefault() throws Exception {
    final SessionFilter sessionFilter = new SessionFilter();
    given().config(RestAssuredConfig.newConfig().sessionConfig(sessionConfig().sessionIdName("phpsessionid"))).auth().form("John", "Doe", new FormAuthConfig("/j_spring_security_check_phpsessionid", "j_username", "j_password")).filter(sessionFilter).expect().statusCode(200).body(equalTo("OK")).when().get("/formAuth");
    assertThat(sessionFilter.getSessionId(), equalTo("1234"));
}
Also used : SessionFilter(io.restassured.filter.session.SessionFilter) FormAuthConfig(io.restassured.authentication.FormAuthConfig) Test(org.junit.Test)

Example 5 with SessionFilter

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

the class AuthenticationITest method sessionFilterRecordsAndProvidesTheSessionId.

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

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