efegokdemir commented on code in PR #4360:
URL: https://github.com/apache/logging-log4j2/pull/4360#discussion_r4149809293
##########
log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/HttpAppenderTest.java:
##########
@@ -271,6 +272,30 @@ void testAppendCustomHeader() throws Exception {
.withRequestBody(containing("\"message\" : \"" + LOG_MESSAGE +
"\"")));
}
+ @Test
+ void testAppendSkipsHeaderWithInvalidRuntimeValue() throws Exception {
+
WIRE_MOCK.stubFor(post(urlEqualTo("/test/log4j/")).willReturn(SUCCESS_RESPONSE));
+ ThreadContext.put("tenant", "tenant\nwith-line-break");
+ try {
+ final Appender appender = HttpAppender.newBuilder()
+ .setName("Http")
+ .setLayout(JsonLayout.createDefaultLayout())
+ .setConfiguration(CONFIGURATION)
+ .setIgnoreExceptions(false)
+ .setUrl(wireMockUrl("/test/log4j/", false, false))
+ .setHeaders(new Property[]
{Property.createProperty("X-Tenant", "${ctx:tenant}")})
+ .build();
+ appender.append(createLogEvent());
+ } finally {
+ ThreadContext.remove("tenant");
+ }
+
+ WIRE_MOCK.verify(postRequestedFor(urlEqualTo("/test/log4j/"))
+ .withoutHeader("X-Tenant")
+ .withHeader("Content-Type", containing("application/json"))
+ .withRequestBody(containing("\"message\" : \"" + LOG_MESSAGE +
"\"")));
Review Comment:
Correction: current HEAD 495425b adds UsingStatusListener and asserts the
WARN status message contains X-Tenant. The requested changelog entry for issue
4352 is also present.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]