Skip to content

Commit f29b6e9

Browse files
committed
chore: Document the test rationale
1 parent b772034 commit f29b6e9

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

oauth2_http/javatests/com/google/auth/oauth2/LoggingTest.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,8 @@ void stsRequestHandler_exchangeToken_masksSensitiveTokens() throws IOException {
627627
testAppender.stop();
628628
}
629629

630+
// We specifically test ImpersonatedCredentials here because it constructs its HTTP requests
631+
// using JsonHttpContent, unlike most other credentials which use UrlEncodedContent.
630632
@Test
631633
void impersonatedCredentials_exchangeToken_masksSensitiveTokens()
632634
throws IOException, IllegalStateException {
@@ -659,8 +661,7 @@ void impersonatedCredentials_exchangeToken_masksSensitiveTokens()
659661
requestPayload = (String) kvp.value;
660662
}
661663
}
662-
// When logged at DEBUG level, the request payload should be present and valid JSON
663-
// (the JsonHttpContent payload goes through parseGenericData for masking)
664+
// When logged at DEBUG level, the request payload should be present and valid JSON.
664665
if (requestPayload != null) {
665666
assertTrue(isValidJson(requestPayload), "Request payload should be valid JSON");
666667
}
@@ -685,6 +686,8 @@ void impersonatedCredentials_exchangeToken_masksSensitiveTokens()
685686
testAppender.stop();
686687
}
687688

689+
// We specifically use ImpersonatedCredentials for this test because its request payload
690+
// is formatted using JsonHttpContent, whereas other credentials primarily use UrlEncodedContent.
688691
@Test
689692
void impersonatedCredentials_requestPayload_masksJsonHttpContentSensitiveKeys()
690693
throws IOException, IllegalStateException {
@@ -734,10 +737,8 @@ void impersonatedCredentials_requestPayload_masksJsonHttpContentSensitiveKeys()
734737
assertNotNull(requestPayload, "Request payload should be logged at DEBUG level");
735738
assertTrue(isValidJson(requestPayload), "Request payload should be valid JSON");
736739

737-
// The ImpersonatedCredentials request payload uses JsonHttpContent with fields:
738-
// delegates, scope, lifetime. None of these are in SENSITIVE_KEYS, so they should
739-
// appear as-is (not hashed). This validates that JsonHttpContent goes through
740-
// parseGenericData without breaking.
740+
// The request payload uses JsonHttpContent with fields: delegates, scope, lifetime. None of
741+
// these are in SENSITIVE_KEYS, so they should appear as-is (not hashed).
741742
assertFalse(
742743
requestPayload.contains("\"delegates\":null"),
743744
"Payload should be properly serialized from JsonHttpContent");

0 commit comments

Comments
 (0)