From 690db41d2b31dcd83c6b7159b941cb2208d3877c Mon Sep 17 00:00:00 2001 From: Chandra Sirimala Date: Wed, 20 Aug 2025 15:08:16 +0000 Subject: [PATCH 1/4] fix: test_blob_acl_w_metageneration_match --- tests/system/test_blob.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/tests/system/test_blob.py b/tests/system/test_blob.py index 8b50322ba..b600a0011 100644 --- a/tests/system/test_blob.py +++ b/tests/system/test_blob.py @@ -409,6 +409,7 @@ def test_blob_acl_w_user_project( assert not acl.has_entity("allUsers") +# error def test_blob_acl_w_metageneration_match( shared_bucket, blobs_to_delete, @@ -425,28 +426,28 @@ def test_blob_acl_w_metageneration_match( # Exercise blob ACL with metageneration/generation match acl = blob.acl - blob.reload() + acl.domain("google.com").grant_read() + # blob.reload() with pytest.raises(exceptions.PreconditionFailed): - acl.save_predefined( - "publicRead", if_metageneration_match=wrong_metageneration_number - ) - assert "READER" not in acl.all().get_roles() + acl.save(if_metageneration_match=wrong_metageneration_number) + assert "READER" not in acl.domain("google.com").get_roles() - acl.save_predefined("publicRead", if_metageneration_match=blob.metageneration) - assert "READER" in acl.all().get_roles() + acl.save(if_metageneration_match=blob.metageneration) - blob.reload() - del acl.entities["allUsers"] + assert "READER" in acl.domain("google.com").get_roles() + # blob.reload() + acl.domain("google.com").revoke_read() with pytest.raises(exceptions.PreconditionFailed): acl.save(if_generation_match=wrong_generation_number) - assert acl.has_entity("allUsers") + assert "READER" in acl.domain("google.com").get_roles() acl.save(if_generation_match=blob.generation) - assert not acl.has_entity("allUsers") + assert "READER" not in acl.domain("google.com").get_roles() +# error def test_blob_acl_upload_predefined( shared_bucket, blobs_to_delete, From a622da1fb22996fd2f1a3de543acb4af03cccf7c Mon Sep 17 00:00:00 2001 From: Chandra Sirimala Date: Wed, 20 Aug 2025 18:26:44 +0000 Subject: [PATCH 2/4] fix: test_blob_acl_upload_predefined --- tests/system/test_blob.py | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/tests/system/test_blob.py b/tests/system/test_blob.py index b600a0011..6951a3618 100644 --- a/tests/system/test_blob.py +++ b/tests/system/test_blob.py @@ -454,31 +454,33 @@ def test_blob_acl_upload_predefined( file_data, service_account, ): - control = shared_bucket.blob(f"logo{uuid.uuid4().hex}") - control_info = file_data["logo"] + control_blob = shared_bucket.blob(f"logo{uuid.uuid4().hex}") + control_blob_info = file_data["logo"] blob = shared_bucket.blob(f"SmallFile{uuid.uuid4().hex}") info = file_data["simple"] try: - control.upload_from_filename(control_info["path"]) + control_blob.upload_from_filename(control_blob_info["path"]) finally: - blobs_to_delete.append(control) - + blobs_to_delete.append(control_blob) try: - blob.upload_from_filename(info["path"], predefined_acl="publicRead") + blob.upload_from_filename(info["path"], predefined_acl="private") finally: blobs_to_delete.append(blob) - control_acl = control.acl - assert "READER" not in control_acl.all().get_roles() + control_blob_acl = control_blob.acl acl = blob.acl - assert "READER" in acl.all().get_roles() - - acl.all().revoke_read() - assert acl.all().get_roles() == set() - assert control_acl.all().get_roles() == acl.all().get_roles() + count = 0 + for entry in acl: + count += 1 + entity = entry["entity"] + assert count == 1 + assert entity.lstrip("user-") == service_account.service_account_email + # assert sum(1 for _ in acl) == 1 + + assert sum(1 for _ in control_blob_acl) > 1 def test_blob_patch_metadata( From 56705d81eae3c3794cb2b362858f20ddc3796885 Mon Sep 17 00:00:00 2001 From: Chandra Sirimala Date: Wed, 20 Aug 2025 19:12:16 +0000 Subject: [PATCH 3/4] remove unwanted comments and code --- tests/system/test_blob.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/system/test_blob.py b/tests/system/test_blob.py index 6951a3618..15945745e 100644 --- a/tests/system/test_blob.py +++ b/tests/system/test_blob.py @@ -409,7 +409,6 @@ def test_blob_acl_w_user_project( assert not acl.has_entity("allUsers") -# error def test_blob_acl_w_metageneration_match( shared_bucket, blobs_to_delete, @@ -447,7 +446,6 @@ def test_blob_acl_w_metageneration_match( assert "READER" not in acl.domain("google.com").get_roles() -# error def test_blob_acl_upload_predefined( shared_bucket, blobs_to_delete, @@ -478,7 +476,6 @@ def test_blob_acl_upload_predefined( entity = entry["entity"] assert count == 1 assert entity.lstrip("user-") == service_account.service_account_email - # assert sum(1 for _ in acl) == 1 assert sum(1 for _ in control_blob_acl) > 1 From a36b03008ce6f19d30e336659be2dcd5ffd9f8b2 Mon Sep 17 00:00:00 2001 From: Chandra Sirimala Date: Wed, 20 Aug 2025 19:13:23 +0000 Subject: [PATCH 4/4] remove unwanted code --- tests/system/test_blob.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/system/test_blob.py b/tests/system/test_blob.py index 15945745e..a421fb2e4 100644 --- a/tests/system/test_blob.py +++ b/tests/system/test_blob.py @@ -426,7 +426,6 @@ def test_blob_acl_w_metageneration_match( # Exercise blob ACL with metageneration/generation match acl = blob.acl acl.domain("google.com").grant_read() - # blob.reload() with pytest.raises(exceptions.PreconditionFailed): acl.save(if_metageneration_match=wrong_metageneration_number) @@ -435,7 +434,6 @@ def test_blob_acl_w_metageneration_match( acl.save(if_metageneration_match=blob.metageneration) assert "READER" in acl.domain("google.com").get_roles() - # blob.reload() acl.domain("google.com").revoke_read() with pytest.raises(exceptions.PreconditionFailed):