get_alt_client,
get_iam_client,
get_iam_root_client,
+ get_iam_root_account_id,
get_iam_alt_root_client,
get_iam_alt_root_user_id,
get_iam_alt_root_email,
+ get_iam_alt_root_account_id,
make_iam_name,
get_iam_path_prefix,
get_new_bucket,
s3_main = get_iam_root_client(service_name='s3')
response = s3_main.get_bucket_acl(Bucket=bucket_name)
- main_arn = iam_root.get_user()['User']['Arn']
- account_id = main_arn.removeprefix('arn:aws:iam::').removesuffix(':root')
+ account_id = get_iam_root_account_id()
assert response['Owner']['ID'] == account_id
assert response['Grants'][0]['Grantee']['ID'] == account_id
roots3 = get_iam_root_client(service_name='s3')
path = get_iam_path_prefix()
user_name = make_iam_name('AltUser')
- response = iam_alt_root.create_user(UserName=user_name, Path=path)
- user_arn = response['User']['Arn']
- account_id = user_arn.removeprefix('arn:aws:iam::').removesuffix(f':user{path}{user_name}')
+ iam_alt_root.create_user(UserName=user_name, Path=path)
+
+ account_id = get_iam_alt_root_account_id()
_test_cross_account_user_bucket_policy(roots3, iam_alt_root, user_name, account_id)
@pytest.mark.iam_account
roots3 = get_iam_root_client(service_name='s3')
path = get_iam_path_prefix()
user_name = make_iam_name('AltUser')
- response = iam_alt_root.create_user(UserName=user_name, Path=path)
- user_arn = response['User']['Arn']
- account_id = user_arn.removeprefix('arn:aws:iam::').removesuffix(f':user{path}{user_name}')
+ iam_alt_root.create_user(UserName=user_name, Path=path)
+
+ account_id = get_iam_alt_root_account_id()
_test_cross_account_bucket_user_policy(roots3, iam_alt_root, user_name, account_id)
def test_cross_account_root_bucket_policy_allow_account_id(iam_root, iam_alt_root):
roots3 = get_iam_root_client(service_name='s3')
alts3 = get_iam_alt_root_client(service_name='s3')
- alt_arn = iam_alt_root.get_user()['User']['Arn']
- account_id = alt_arn.removeprefix('arn:aws:iam::').removesuffix(':root')
+
+ account_id = get_iam_alt_root_account_id()
_test_cross_account_root_bucket_policy(roots3, alts3, account_id)
# test root cross-account access with bucket acls