Skip to content

Commit 69fbef7

Browse files
committed
test(s3): preserve replicated policy after invalid replacements
1 parent e8aa07a commit 69fbef7

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎scripts/validation_replication/replication_behavior.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2652,6 +2652,21 @@ def policy_probe() -> tuple[bool, Any]:
26522652
return observed == source_policy, observed
26532653

26542654
replicated = self.wait_until(case_id, "bucket policy replication", policy_probe)
2655+
for invalid in ("{", "[]", '["","2012-10-17",[]]'):
2656+
try:
2657+
self.client_a.put_bucket_policy(Bucket=bucket, Policy=invalid)
2658+
except ClientError as exc:
2659+
code = exc.response["Error"]["Code"]
2660+
status = exc.response["ResponseMetadata"]["HTTPStatusCode"]
2661+
if (status, code) != (400, "MalformedPolicy"):
2662+
raise AssertionError(f"invalid bucket policy returned {status} {code}") from exc
2663+
else:
2664+
raise AssertionError("invalid bucket policy was accepted")
2665+
observed = json.loads(self.client_a.get_bucket_policy(Bucket=bucket)["Policy"])
2666+
if observed != source_policy:
2667+
raise AssertionError("a rejected write changed the source bucket policy")
2668+
if not policy_probe()[0]:
2669+
raise AssertionError("the peer no longer has the original bucket policy")
26552670
self.client_a.delete_bucket_policy(Bucket=bucket)
26562671

26572672
def delete_probe() -> tuple[bool, Any]:

0 commit comments

Comments
 (0)