diff --git a/google-auth-library-java/oauth2_http/javatests/com/google/auth/oauth2/ServiceAccountCredentialsTest.java b/google-auth-library-java/oauth2_http/javatests/com/google/auth/oauth2/ServiceAccountCredentialsTest.java index ed26a0af3c6f..3c772801d789 100644 --- a/google-auth-library-java/oauth2_http/javatests/com/google/auth/oauth2/ServiceAccountCredentialsTest.java +++ b/google-auth-library-java/oauth2_http/javatests/com/google/auth/oauth2/ServiceAccountCredentialsTest.java @@ -1762,6 +1762,16 @@ void createScopes_existingAccessTokenInvalidated() throws IOException { assertNull(newAccessToken); } + @Test + void getRequestMetadata_withUniverseAndDelegation_throws() { + ServiceAccountCredentials credentials = + createDefaultBuilderWithKey(OAuth2Utils.privateKeyFromPkcs8(PRIVATE_KEY_PKCS8)) + .setUniverseDomain("example.com") + .setServiceAccountUser("user@example.com") + .build(); + assertThrows(IOException.class, () -> credentials.getRequestMetadata(CALL_URI)); + } + private void verifyJwtAccess(Map> metadata, String expectedScopeClaim) throws IOException { assertNotNull(metadata);