Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions s3tests/functional/test_iam.py
Original file line number Diff line number Diff line change
Expand Up @@ -1962,6 +1962,27 @@ def test_account_role_update(iam_root):
}]
})

@pytest.mark.iam_account
@pytest.mark.iam_role
def test_account_role_list_permission(iam_root):
path = get_iam_path_prefix()
user_name = make_iam_name('MyUser')

user = iam_root.create_user(UserName=user_name, Path=path)['User']
user_arn = user['Arn']

key = iam_root.create_access_key(UserName=user_name)['AccessKey']
iam_client = get_iam_client(aws_access_key_id=key['AccessKeyId'],
aws_secret_access_key=key['SecretAccessKey'])

# reject ListRoles due to lack of identity policy
e = assert_raises(ClientError, iam_client.list_roles, PathPrefix=path)
assert (403, 'AccessDenied') == _get_status_and_error_code(e.response)

iam_root.attach_user_policy(UserName=user_name, PolicyArn='arn:aws:iam::aws:policy/IAMReadOnlyAccess')

iam_client.list_roles(PathPrefix=path)

# IAM RolePolicy apis
@pytest.mark.iam_account
@pytest.mark.iam_role
Expand Down