use of org.apache.commons.io.output.WriterOutputStream 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"));
}
use of org.apache.commons.io.output.WriterOutputStream in project rest-assured by rest-assured.
the class AuthenticationITest method formAuthenticationUsingLoggingWithLogDetailEqualToParams.
@Test
public void formAuthenticationUsingLoggingWithLogDetailEqualToParams() 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.PARAMS, new LogConfig(captor, true))).when().get("/formAuth").then().statusCode(200).body(equalTo("OK"));
assertThat(writer.toString(), equalTo("Request params:\t<none>\nQuery params:\t<none>\nForm params:\tj_username=John\n\t\t\t\tj_password=Doe\nPath params:\t<none>\nMultiparts:\t\t<none>\n"));
}
use of org.apache.commons.io.output.WriterOutputStream in project rest-assured by rest-assured.
the class PathParamITest method mixingUnnamedPathParametersAndQueryParametersWorks.
@Test
public void mixingUnnamedPathParametersAndQueryParametersWorks() throws Exception {
final StringWriter writer = new StringWriter();
final PrintStream captor = new PrintStream(new WriterOutputStream(writer), true);
given().config(RestAssuredConfig.config().logConfig(new LogConfig(captor, true))).log().all().filter(new Filter() {
public Response filter(FilterableRequestSpecification requestSpec, FilterableResponseSpecification responseSpec, FilterContext ctx) {
return new ResponseBuilder().setStatusCode(200).setBody("changed").build();
}
}).get("/{channelName}/item-import/rss/import?source={url}", "games", "http://myurl.com");
// Then
assertThat(RequestPathFromLogExtractor.loggedRequestPathIn(writer), equalTo("http://localhost:8080/games/item-import/rss/import?source=http%3A%2F%2Fmyurl.com"));
}
use of org.apache.commons.io.output.WriterOutputStream in project rest-assured by rest-assured.
the class PutTest method doesnt_automatically_adds_x_www_form_urlencoded_as_content_type_when_putting_params.
@Test
public void doesnt_automatically_adds_x_www_form_urlencoded_as_content_type_when_putting_params() {
StringWriter writer = new StringWriter();
PrintStream captor = new PrintStream(new WriterOutputStream(writer), true);
RestAssuredMockMvc.given().config(newConfig().logConfig(new LogConfig(captor, true))).param("name", "Johan").when().put("/greetingPut").then().log().all().statusCode(415);
assertThat(writer.toString(), equalTo("415 Content type 'null' not supported\nAccept: application/x-www-form-urlencoded\n"));
}
use of org.apache.commons.io.output.WriterOutputStream in project rest-assured by rest-assured.
the class RequestLoggingTest method given_config_is_stored_in_writer.
@Before
public void given_config_is_stored_in_writer() {
writer = new StringWriter();
PrintStream captor = new PrintStream(new WriterOutputStream(writer), true);
RestAssuredMockMvc.config = new RestAssuredMockMvcConfig().logConfig(new LogConfig(captor, true));
}
Aggregations