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..57ab82a55347 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,17 @@ void createScopes_existingAccessTokenInvalidated() throws IOException { assertNull(newAccessToken); } + @Test + void getRequestMetadata_withMultipleScopes_selfSignedJWT() throws IOException { + List scopes = Arrays.asList("scope1", "scope2"); + ServiceAccountCredentials credentials = + createDefaultBuilderWithKey(OAuth2Utils.privateKeyFromPkcs8(PRIVATE_KEY_PKCS8)) + .setScopes(scopes) + .setUseJwtAccessWithScope(true) + .build(); + verifyJwtAccess(credentials.getRequestMetadata(CALL_URI), "scope1 scope2"); + } + private void verifyJwtAccess(Map> metadata, String expectedScopeClaim) throws IOException { assertNotNull(metadata);