use of io.restassured.http.Cookie in project knox by apache.
the class GatewayBasicFuncTest method testBasicJsonUseCase.
@Test(timeout = TestUtils.MEDIUM_TIMEOUT)
public void testBasicJsonUseCase() throws IOException {
LOG_ENTER();
String root = "/tmp/GatewayBasicFuncTest/testBasicJsonUseCase";
String username = "hdfs";
String password = "hdfs-password";
/* Create a directory.
curl -i -X PUT "http://<HOST>:<PORT>/<PATH>?op=MKDIRS[&permission=<OCTAL>]"
The client receives a respond with a boolean JSON object:
HTTP/1.1 HttpStatus.SC_OK OK
Content-Type: application/json
Transfer-Encoding: chunked
{"boolean": true}
*/
driver.getMock("WEBHDFS").expect().method("PUT").pathInfo("/v1" + root + "/dir").queryParam("op", "MKDIRS").queryParam("user.name", username).respond().status(HttpStatus.SC_OK).content(driver.getResourceBytes("webhdfs-success.json")).contentType("application/json");
Cookie cookie = given().auth().preemptive().basic(username, password).header("X-XSRF-Header", "jksdhfkhdsf").queryParam("op", "MKDIRS").then().statusCode(HttpStatus.SC_OK).contentType("application/json").body("boolean", is(true)).when().put(driver.getUrl("WEBHDFS") + "/v1" + root + "/dir").getDetailedCookie("JSESSIONID");
assertThat(cookie.isSecured(), is(true));
assertThat(cookie.isHttpOnly(), is(true));
assertThat(cookie.getPath(), is("/gateway/cluster"));
assertThat(cookie.getValue().length(), greaterThan(16));
driver.assertComplete();
LOG_EXIT();
}
use of io.restassured.http.Cookie in project rest-assured by rest-assured.
the class CookieITest method getDetailedCookieWorks.
@Test
public void getDetailedCookieWorks() throws Exception {
final Response response = get("/html_with_cookie");
final Cookie detailedCookieJsessionId = response.getDetailedCookie("JSESSIONID");
assertThat(detailedCookieJsessionId, notNullValue());
assertThat(detailedCookieJsessionId.getPath(), equalTo("/"));
assertThat(detailedCookieJsessionId.getValue(), equalTo("B3134D534F40968A3805968207273EF5"));
}
use of io.restassured.http.Cookie in project rest-assured by rest-assured.
the class CookieITest method canGetCookieDetails.
@Test
public void canGetCookieDetails() throws Exception {
final List<Cookie> cookies = get("/multiCookie").detailedCookies().getList("cookie1");
assertThat(cookies.size(), is(2));
final Cookie firstCookie = cookies.get(0);
assertThat(firstCookie.getValue(), equalTo("cookieValue1"));
assertThat(firstCookie.getDomain(), equalTo("localhost"));
final Cookie secondCookie = cookies.get(1);
assertThat(secondCookie.getValue(), equalTo("cookieValue2"));
assertThat(secondCookie.getDomain(), equalTo("localhost"));
assertThat(secondCookie.getPath(), equalTo("/"));
assertThat(secondCookie.getMaxAge(), is(1234567));
assertThat(secondCookie.isSecured(), is(true));
assertThat(secondCookie.getVersion(), is(1));
}
use of io.restassured.http.Cookie in project rest-assured by rest-assured.
the class CookieITest method parsesValidExpiresDateCorrectly.
@Test
public void parsesValidExpiresDateCorrectly() throws Exception {
Cookies cookies = when().get("/cookieWithValidExpiresDate").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 detailedCookieWorks.
@Test
public void detailedCookieWorks() throws Exception {
final Response response = get("/html_with_cookie");
final Cookie detailedCookieJsessionId = response.detailedCookie("JSESSIONID");
assertThat(detailedCookieJsessionId, notNullValue());
assertThat(detailedCookieJsessionId.getPath(), equalTo("/"));
assertThat(detailedCookieJsessionId.getValue(), equalTo("B3134D534F40968A3805968207273EF5"));
}
Aggregations