Skip to content

Commit

Permalink
Update a test
Browse files Browse the repository at this point in the history
  • Loading branch information
Vadzim Hushchanskou authored and Vadzim Hushchanskou committed Nov 30, 2024
1 parent 50f1544 commit 8ce1de9
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -641,18 +641,22 @@ public void test_rest_assured_logger_text_as_file_multipart() {
@Test
public void test_rest_assured_header_filter() {
FilterableRequestSpecification requestSpecification = mockBasicRequest(HTML_TYPE);
RestAssuredConfig config = RestAssuredConfig.config().logConfig(LogConfig.logConfig().blacklistHeader("Authorization"));
RestAssuredConfig config = RestAssuredConfig.config().logConfig(
LogConfig.logConfig().blacklistHeader("Authorization").blacklistHeader("Set-Cookie"));
when(requestSpecification.getConfig()).thenReturn(config);
Headers headers = new Headers(new Header(HttpHeaders.AUTHORIZATION, "Bearer some_token"));
when(requestSpecification.getHeaders()).thenReturn(headers);
Headers requestHeaders = new Headers(new Header(HttpHeaders.AUTHORIZATION, "Bearer some_token"));
when(requestSpecification.getHeaders()).thenReturn(requestHeaders);
Response responseObject = mockBasicResponse(HTML_TYPE);
Headers responseHeaders = new Headers(new Header("Set-Cookie", "cookie"));
when(responseObject.getHeaders()).thenReturn(responseHeaders);

List<String> logs = runFilterTextMessageCapture(requestSpecification, responseObject);
assertThat(logs, hasSize(2)); // Request + Response

String headerString = "\n\n**Headers**\n" + HttpHeaders.AUTHORIZATION + ": " + REMOVED_TAG;
String requestHeaderString = "\n\n**Headers**\n" + HttpHeaders.AUTHORIZATION + ": " + REMOVED_TAG;
assertThat(logs.get(0), equalTo(EMPTY_REQUEST + requestHeaderString));

assertThat(logs.get(0), equalTo(EMPTY_REQUEST + headerString));
assertThat(logs.get(1), equalTo(EMPTY_RESPONSE));
String responseHeaderString = "\n\n**Headers**\nSet-Cookie: " + REMOVED_TAG;
assertThat(logs.get(1), equalTo(EMPTY_RESPONSE + responseHeaderString));
}
}

0 comments on commit 8ce1de9

Please sign in to comment.