### Question:
Headers { static String toString(Map<String, List<Object>> headers, boolean logSensitiveHeaders) { Map<String, List<Object>> filteredHeaders = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); filteredHeaders.putAll(headers); if (!logSensitiveHeaders) { for (String filteredKey : SENSITIVE_HEADERS) { filteredHeaders.put(filteredKey, SENSITIVE_HEADER_MARKER); } } return filteredHeaders.toString(); } Headers(Message message);  Headers(); static String getUserAgent(); Map<String, List<String>> headerMap(); void writeSessionCookies(Map<String, Cookie> sessionCookies); void removeAuthorizationHeaders(); void setAuthorization(String authorization); void setProxyAuthorization(String authorization); static Map<String, List<String>> getSetProtocolHeaders(final Message message); void readFromConnection(HttpURLConnection connection); void setProtocolHeadersInConnection(HttpURLConnection connection); String determineContentType(); String getAuthorization(); static SimpleDateFormat getHttpDateFormat(); static String toHttpDate(Date date); static String toHttpLanguage(Locale locale); static final String KEY_HTTP_CONNECTION; static final String ADD_HEADERS_PROPERTY; static final String PROTOCOL_HEADERS_CONTENT_TYPE; static final String HTTP_HEADERS_SETCOOKIE; static final String HTTP_HEADERS_LINK; static final String EMPTY_REQUEST_PROPERTY; }### Answer:
@Test public void sensitiveHeadersTest() { Map<String, List<Object>> headerMap = new HashMap<>(); headerMap.put("Authorization", Arrays.asList("FAIL")); headerMap.put("Proxy-Authorization", Arrays.asList("FAIL")); headerMap.put("Content-Type", Arrays.asList("application/xml")); headerMap.put("Accept", Arrays.asList("text/plain")); String loggedString = Headers.toString(headerMap, false); assertFalse("The value of a sensitive header could be logged: " + loggedString, loggedString.contains("FAIL")); assertTrue("The value of a non-sensitive header would not be logged: " + loggedString, loggedString.contains("application/xml") && loggedString.contains("text/plain")); assertTrue("Expected header keys were not logged: " + loggedString, loggedString.contains("Authorization") && loggedString.contains("Proxy-Authorization") && loggedString.contains("Accept") && loggedString.contains("Content-Type")); }