Skip to content
Open
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 @@ -53,6 +53,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -122,9 +123,20 @@ void fromStream_unknownType_throws() throws IOException {
}
}

@Test
void fromStream_invalidJson_throws() throws IOException {
// This test ensures Java successfully throws an IOException when ADC JSON parsing
// fails, preventing silent fallbacks.
MockHttpTransportFactory transportFactory = new MockHttpTransportFactory();
try (InputStream stream =
new ByteArrayInputStream("invalid-json{".getBytes(StandardCharsets.UTF_8))) {
assertThrows(IOException.class, () -> GoogleCredentials.fromStream(stream, transportFactory));
}
}

@Test
void fromStream_nullTransport_throws() {
InputStream stream = new ByteArrayInputStream("foo".getBytes());
InputStream stream = new ByteArrayInputStream("foo".getBytes(StandardCharsets.UTF_8));
assertThrows(NullPointerException.class, () -> GoogleCredentials.fromStream(stream, null));
}

Expand Down
Loading