mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-10-09 21:14:22 +00:00
fix(tests_iam): AWS managed policies are isolated (#8609)
Co-authored-by: MustafaAamir <mustafa@gmail.com> Co-authored-by: Pepe Fagoaga <pepe@prowler.com>
This commit is contained in:
co-authored by
MustafaAamir
Pepe Fagoaga
parent
ec0341c696
commit
2a4b62527a
@@ -7,7 +7,7 @@ from freezegun import freeze_time
|
||||
from mock import patch
|
||||
from moto import mock_aws
|
||||
|
||||
from prowler.providers.aws.services.iam.iam_service import IAM, Policy, is_service_role
|
||||
from prowler.providers.aws.services.iam.iam_service import IAM, is_service_role
|
||||
from tests.providers.aws.utils import (
|
||||
AWS_ACCOUNT_NUMBER,
|
||||
AWS_REGION_US_EAST_1,
|
||||
@@ -871,18 +871,14 @@ nTTxU4a7x1naFxzYXK1iQ1vMARKMjDb19QEJIEJKZlDK4uS7yMlf1nFS
|
||||
assert iam.users[0].inline_policies == [policy_name]
|
||||
assert iam.users[0].tags == []
|
||||
|
||||
# TODO: Workaround until this gets fixed https://github.com/getmoto/moto/issues/6712
|
||||
for policy in iam.policies.values():
|
||||
if policy.name == policy_name:
|
||||
assert policy == Policy(
|
||||
name=policy_name,
|
||||
arn=user_arn,
|
||||
version_id="v1",
|
||||
type="Inline",
|
||||
attached=True,
|
||||
document=INLINE_POLICY_NOT_ADMIN,
|
||||
entity=user_name,
|
||||
)
|
||||
policy = iam.policies[f"{user_arn}:policy/{policy_name}"]
|
||||
assert policy.name == policy_name
|
||||
assert policy.arn == user_arn
|
||||
assert policy.version_id == "v1"
|
||||
assert policy.type == "Inline"
|
||||
assert policy.attached
|
||||
assert policy.document == INLINE_POLICY_NOT_ADMIN
|
||||
assert policy.entity == user_name
|
||||
|
||||
# Test IAM Group Inline Policy
|
||||
@mock_aws
|
||||
@@ -913,18 +909,14 @@ nTTxU4a7x1naFxzYXK1iQ1vMARKMjDb19QEJIEJKZlDK4uS7yMlf1nFS
|
||||
assert iam.groups[0].inline_policies == [policy_name]
|
||||
assert iam.groups[0].users == []
|
||||
|
||||
# TODO: Workaround until this gets fixed https://github.com/getmoto/moto/issues/6712
|
||||
for policy in iam.policies.values():
|
||||
if policy.name == policy_name:
|
||||
assert policy == Policy(
|
||||
name=policy_name,
|
||||
arn=group_arn,
|
||||
version_id="v1",
|
||||
type="Inline",
|
||||
attached=True,
|
||||
document=INLINE_POLICY_NOT_ADMIN,
|
||||
entity=group_name,
|
||||
)
|
||||
policy = iam.policies[f"{group_arn}:policy/{policy_name}"]
|
||||
assert policy.name == policy_name
|
||||
assert policy.arn == group_arn
|
||||
assert policy.version_id == "v1"
|
||||
assert policy.type == "Inline"
|
||||
assert policy.attached
|
||||
assert policy.document == INLINE_POLICY_NOT_ADMIN
|
||||
assert policy.entity == group_name
|
||||
|
||||
# Test IAM Role Inline Policy
|
||||
@mock_aws
|
||||
@@ -959,18 +951,14 @@ nTTxU4a7x1naFxzYXK1iQ1vMARKMjDb19QEJIEJKZlDK4uS7yMlf1nFS
|
||||
assert iam.roles[0].inline_policies == [policy_name]
|
||||
assert iam.roles[0].tags == []
|
||||
|
||||
# TODO: Workaround until this gets fixed https://github.com/getmoto/moto/issues/6712
|
||||
for policy in iam.policies.values():
|
||||
if policy.name == policy_name:
|
||||
assert policy == Policy(
|
||||
name=policy_name,
|
||||
arn=role_arn,
|
||||
version_id="v1",
|
||||
type="Inline",
|
||||
attached=True,
|
||||
document=INLINE_POLICY_NOT_ADMIN,
|
||||
entity=role_name,
|
||||
)
|
||||
policy = iam.policies[f"{role_arn}:policy/{policy_name}"]
|
||||
assert policy.name == policy_name
|
||||
assert policy.arn == role_arn
|
||||
assert policy.version_id == "v1"
|
||||
assert policy.type == "Inline"
|
||||
assert policy.attached
|
||||
assert policy.document == INLINE_POLICY_NOT_ADMIN
|
||||
assert policy.entity == role_name
|
||||
|
||||
# Test IAM List Attached Group Policies
|
||||
@mock_aws
|
||||
|
||||
Reference in New Issue
Block a user