Skip to content

Commit

Permalink
test: ITStorageTest requires Permission 'cloudkms.keyRings.setIamPoli…
Browse files Browse the repository at this point in the history
…cy' (#387)

* test: ITStorageTest requires Permission 'cloudkms.keyRings.setIamPolicy'
* test: notice IT_SERVICE_ACCOUNT_EMAIL evn variable for running integration test
  • Loading branch information
dmitry-fa committed Jul 18, 2020
1 parent 38c1c34 commit e63feb7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Expand Up @@ -48,6 +48,7 @@ integration tests.

```bash
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service/account.json
export IT_SERVICE_ACCOUNT_EMAIL=my-service-account@my-project.gserviceaccount.com
mvn -Penable-integration-tests clean verify
```

Expand Down
Expand Up @@ -260,6 +260,7 @@ public HttpTransport create() {
}

private static void prepareKmsKeys() throws IOException {
// https://cloud.google.com/storage/docs/encryption/using-customer-managed-keys
String projectId = remoteStorageHelper.getOptions().getProjectId();
GoogleCredentials credentials = GoogleCredentials.getApplicationDefault();
ManagedChannel kmsChannel =
Expand Down Expand Up @@ -339,7 +340,13 @@ private static void ensureKmsKeyRingIamPermissionsForTests(
.build();
requestParamsHeader.put(requestParamsKey, "parent=" + kmsKeyRingResourcePath);
iamStub = MetadataUtils.attachHeaders(iamStub, requestParamsHeader);
iamStub.setIamPolicy(setIamPolicyRequest);
try {
iamStub.setIamPolicy(setIamPolicyRequest);
} catch (StatusRuntimeException e) {
if (log.isLoggable(Level.WARNING)) {
log.log(Level.WARNING, "Unable to set IAM policy: {0}", e.getMessage());
}
}
}

private static String ensureKmsKeyExistsForTests(
Expand Down

0 comments on commit e63feb7

Please sign in to comment.