|
89 | 89 | bucket_gapi_with_key = bucket_gapi.dup |
90 | 90 | bucket_gapi_with_key.encryption = encryption_gapi(key_name: kms_key) |
91 | 91 | bucket_with_key = Google::Cloud::Storage::Bucket.from_gapi bucket_gapi_with_key, storage.service |
| 92 | + patch_bucket_gapi = Google::Apis::StorageV1::Bucket.new encryption: encryption_gapi(key_name: kms_key) |
| 93 | + patch_bucket_gapi = Google::Apis::StorageV1::Bucket.new( |
| 94 | + encryption: Google::Apis::StorageV1::Bucket::Encryption.new( |
| 95 | + default_kms_key_name: nil |
| 96 | + ) |
| 97 | + ) |
92 | 98 | mock = Minitest::Mock.new |
93 | | - mock.expect :patch_bucket, bucket_gapi do |name, patch_obj, **args| |
94 | | - name == bucket_name && patch_obj.encryption&.default_kms_key_name.nil? |
95 | | - end |
| 99 | + mock.expect :patch_bucket, bucket_gapi, [bucket_name, patch_bucket_gapi], **patch_bucket_args(options: {retries: 0}) |
96 | 100 |
|
97 | 101 | bucket_with_key.service.mocked_service = mock |
98 | 102 |
|
|
123 | 127 | end |
124 | 128 |
|
125 | 129 | describe "encryption enforcement config" do |
126 | | - let(:customer_managed_encryption) { Google::Apis::StorageV1::Bucket::Encryption::CustomerManagedEncryptionEnforcementConfig.new restriction_mode: "NotRestricted" } |
127 | | - let(:customer_supplied_encryption) { Google::Apis::StorageV1::Bucket::Encryption::CustomerSuppliedEncryptionEnforcementConfig.new restriction_mode: "FullyRestricted" } |
128 | | - let(:google_managed_encryption) { Google::Apis::StorageV1::Bucket::Encryption::GoogleManagedEncryptionEnforcementConfig.new restriction_mode: "NotRestricted" } |
129 | 130 | let(:bucket_encryption) do |
130 | 131 | Google::Apis::StorageV1::Bucket::Encryption.new( |
131 | 132 | customer_managed_encryption_enforcement_config: customer_managed_encryption, |
|
142 | 143 | end |
143 | 144 |
|
144 | 145 | it "knows its encryption enforcement config" do |
145 | | - _(bucket.customer_managed_encryption_enforcement_config.restriction_mode).must_equal "NotRestricted" |
146 | | - _(bucket.customer_supplied_encryption_enforcement_config.restriction_mode).must_equal "FullyRestricted" |
| 146 | + _(bucket.customer_managed_encryption_enforcement_config.restriction_mode).must_equal "FullyRestricted" |
| 147 | + _(bucket.customer_supplied_encryption_enforcement_config.restriction_mode).must_equal "NotRestricted" |
147 | 148 | _(bucket.google_managed_encryption_enforcement_config.restriction_mode).must_equal "NotRestricted" |
148 | 149 | end |
149 | 150 |
|
|
163 | 164 | mock.expect :patch_bucket, returned_bucket_gapi, [bucket_name, patch_bucket_gapi], **patch_bucket_args(options: { retries: 0 }) |
164 | 165 |
|
165 | 166 | bucket.service.mocked_service = mock |
166 | | - _(bucket.customer_managed_encryption_enforcement_config.restriction_mode).must_equal "NotRestricted" |
167 | | - _(bucket.customer_supplied_encryption_enforcement_config.restriction_mode).must_equal "FullyRestricted" |
| 167 | + _(bucket.customer_managed_encryption_enforcement_config.restriction_mode).must_equal "FullyRestricted" |
| 168 | + _(bucket.customer_supplied_encryption_enforcement_config.restriction_mode).must_equal "NotRestricted" |
168 | 169 | _(bucket.google_managed_encryption_enforcement_config.restriction_mode).must_equal "NotRestricted" |
169 | 170 |
|
170 | 171 | bucket.update_bucket_encryption_enforcement_config incoming_config |
171 | | - _(bucket.customer_managed_encryption_enforcement_config.restriction_mode).must_equal "NotRestricted" |
172 | | - _(bucket.customer_supplied_encryption_enforcement_config.restriction_mode).must_equal "FullyRestricted" |
| 172 | + _(bucket.customer_managed_encryption_enforcement_config.restriction_mode).must_equal "FullyRestricted" |
| 173 | + _(bucket.customer_supplied_encryption_enforcement_config.restriction_mode).must_equal "NotRestricted" |
173 | 174 | _(bucket.google_managed_encryption_enforcement_config.restriction_mode).must_equal "FullyRestricted" |
174 | 175 |
|
175 | 176 | mock.verify |
|
0 commit comments