Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,18 @@ void fromStream_unknownType_throws() throws IOException {
}
}

@Test
void fromStream_invalidJson_throws() throws IOException {
// Other client libraries (like Python, Go, and Rust) strictly validate JSON syntax and reject
// malformed payload structures immediately. This test ensures Java maintains parity by
// successfully throwing an IOException when ADC JSON parsing fails, preventing silent fallbacks.
MockHttpTransportFactory transportFactory = new MockHttpTransportFactory();
try (InputStream stream = new ByteArrayInputStream("invalid-json{".getBytes(java.nio.charset.StandardCharsets.UTF_8))) {
assertThrows(
IOException.class, () -> GoogleCredentials.fromStream(stream, transportFactory));
}
}

@Test
void fromStream_nullTransport_throws() {
InputStream stream = new ByteArrayInputStream("foo".getBytes());
Expand Down
Loading