Index: /trunk/test/unit/org/openstreetmap/josm/actions/ShowStatusReportActionTest.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/actions/ShowStatusReportActionTest.java	(revision 19712)
+++ /trunk/test/unit/org/openstreetmap/josm/actions/ShowStatusReportActionTest.java	(revision 19712)
@@ -0,0 +1,38 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.actions;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.junit.jupiter.api.Test;
+import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
+
+/**
+ * Unit tests of {@link ShowStatusReportAction}.
+ */
+@BasicPreferences
+class ShowStatusReportActionTest {
+    /**
+     * The API keys and tokens in the URLs of preference values, e.g. of custom imagery, are stripped from the status
+     * report; other values are kept.
+     */
+    @Test
+    void testValueCleanupStripsUrls() {
+        assertEquals("https://tiles.example.org/{zoom}/{x}/{y}.png?apikey=...stripped...",
+                ShowStatusReportAction.valueCleanup("https://tiles.example.org/{zoom}/{x}/{y}.png?apikey=a-secret-key"));
+
+        final Map<String, String> imagery = new LinkedHashMap<>();
+        imagery.put("name", "Custom");
+        imagery.put("url", "https://tiles.example.org/{zoom}/{x}/{y}.png?access_token=a-secret-token");
+        assertEquals("[{name=Custom, url=https://tiles.example.org/{zoom}/{x}/{y}.png?access_token=...stripped...}]",
+                ShowStatusReportAction.valueCleanup(Collections.singletonList(imagery)));
+
+        assertEquals("[[https://example.org/?key=...stripped..., other]]", ShowStatusReportAction.valueCleanup(
+                Collections.singletonList(Arrays.asList("https://example.org/?key=a-secret-key", "other"))));
+        assertEquals("[a, b]", ShowStatusReportAction.valueCleanup(Arrays.asList("a", "b")));
+    }
+}
Index: /trunk/test/unit/org/openstreetmap/josm/tools/HttpClientCredentialsLoggingTest.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/tools/HttpClientCredentialsLoggingTest.java	(revision 19712)
+++ /trunk/test/unit/org/openstreetmap/josm/tools/HttpClientCredentialsLoggingTest.java	(revision 19712)
@@ -0,0 +1,112 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.tools;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.net.URI;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+import java.util.logging.SimpleFormatter;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
+import org.openstreetmap.josm.testutils.annotations.BasicWiremock;
+import org.openstreetmap.josm.testutils.annotations.HTTP;
+
+import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo;
+
+/**
+ * Credentials are not written to the log by {@link HttpClient}: debug and trace logs are often posted in public
+ * tickets. The stripping itself is tested in {@link TextUtilsTest}.
+ */
+@BasicPreferences
+@BasicWiremock
+@HTTP
+class HttpClientCredentialsLoggingTest {
+    private static final String TOKEN = "a-secret-bearer-token";
+    private static final String COOKIE = "a-secret-session-cookie";
+    private static final String CLIENT_SECRET = "a-secret-client-secret";
+
+    private final List<String> logged = Collections.synchronizedList(new ArrayList<>());
+    private final SimpleFormatter formatter = new SimpleFormatter();
+    private final Handler handler = new Handler() {
+        @Override
+        public void publish(LogRecord logRecord) {
+            logged.add(formatter.formatMessage(logRecord));
+        }
+
+        @Override
+        public void flush() {
+            // nothing to flush
+        }
+
+        @Override
+        public void close() {
+            // nothing to close
+        }
+    };
+    private Level level;
+
+    @BeforeEach
+    void setUp() {
+        level = Logging.getLogger().getLevel();
+        Logging.getLogger().addHandler(handler);
+        Logging.setLogLevel(Logging.LEVEL_TRACE);
+    }
+
+    @AfterEach
+    void tearDown() {
+        Logging.getLogger().removeHandler(handler);
+        Logging.setLogLevel(level);
+    }
+
+    /**
+     * A request with a bearer token, answered with a session cookie, and a token request with a client secret, are
+     * logged at trace level without any of them.
+     * @param wireMock the server answering the requests
+     * @throws Exception if a request fails
+     */
+    @Test
+    void testRequestsAreLoggedWithoutCredentials(WireMockRuntimeInfo wireMock) throws Exception {
+        wireMock.getWireMock().register(get(urlEqualTo("/api/0.6/user/details"))
+                .willReturn(aResponse().withStatus(200).withHeader("Set-Cookie", "_osm_session=" + COOKIE).withBody("<osm/>")));
+        wireMock.getWireMock().register(post(urlEqualTo("/oauth2/token"))
+                .willReturn(aResponse().withStatus(200).withBody("{}")));
+
+        final HttpClient details = HttpClient.create(URI.create(wireMock.getHttpBaseUrl() + "/api/0.6/user/details").toURL());
+        details.setHeader("Authorization", "Bearer " + TOKEN);
+        try {
+            details.connect();
+        } finally {
+            details.disconnect();
+        }
+        final HttpClient token = HttpClient.create(URI.create(wireMock.getHttpBaseUrl() + "/oauth2/token").toURL(), "POST");
+        token.setHeader("Content-Type", "application/x-www-form-urlencoded");
+        token.setRequestBody(("grant_type=authorization_code&client_id=an-id&client_secret=" + CLIENT_SECRET + "&code=a-code")
+                .getBytes(StandardCharsets.UTF_8));
+        try {
+            token.connect();
+        } finally {
+            token.disconnect();
+        }
+
+        final String log = String.join("\n", logged);
+        assertTrue(log.contains("Authorization=Bearer ...stripped..."), log);
+        assertTrue(log.contains("client_secret=...stripped..."), log);
+        for (String secret : new String[] {TOKEN, COOKIE, CLIENT_SECRET}) {
+            assertFalse(log.contains(secret), () -> "logged: " + secret + "\n" + log);
+        }
+    }
+}
Index: /trunk/test/unit/org/openstreetmap/josm/tools/TextUtilsTest.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/tools/TextUtilsTest.java	(revision 19712)
+++ /trunk/test/unit/org/openstreetmap/josm/tools/TextUtilsTest.java	(revision 19712)
@@ -0,0 +1,88 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.tools;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.junit.jupiter.api.Test;
+
+/**
+ * Unit tests of {@link TextUtils}.
+ */
+class TextUtilsTest {
+
+    /**
+     * Test of {@link TextUtils#wrapLongUrl}.
+     */
+    @Test
+    void testWrapLongUrl() {
+        assertEquals("https:/​/​example.org/​x?a=1&​b=2", TextUtils.wrapLongUrl("https://example.org/x?a=1&b=2"));
+    }
+
+    /**
+     * API keys and tokens in a URL are stripped, as before; other parameters are kept.
+     */
+    @Test
+    void testStripUrl() {
+        assertEquals("https://example.org/{z}/{x}/{y}.png?access_token=...stripped...&style=dark",
+                TextUtils.stripUrl("https://example.org/{z}/{x}/{y}.png?access_token=abc&style=dark"));
+        assertEquals("https://example.org/tiles?apikey=...stripped...&connectId=...stripped...",
+                TextUtils.stripUrl("https://example.org/tiles?apikey=abc&connectId=def"));
+        assertEquals("https://example.org/search?q=Main+Street&postcode=AB1",
+                TextUtils.stripUrl("https://example.org/search?q=Main+Street&postcode=AB1"));
+    }
+
+    /**
+     * The OAuth 2.0 authorization code in the redirect received by Remote Control is stripped.
+     */
+    @Test
+    void testStripUrlAuthorizationCode() {
+        assertEquals("GET /oauth_authorization?code=...stripped...&state=a-state HTTP/1.1",
+                TextUtils.stripUrl("GET /oauth_authorization?code=a-code&state=a-state HTTP/1.1"));
+        assertEquals("GET /oauth_authorization?state=a-state&code=...stripped... HTTP/1.1",
+                TextUtils.stripUrl("GET /oauth_authorization?state=a-state&code=a-code HTTP/1.1"));
+    }
+
+    /**
+     * The credentials of an OAuth 2.0 token request are stripped from its form-encoded body; the other parameters are
+     * kept, among them the grant type, whose value may be {@code refresh_token}.
+     */
+    @Test
+    void testStripUrlFormBody() {
+        assertEquals("grant_type=authorization_code&client_id=an-id&client_secret=...stripped...&redirect_uri=http://x"
+                + "&code=...stripped...&code_verifier=...stripped...",
+                TextUtils.stripUrl("grant_type=authorization_code&client_id=an-id&client_secret=a-secret"
+                + "&redirect_uri=http://x&code=a-code&code_verifier=a-verifier"));
+        assertEquals("grant_type=refresh_token&refresh_token=...stripped...",
+                TextUtils.stripUrl("grant_type=refresh_token&refresh_token=a-refresh-token"));
+        assertEquals("username=someone&password=...stripped...", TextUtils.stripUrl("username=someone&password=secret"));
+    }
+
+    /**
+     * The values of the headers which are credentials are stripped, but for the scheme of an authorization; the
+     * other headers are kept as they are, in the same order.
+     */
+    @Test
+    void testStripHeaders() {
+        final Map<String, String> request = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+        request.put("Accept", "application/xml");
+        request.put("authorization", "Bearer a-token");
+        request.put("Proxy-Authorization", "Basic dXNlcjpwYXNzd29yZA==");
+        request.put("Cookie", "a-cookie=1; other=2");
+        assertEquals("{Accept=application/xml, authorization=Bearer ...stripped..., Cookie=...stripped..., "
+                + "Proxy-Authorization=Basic ...stripped...}", TextUtils.stripHeaders(request).toString());
+
+        final Map<String, List<String>> response = new LinkedHashMap<>();
+        response.put(null, Collections.singletonList("HTTP/1.1 200 OK"));
+        response.put("Set-Cookie", Arrays.asList("_osm_session=a-cookie; path=/; HttpOnly", "other=1"));
+        response.put("Content-Type", Collections.singletonList("application/json"));
+        assertEquals("{null=[HTTP/1.1 200 OK], Set-Cookie=[...stripped..., ...stripped...], Content-Type=[application/json]}",
+                TextUtils.stripHeaders(response).toString());
+    }
+}
