Skip to content

Commit f8a44d9

Browse files
committed
test/rgw/multisite: test error handling of forwarded s3:PutBucketPolicy
PutBucketPolicy doesn't parse the given policy until after it's forwarded and applied on the master zone, so add a test that sends a non-json policy document that will fail to parse without the fix to rgw_forward_request_to_master(), the InvalidArgument error Code is still mapped correctly, but the error Message is not preserved: > assert e.response['Error']['Message'] > AssertionError Signed-off-by: Casey Bodley <[email protected]>
1 parent 3e9faa4 commit f8a44d9

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/test/rgw/rgw_multi/tests.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2210,6 +2210,27 @@ def test_role_delete_sync():
22102210
zone.iam_conn.get_role, RoleName=role_name)
22112211
log.info(f'success, zone: {zone.name} does not have role: {role_name}')
22122212

2213+
def test_forwarded_put_bucket_policy_error():
2214+
zonegroup = realm.master_zonegroup()
2215+
zonegroup_conns = ZonegroupConns(zonegroup)
2216+
primary = zonegroup_conns.rw_zones[0]
2217+
2218+
# create a bucket that blocks public policy
2219+
bucket = gen_bucket_name()
2220+
primary.create_bucket(bucket)
2221+
realm_meta_checkpoint(realm)
2222+
2223+
# try to write a policy that can't be parsed
2224+
policy = 'Invalid policy document'
2225+
try:
2226+
for zone in zonegroup_conns.rw_zones:
2227+
e = assert_raises(ClientError, zone.s3_client.put_bucket_policy,
2228+
Bucket=bucket, Policy=policy)
2229+
eq(e.response['Error']['Code'], 'InvalidArgument')
2230+
assert e.response['Error']['Message']
2231+
finally:
2232+
zonegroup_conns.rw_zones[0].delete_bucket(bucket)
2233+
realm_meta_checkpoint(realm)
22132234

22142235
def test_replication_status():
22152236
zonegroup = realm.master_zonegroup()

0 commit comments

Comments
 (0)