Skip to content
Permalink
Browse files
fix: follow up fix service account credentials createScopedRequired (#…
  • Loading branch information
arithmetic1728 committed Mar 18, 2021
1 parent 3d066ee commit 7ddac43c418bb8b0cc3fd8d4f9d8752ad65bd842
@@ -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();
}

/**
@@ -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();

0 comments on commit 7ddac43

Please sign in to comment.