Skip to content

Commit

Permalink
fix: fix service account credentials createScopedRequired (#601)
Browse files Browse the repository at this point in the history
* fix: fix service account credentials createScopedRequired

* Update oauth2_http/javatests/com/google/auth/oauth2/ServiceAccountCredentialsTest.java
  • Loading branch information
arithmetic1728 authored Mar 18, 2021
1 parent 31ebe6e commit 0614482
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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).
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0614482

Please sign in to comment.