Skip to content

Commit e704129

Browse files
clwluvwcbodley
authored andcommitted
qa/rgw: add perm check test for copy obj between zonegroups
Make sure perms are evaluated properly for the source object. Signed-off-by: Seena Fallah <[email protected]> (cherry picked from commit 9523e15)
1 parent 6f11632 commit e704129

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

src/test/rgw/rgw_multi/tests.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5764,7 +5764,7 @@ def test_bucket_replication_source_forbidden_getobjecttagging():
57645764
'Version': '2012-10-17',
57655765
'Statement': [{
57665766
'Effect': 'Deny',
5767-
'Principal': {'AWS': [f"arn:aws:iam:::user/{user.id}"]},
5767+
'Principal': {'AWS': [f"arn:aws:iam:::user/{non_account_user.id}"]},
57685768
'Action': 's3:GetObjectTagging',
57695769
'Resource': f'arn:aws:s3:::{source_bucket.name}/*',
57705770
}]
@@ -5821,7 +5821,7 @@ def test_bucket_replication_source_forbidden_getobjectversiontagging():
58215821
'Version': '2012-10-17',
58225822
'Statement': [{
58235823
'Effect': 'Deny',
5824-
'Principal': {'AWS': [f"arn:aws:iam:::user/{user.id}"]},
5824+
'Principal': {'AWS': [f"arn:aws:iam:::user/{non_account_user.id}"]},
58255825
'Action': 's3:GetObjectVersionTagging',
58265826
'Resource': f'arn:aws:s3:::{source_bucket.name}/*',
58275827
}]
@@ -5838,3 +5838,30 @@ def test_bucket_replication_source_forbidden_getobjectversiontagging():
58385838
res = dest.s3_client.get_object(Bucket=dest_bucket.name, Key=objname)
58395839
assert_equal(res['Body'].read().decode('utf-8'), 'foo')
58405840
assert 'TagCount' not in res
5841+
5842+
@run_per_zonegroup
5843+
def test_copy_obj_perm_check_between_zonegroups(zonegroup):
5844+
if len(realm.current_period.zonegroups) < 2:
5845+
raise SkipTest('need at least 2 zonegroups to run this test')
5846+
5847+
source_zone = ZonegroupConns(zonegroup).rw_zones[0]
5848+
source_bucket = source_zone.create_bucket(gen_bucket_name())
5849+
5850+
objname = 'dummy'
5851+
k = new_key(source_zone, source_bucket.name, objname)
5852+
k.set_contents_from_string('foo')
5853+
5854+
for zg in realm.current_period.zonegroups:
5855+
if zg.name == zonegroup.name:
5856+
continue
5857+
5858+
dest_zone = ZonegroupConns(zg).non_account_alt_rw_zones[0]
5859+
dest_bucket = dest_zone.create_bucket(gen_bucket_name())
5860+
realm_meta_checkpoint(realm)
5861+
5862+
# copy object returns 403
5863+
e = assert_raises(ClientError, dest_zone.s3_client.copy_object,
5864+
Bucket=dest_bucket.name,
5865+
CopySource={'Bucket': source_bucket.name, 'Key': objname},
5866+
Key=objname)
5867+
assert e.response['Error']['Code'] == 'AccessDenied'

0 commit comments

Comments
 (0)