use of io.restassured.config.LogConfig in project rest-assured by rest-assured.
the class LoggingITest method logCookiesUsingRequestLogSpec.
@Test
public void logCookiesUsingRequestLogSpec() throws Exception {
final StringWriter writer = new StringWriter();
final PrintStream captor = new PrintStream(new WriterOutputStream(writer), true);
given().config(config().logConfig(new LogConfig(captor, true))).log().cookies().cookie("myCookie1", "myCookieValue1").cookie("myCookie2", "myCookieValue2").cookie("myMultiCookie", "myMultiCookieValue1", "myMultiCookieValue2").when().post("/reflect");
assertThat(writer.toString(), equalTo("Cookies:\t\tmyCookie1=myCookieValue1\n\t\t\t\tmyCookie2=myCookieValue2\n\t\t\t\tmyMultiCookie=myMultiCookieValue1\n\t\t\t\tmyMultiCookie=myMultiCookieValue2" + LINE_SEPARATOR));
}
use of io.restassured.config.LogConfig in project rest-assured by rest-assured.
the class LoggingITest method logParamsUsingRequestLogSpec.
@Test
public void logParamsUsingRequestLogSpec() throws Exception {
final StringWriter writer = new StringWriter();
final PrintStream captor = new PrintStream(new WriterOutputStream(writer), true);
given().config(config().logConfig(new LogConfig(captor, true))).log().parameters().param("firstName", "John").queryParam("lastName", "Doe").when().get("/greetJSON");
assertThat(writer.toString(), equalTo("Request params:\tfirstName=John\nQuery params:\tlastName=Doe\nForm params:\t<none>\nPath params:\t<none>\nMultiparts:\t\t<none>" + LINE_SEPARATOR));
}
use of io.restassured.config.LogConfig in project rest-assured by rest-assured.
the class LoggingITest method logAllWhenBaseURIIsDefinedUsingRequestLogSpec.
@Test
public void logAllWhenBaseURIIsDefinedUsingRequestLogSpec() throws Exception {
final StringWriter writer = new StringWriter();
final PrintStream captor = new PrintStream(new WriterOutputStream(writer), true);
RestAssured.baseURI = "http://localhost:8080/reflect";
try {
given().config(config().logConfig(new LogConfig(captor, true))).log().all().body("hello").when().post("/");
} finally {
RestAssured.reset();
}
assertThat(writer.toString(), equalTo("Request method:\tPOST\nRequest URI:\thttp://localhost:8080/reflect/\nProxy:\t\t\t<none>\nRequest params:\t<none>\nQuery params:\t<none>\nForm params:\t<none>\nPath params:\t<none>\nHeaders:\t\tAccept=*/*\n\t\t\t\tContent-Type=text/plain; charset=" + RestAssured.config().getEncoderConfig().defaultContentCharset() + "\nCookies:\t\t<none>\nMultiparts:\t\t<none>\nBody:\nhello" + LINE_SEPARATOR));
}
use of io.restassured.config.LogConfig in project rest-assured by rest-assured.
the class AuthenticationITest method formAuthenticationUsingLogging.
@Test
public void formAuthenticationUsingLogging() throws Exception {
final StringWriter writer = new StringWriter();
final PrintStream captor = new PrintStream(new WriterOutputStream(writer), true);
given().auth().form("John", "Doe", FormAuthConfig.springSecurity().withLoggingEnabled(new LogConfig(captor, true))).when().get("/formAuth").then().statusCode(200).body(equalTo("OK"));
assertThat(writer.toString(), equalTo("Request method:\tPOST\nRequest URI:\thttp://localhost:8080/j_spring_security_check\nProxy:\t\t\t<none>\nRequest params:\t<none>\nQuery params:\t<none>\nForm params:\tj_username=John\n\t\t\t\tj_password=Doe\nPath params:\t<none>\nHeaders:\t\tAccept=*/*\n\t\t\t\tContent-Type=application/x-www-form-urlencoded; charset=" + RestAssured.config().getEncoderConfig().defaultContentCharset() + "\nCookies:\t\t<none>\nMultiparts:\t\t<none>\nBody:\t\t\t<none>\nHTTP/1.1 200 OK\nContent-Type: text/plain;charset=utf-8\nSet-Cookie: jsessionid=1234\nContent-Length: 0\nServer: Jetty(9.3.2.v20150730)\n"));
}
use of io.restassured.config.LogConfig in project rest-assured by rest-assured.
the class AuthenticationITest method formAuthenticationUsingLoggingWithLogDetailEqualToStatus.
@Test
public void formAuthenticationUsingLoggingWithLogDetailEqualToStatus() throws Exception {
final StringWriter writer = new StringWriter();
final PrintStream captor = new PrintStream(new WriterOutputStream(writer), true);
given().auth().form("John", "Doe", FormAuthConfig.springSecurity().withLoggingEnabled(LogDetail.STATUS, new LogConfig(captor, true))).when().get("/formAuth").then().statusCode(200).body(equalTo("OK"));
assertThat(writer.toString(), equalTo("HTTP/1.1 200 OK\n"));
}
Aggregations