Skip to content

Commit 828f50f

Browse files
committed
test(auth): Assert IOException on custom universe domain with delegation
This commit adds a test case to ServiceAccountCredentialsTest to verify that configuring a custom Universe Domain along with Domain-Wide Delegation safely throws the expected IOException. Domain-wide delegation is not supported outside of the default Google universe. This brings the Java library's test suite into alignment with the expected auth specification. Other Google Cloud client libraries like Go, Node.js, and Python natively assert that this configuration combination throws a validation error during credential initialization or token generation.
1 parent 051aea7 commit 828f50f

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

google-auth-library-java/oauth2_http/javatests/com/google/auth/oauth2/ServiceAccountCredentialsTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,6 +1762,16 @@ void createScopes_existingAccessTokenInvalidated() throws IOException {
17621762
assertNull(newAccessToken);
17631763
}
17641764

1765+
@Test
1766+
void getRequestMetadata_withUniverseAndDelegation_throws() {
1767+
ServiceAccountCredentials credentials =
1768+
createDefaultBuilderWithKey(OAuth2Utils.privateKeyFromPkcs8(PRIVATE_KEY_PKCS8))
1769+
.setUniverseDomain("example.com")
1770+
.setServiceAccountUser("user@example.com")
1771+
.build();
1772+
assertThrows(IOException.class, () -> credentials.getRequestMetadata(CALL_URI));
1773+
}
1774+
17651775
private void verifyJwtAccess(Map<String, List<String>> metadata, String expectedScopeClaim)
17661776
throws IOException {
17671777
assertNotNull(metadata);

0 commit comments

Comments
 (0)