Skip to content

Commit d911fde

Browse files
dazumaquartzmo
authored andcommitted
Allow override of KMS keys in storage acceptance tests (#2528)
* Allow override of KMS keys in storage acceptance tests * Use current project instead of hard-coding the project ID
1 parent f42e105 commit d911fde

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

google-cloud-storage/acceptance/storage/bucket_encryption_test.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,14 @@
1717
describe Google::Cloud::Storage::Bucket, :encryption, :storage do
1818
let(:bucket_name) { "#{$bucket_names[1]}-encryption" }
1919
let(:bucket_location) { "us-central1" }
20-
let(:kms_key) { "projects/helical-zone-771/locations/#{bucket_location}/keyRings/ruby-test/cryptoKeys/ruby-test-key-1" }
21-
let(:kms_key_2) { "projects/helical-zone-771/locations/#{bucket_location}/keyRings/ruby-test/cryptoKeys/ruby-test-key-2" }
20+
let(:kms_key) {
21+
ENV["GCLOUD_TEST_STORAGE_KMS_KEY_1"] ||
22+
"projects/#{storage.project_id}/locations/#{bucket_location}/keyRings/ruby-test/cryptoKeys/ruby-test-key-1"
23+
}
24+
let(:kms_key_2) {
25+
ENV["GCLOUD_TEST_STORAGE_KMS_KEY_2"] ||
26+
"projects/#{storage.project_id}/locations/#{bucket_location}/keyRings/ruby-test/cryptoKeys/ruby-test-key-2"
27+
}
2228
let :bucket do
2329
b = safe_gcs_execute { storage.create_bucket(bucket_name, location: bucket_location) }
2430
b.default_kms_key = kms_key

google-cloud-storage/acceptance/storage/file_encryption_test.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,14 @@
159159
end
160160

161161
describe "KMS customer-managed encryption key (CMEK)" do
162-
let(:kms_key) { "projects/helical-zone-771/locations/#{bucket_location}/keyRings/ruby-test/cryptoKeys/ruby-test-key-1" }
163-
let(:kms_key_2) { "projects/helical-zone-771/locations/#{bucket_location}/keyRings/ruby-test/cryptoKeys/ruby-test-key-2" }
162+
let(:kms_key) {
163+
ENV["GCLOUD_TEST_STORAGE_KMS_KEY_1"] ||
164+
"projects/#{storage.project_id}/locations/#{bucket_location}/keyRings/ruby-test/cryptoKeys/ruby-test-key-1"
165+
}
166+
let(:kms_key_2) {
167+
ENV["GCLOUD_TEST_STORAGE_KMS_KEY_2"] ||
168+
"projects/#{storage.project_id}/locations/#{bucket_location}/keyRings/ruby-test/cryptoKeys/ruby-test-key-2"
169+
}
164170

165171
it "should upload and download a file with default_kms_key" do
166172
bucket.default_kms_key = kms_key

0 commit comments

Comments
 (0)