@@ -184,13 +184,14 @@ void maskResponseHeaders() {
184184 @ Test
185185 void maskRequestHeadersWithDuplicateHeaderName () {
186186 final HeaderMaskingFunction maskingFunction = (name , value ) -> "****armeria****" ;
187+ final HeadersSanitizer <String > headersSanitizer =
188+ HeadersSanitizer .builderForText ()
189+ .sensitiveHeaders ("accept-encoding" )
190+ .sensitiveHeaders ("content-type" )
191+ .maskingFunction (maskingFunction )
192+ .build ();
187193 final LogFormatter logFormatter = LogFormatter .builderForText ()
188- .requestHeadersSanitizer (
189- HeadersSanitizer .builderForText ()
190- .sensitiveHeaders ("accept-encoding" )
191- .sensitiveHeaders ("content-type" )
192- .maskingFunction (maskingFunction )
193- .build ())
194+ .requestHeadersSanitizer (headersSanitizer )
194195 .build ();
195196 final HttpRequest req = HttpRequest .of (RequestHeaders .of (HttpMethod .GET , "/hello" ,
196197 "Accept-Encoding" , "gzip" ,
@@ -226,11 +227,11 @@ void removeSensitiveHeaders() {
226227 log .endResponse ();
227228
228229 final String responseLog = logFormatter .formatResponse (log );
229- final Matcher matcher1 = Pattern .compile ("\" set-cookie\" = \" (.*?)\" " ).matcher (responseLog );
230+ final Matcher matcher1 = Pattern .compile ("set-cookie= (.*?)[, \\ ]] " ).matcher (responseLog );
230231 assertThat (matcher1 .find ()).isFalse ();
231- final Matcher matcher2 = Pattern .compile ("\" multiple-header\" = \" (.*?)\" " ).matcher (responseLog );
232+ final Matcher matcher2 = Pattern .compile ("multiple-header= (.*?)[, \\ ]] " ).matcher (responseLog );
232233 assertThat (matcher2 .find ()).isFalse ();
233- final Matcher matcher3 = Pattern .compile ("\" cache-control\" = \" (.*?)\" " ).matcher (responseLog );
234+ final Matcher matcher3 = Pattern .compile ("cache-control= (.*?)[, \\ ]] " ).matcher (responseLog );
234235 assertThat (matcher3 .find ()).isTrue ();
235236 assertThat (matcher3 .group (1 )).isEqualTo ("no-cache" );
236237 }
0 commit comments