@@ -164,7 +164,6 @@ def bucket_test_iam_permissions(client, _preconditions, **resources):
164164 bucket .test_iam_permissions (permissions )
165165
166166
167- # TODO(cathyo@): issue resolved in the new testbench where buckets have a valid metageneration
168167def bucket_lock_retention_policy (client , _preconditions , ** resources ):
169168 bucket = client .bucket (resources .get ("bucket" ).name )
170169 bucket .retention_period = 60
@@ -222,8 +221,8 @@ def client_get_service_account_email(client, _preconditions, **_):
222221 client .get_service_account_email ()
223222
224223
225- def bucket_patch (client , _preconditions , ** _ ):
226- bucket = client .get_bucket ("bucket" )
224+ def bucket_patch (client , _preconditions , ** resources ):
225+ bucket = client .get_bucket (resources . get ( "bucket" ). name )
227226 metageneration = bucket .metageneration
228227 bucket .storage_class = "COLDLINE"
229228 if _preconditions :
@@ -233,7 +232,7 @@ def bucket_patch(client, _preconditions, **_):
233232
234233
235234def bucket_update (client , _preconditions , ** resources ):
236- bucket = client .get_bucket ("bucket" )
235+ bucket = client .get_bucket (resources . get ( "bucket" ). name )
237236 metageneration = bucket .metageneration
238237 bucket ._properties = {"storageClass" : "STANDARD" }
239238 if _preconditions :
@@ -252,6 +251,8 @@ def bucket_set_iam_policy(client, _preconditions, **resources):
252251 if _preconditions :
253252 bucket .set_iam_policy (policy )
254253 else :
254+ # IAM policies have no metageneration: clear ETag to avoid checking that it matches.
255+ policy .etag = None
255256 bucket .set_iam_policy (policy )
256257
257258
@@ -311,7 +312,7 @@ def blob_update(client, _preconditions, **resources):
311312def bucket_copy_blob (client , _preconditions , ** resources ):
312313 object = resources .get ("object" )
313314 bucket = client .bucket (resources .get ("bucket" ).name )
314- destination = client .bucket ( "bucket" )
315+ destination = client .create_bucket ( uuid . uuid4 (). hex )
315316 if _preconditions :
316317 bucket .copy_blob (
317318 object , destination , new_name = uuid .uuid4 ().hex , if_generation_match = 0
@@ -443,8 +444,8 @@ def blob_create_resumable_upload_session(client, _preconditions, **resources):
443444 "storage.buckets.getIamPolicy" : [bucket_get_iam_policy ],
444445 "storage.buckets.insert" : [client_create_bucket , bucket_create ],
445446 "storage.buckets.list" : [client_list_buckets ],
446- "storage.buckets.lockRententionPolicy " : [],
447- "storage.buckets.testIamPermission " : [bucket_test_iam_permissions ],
447+ "storage.buckets.lockRetentionPolicy " : [bucket_lock_retention_policy ],
448+ "storage.buckets.testIamPermissions " : [bucket_test_iam_permissions ],
448449 "storage.notifications.delete" : [notification_delete ],
449450 "storage.notifications.get" : [
450451 bucket_get_notification ,
@@ -466,15 +467,14 @@ def blob_create_resumable_upload_session(client, _preconditions, **resources):
466467 bucket_list_blobs ,
467468 bucket_delete ,
468469 ], # S1 end
469- "storage.buckets.patch" : [bucket_patch ], # S2 start
470+ "storage.buckets.patch" : [bucket_patch ], # S2/S3 start
470471 "storage.buckets.setIamPolicy" : [bucket_set_iam_policy ],
471472 "storage.buckets.update" : [bucket_update ],
472473 "storage.objects.compose" : [blob_compose ],
473474 "storage.objects.copy" : [bucket_copy_blob , bucket_rename_blob ],
474475 "storage.objects.delete" : [
475476 bucket_delete_blob ,
476477 bucket_delete_blobs ,
477- bucket_delete ,
478478 blob_delete ,
479479 bucket_rename_blob ,
480480 ],
@@ -487,7 +487,7 @@ def blob_create_resumable_upload_session(client, _preconditions, **resources):
487487 ],
488488 "storage.objects.patch" : [blob_patch ],
489489 "storage.objects.rewrite" : [blob_rewrite , blob_update_storage_class ],
490- "storage.objects.update" : [blob_update ], # S2 end
490+ "storage.objects.update" : [blob_update ], # S2/S3 end
491491}
492492
493493
0 commit comments