use of io.restassured.http.Cookie in project rest-assured by rest-assured.
the class MockMvcRequestSpecificationMergingTest method cookies_are_not_overwritten_when_not_defined_in_specification.
@Test
public void cookies_are_not_overwritten_when_not_defined_in_specification() {
// Given
Cookie thisCookie = new Cookie.Builder("cookie2", "value2").build();
MockMvcRequestSpecification specToMerge = new MockMvcRequestSpecBuilder().addQueryParam("param1", "value1").build();
// When
MockMvcRequestSpecification spec = RestAssuredMockMvc.given().cookie(thisCookie).spec(specToMerge);
// Then
Assertions.assertThat(implOf(spec).getCookies()).containsOnly(thisCookie);
Assertions.assertThat(implOf(spec).getQueryParams()).containsOnly(entry("param1", "value1"));
}
use of io.restassured.http.Cookie in project rest-assured by rest-assured.
the class CookieITest method removesDoubleQuotesFromCookieWithExpiresDate.
@Test
public void removesDoubleQuotesFromCookieWithExpiresDate() throws Exception {
Cookies cookies = when().get("/cookieWithDoubleQuoteExpiresDate").then().extract().detailedCookies();
assertThat(cookies.asList(), hasSize(1));
Cookie cookie = cookies.get("name");
assertThat(cookie.getExpiryDate(), equalTo(DateUtils.parseDate("Sat, 02 May 2009 23:38:25 GMT")));
}
use of io.restassured.http.Cookie in project rest-assured by rest-assured.
the class CookieITest method setsExpiresPropertyToNullWhenCookieHasInvalidExpiresDate.
@Test
public void setsExpiresPropertyToNullWhenCookieHasInvalidExpiresDate() throws Exception {
Cookies cookies = when().get("/cookieWithInvalidExpiresDate").then().extract().detailedCookies();
assertThat(cookies.asList(), hasSize(1));
Cookie cookie = cookies.get("name");
assertThat(cookie.getExpiryDate(), nullValue());
}
use of io.restassured.http.Cookie in project tutorials by eugenp.
the class RestAssuredAdvancedLiveTest method whenUseCookieBuilder_thenOK.
@Test
public void whenUseCookieBuilder_thenOK() {
Cookie myCookie = new Cookie.Builder("session_id", "1234").setSecured(true).setComment("session id cookie").build();
given().cookie(myCookie).when().get("/users/eugenp").then().statusCode(200);
}
Aggregations