Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: follow up fix service account credentials createScopedRequired #605

Merged
merged 2 commits into from Mar 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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