Skip to content

Commit

Permalink
fix: follow up fix service account credentials createScopedRequired (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
arithmetic1728 authored Mar 18, 2021
1 parent 3d066ee commit 7ddac43
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ public static ServiceAccountCredentials fromStream(
/** Returns whether the scopes are empty, meaning createScoped must be called before use. */
@Override
public boolean createScopedRequired() {
return scopes.isEmpty();
return scopes.isEmpty() && defaultScopes.isEmpty();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,14 +488,23 @@ public void createScopedRequired_emptyScopes() throws IOException {
}

@Test
public void createScopedRequired_nonEmptyScopes_false() throws IOException {
public void createScopedRequired_nonEmptyScopes() throws IOException {
GoogleCredentials credentials =
ServiceAccountCredentials.fromPkcs8(
CLIENT_ID, CLIENT_EMAIL, PRIVATE_KEY_PKCS8, PRIVATE_KEY_ID, SCOPES);

assertFalse(credentials.createScopedRequired());
}

@Test
public void createScopedRequired_nonEmptyDefaultScopes() throws IOException {
GoogleCredentials credentials =
ServiceAccountCredentials.fromPkcs8(
CLIENT_ID, CLIENT_EMAIL, PRIVATE_KEY_PKCS8, PRIVATE_KEY_ID, null, SCOPES);

assertFalse(credentials.createScopedRequired());
}

@Test
public void fromJSON_getProjectId() throws IOException {
MockTokenServerTransportFactory transportFactory = new MockTokenServerTransportFactory();
Expand Down

0 comments on commit 7ddac43

Please sign in to comment.