Skip to content

Commit 862e52c

Browse files
committed
only log error code, not path, as info is covered by CloudSyncVerticle
1 parent e292810 commit 862e52c

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@
279279
<artifactId>maven-surefire-plugin</artifactId>
280280
<version>3.2.5</version>
281281
<configuration>
282-
<argLine>@{argLine} -XX:+EnableDynamicAgentLoading -Dnet.bytebuddy.experimental=true</argLine>
282+
<argLine>-XX:+EnableDynamicAgentLoading</argLine>
283283
</configuration>
284284
</plugin>
285285
<plugin>

src/main/java/com/uid2/shared/attest/UidCoreClient.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,9 @@ private InputStream getWithAttest(String path) throws IOException, AttestationRe
112112
HttpResponse<String> httpResponse;
113113
httpResponse = sendHttpRequest(path, attestationToken);
114114
if (httpResponse.statusCode() != 200) {
115-
// Don't log full path as it may contain sensitive information
116-
URI uri = URI.create(path);
117-
String safeEndpoint = uri.getHost() + uri.getPath();
118115
throw new CloudStorageException(String.format(
119-
"Cannot download required files from UID2 core service, HTTP response code %d, endpoint: %s, please visit UID2 guides for troubleshooting",
120-
httpResponse.statusCode(), safeEndpoint));
116+
"Cannot download required files from UID2 core service, HTTP response code %d, please visit UID2 guides for troubleshooting",
117+
httpResponse.statusCode()));
121118
}
122119
return Utils.convertHttpResponseToInputStream(httpResponse);
123120
}

src/test/java/com/uid2/shared/attest/UidCoreClientTest.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -193,21 +193,20 @@ public void Download_NetworkError_LogsExceptionType() throws IOException, Attest
193193
}
194194

195195
@Test
196-
public void Download_EndpointWithQueryParams_LogsOnlyHostAndPath() throws IOException, AttestationResponseHandlerException {
196+
public void Download_Http403Error_DoesNotLogPath() throws IOException, AttestationResponseHandlerException {
197197
HttpResponse<String> mockHttpResponse = mock(HttpResponse.class);
198198
when(mockHttpResponse.statusCode()).thenReturn(403);
199-
// URL with query params (simulating potential sensitive data)
200-
when(mockHttpClient.get(eq("https://core-prod.uidapi.com/sites/refresh?token=secret123"), any(HashMap.class))).thenReturn(mockHttpResponse);
199+
when(mockHttpClient.get(eq("https://core-prod.uidapi.com/sites/refresh"), any(HashMap.class))).thenReturn(mockHttpResponse);
201200

202201
CloudStorageException result = assertThrows(CloudStorageException.class, () -> {
203-
uidCoreClient.download("https://core-prod.uidapi.com/sites/refresh?token=secret123");
202+
uidCoreClient.download("https://core-prod.uidapi.com/sites/refresh");
204203
});
205204

206205
assertAll(
207-
() -> assertTrue(result.getMessage().contains("core-prod.uidapi.com/sites/refresh"),
208-
"Should contain host and path"),
209-
() -> assertFalse(result.getMessage().contains("token=secret123"),
210-
"Should NOT contain query parameters with tokens")
206+
() -> assertTrue(result.getMessage().contains("HTTP response code 403"),
207+
"Should contain HTTP status code"),
208+
() -> assertTrue(result.getMessage().contains("Cannot download required files from UID2 core service"),
209+
"Should have customer-friendly message")
211210
);
212211
}
213212
}

0 commit comments

Comments
 (0)