mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-08-11 13:48:37 +02:00
Update CorrelationIdFilterTest.java
This commit is contained in:
parent
1973c86720
commit
cf2f366e8e
@ -22,12 +22,11 @@ import jakarta.servlet.ServletResponse;
|
|||||||
/**
|
/**
|
||||||
* Tests for {@link CorrelationIdFilter}.
|
* Tests for {@link CorrelationIdFilter}.
|
||||||
*
|
*
|
||||||
* <p>Important notes:
|
* <p>Important notes: - The filter sets MDC in the try block and clears it in the finally block.
|
||||||
* - The filter sets MDC in the try block and clears it in the finally block. Therefore,
|
* Therefore, we capture the MDC values inside a special FilterChain before the clear happens
|
||||||
* we capture the MDC values inside a special FilterChain before the clear happens (snapshot).
|
* (snapshot). - The response header is sanitized via Newlines.stripAll(id). The current code does
|
||||||
* - The response header is sanitized via Newlines.stripAll(id).
|
* NOT sanitize the value stored in the MDC or the request attribute. These tests reflect the
|
||||||
* The current code does NOT sanitize the value stored in the MDC or the request attribute.
|
* current behavior.
|
||||||
* These tests reflect the current behavior.
|
|
||||||
*/
|
*/
|
||||||
class CorrelationIdFilterTest {
|
class CorrelationIdFilterTest {
|
||||||
|
|
||||||
@ -133,7 +132,8 @@ class CorrelationIdFilterTest {
|
|||||||
|
|
||||||
assertTrue(chain.called);
|
assertTrue(chain.called);
|
||||||
|
|
||||||
// Consistency: same value in MDC, request attribute, and response header (no newline removal needed)
|
// Consistency: same value in MDC, request attribute, and response header (no newline
|
||||||
|
// removal needed)
|
||||||
String mdcId = chain.capturedMdc.get(CorrelationIdFilter.MDC_KEY);
|
String mdcId = chain.capturedMdc.get(CorrelationIdFilter.MDC_KEY);
|
||||||
assertNotNull(mdcId);
|
assertNotNull(mdcId);
|
||||||
assertEquals(mdcId, chain.requestAttr);
|
assertEquals(mdcId, chain.requestAttr);
|
||||||
|
Loading…
Reference in New Issue
Block a user