Skip to content

Commit 3e9faa4

Browse files
committed
test/rgw/multisite: test error handling of forwarded iam:DeleteRole
DeleteRole's conflict handling happens after forwarding, so use test_role_delete_sync() to test that forwarded 409 Conflict errors preserve the DeleteConflict code and error message without the fix to forward_iam_request_to_master(), DeleteRole instead fails with: > botocore.exceptions.ClientError: An error occurred (BucketNotEmpty) when calling the DeleteRole operation: None Signed-off-by: Casey Bodley <[email protected]>
1 parent d80caca commit 3e9faa4

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/test/rgw/rgw_multi/tests.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2188,6 +2188,18 @@ def test_role_delete_sync():
21882188
zone.iam_conn.get_role(RoleName=role_name)
21892189
log.info(f'success, zone: {zone.name} has role: {role_name}')
21902190

2191+
# attach a role policy that prevents role deletion
2192+
policy_arn = 'arn:aws:iam::aws:policy/AmazonS3FullAccess'
2193+
zonegroup_conns.master_zone.iam_conn.attach_role_policy(RoleName=role_name, PolicyArn=policy_arn)
2194+
2195+
for zone in zonegroup_conns.zones:
2196+
e = assert_raises(zone.iam_conn.exceptions.DeleteConflictException,
2197+
zone.iam_conn.delete_role, RoleName=role_name)
2198+
assert e.response['Error']['Code'] == 'DeleteConflict'
2199+
assert e.response['Error']['Message']
2200+
2201+
zonegroup_conns.master_zone.iam_conn.detach_role_policy(RoleName=role_name, PolicyArn=policy_arn)
2202+
21912203
log.info(f"deleting role: {role_name}")
21922204
zonegroup_conns.master_zone.iam_conn.delete_role(RoleName=role_name)
21932205
zonegroup_meta_checkpoint(zonegroup)

0 commit comments

Comments
 (0)