Skip to content
Permalink
Browse files
fix: fix service account credentials createScopedRequired (#601)
* fix: fix service account credentials createScopedRequired

* Update oauth2_http/javatests/com/google/auth/oauth2/ServiceAccountCredentialsTest.java
  • Loading branch information
arithmetic1728 committed Mar 18, 2021
1 parent 31ebe6e commit 061448209da05ddfc75b40aae495c33d0ee7f1ee
@@ -561,6 +561,12 @@ public static ServiceAccountCredentials fromStream(
fileType, SERVICE_ACCOUNT_FILE_TYPE));
}

/** Returns whether the scopes are empty, meaning createScoped must be called before use. */
@Override
public boolean createScopedRequired() {
return scopes.isEmpty();
}

/**
* Refreshes the OAuth2 access token by getting a new access token using a JSON Web Token (JWT).
*/
@@ -479,12 +479,12 @@ public void createdScoped_defaultScopes() throws IOException {
}

@Test
public void createScopedRequired_emptyScopes_false() throws IOException {
public void createScopedRequired_emptyScopes() throws IOException {
GoogleCredentials credentials =
ServiceAccountCredentials.fromPkcs8(
CLIENT_ID, CLIENT_EMAIL, PRIVATE_KEY_PKCS8, PRIVATE_KEY_ID, EMPTY_SCOPES);

assertFalse(credentials.createScopedRequired());
assertTrue(credentials.createScopedRequired());
}

@Test

0 comments on commit 0614482

Please sign in to comment.