# Path: tests/test_commands.py
# ROLE_POLICIES = {
#     "all_services_used": {
#         "iam_perms": {
#             "Version": "2012-10-17",
#             "Statement": [
#                 {
#                     "Action": ["iam:AddRoleToInstanceProfile", "iam:AttachRolePolicy"],
#                     "Resource": ["*"],
#                     "Effect": "Allow",
#                 }
#             ],
#         },
#         "s3_perms": {
#             "Version": "2012-10-17",
#             "Statement": [
#                 {
#                     "Action": ["s3:CreateBucket", "s3:DeleteBucket"],
#                     "Resource": ["*"],
#                     "Effect": "Allow",
#                 }
#             ],
#         },
#     },
#     "unused_ec2": {
#         "iam_perms": {
#             "Version": "2012-10-17",
#             "Statement": [
#                 {
#                     "Action": ["iam:AddRoleToInstanceProfile", "iam:AttachRolePolicy"],
#                     "Resource": ["*"],
#                     "Effect": "Allow",
#                 }
#             ],
#         },
#         "ec2_perms": {
#             "Version": "2012-10-17",
#             "Statement": [
#                 {
#                     "Action": ["ec2:AllocateHosts", "ec2:AssociateAddress"],
#                     "Resource": ["*"],
#                     "Effect": "Allow",
#                 }
#             ],
#         },
#     },
#     "additional_unused_ec2": {
#         "iam_perms": {
#             "Version": "2012-10-17",
#             "Statement": [
#                 {
#                     "Action": ["iam:AddRoleToInstanceProfile", "iam:AttachRolePolicy"],
#                     "Resource": ["*"],
#                     "Effect": "Allow",
#                 }
#             ],
#         },
#         "ec2_perms": {
#             "Version": "2012-10-17",
#             "Statement": [
#                 {
#                     "Action": ["ec2:AllocateHosts", "ec2:AssociateAddress"],
#                     "Resource": ["*"],
#                     "Effect": "Allow",
#                 }
#             ],
#         },
#     },
#     "unused_iam": {
#         "iam_perms": {
#             "Version": "2012-10-17",
#             "Statement": [
#                 {
#                     "Action": ["iam:AddRoleToInstanceProfile", "iam:AttachRolePolicy"],
#                     "Resource": ["*"],
#                     "Effect": "Allow",
#                 }
#             ],
#         },
#         "ec2_perms": {
#             "Version": "2012-10-17",
#             "Statement": [
#                 {
#                     "Action": ["ec2:AllocateHosts", "ec2:AssociateAddress"],
#                     "Resource": ["*"],
#                     "Effect": "Allow",
#                 }
#             ],
#         },
#     },
# }


import repokid.utils.permissions
import repokid.utils.roledata
from tests.test_commands import ROLE_POLICIES
        (
            rewritten_policies,
            empty_policies,
        ) = repokid.utils.permissions.get_repoed_policy(policies, repoable_permissions)

        assert rewritten_policies == {
            "s3_perms": {
                "Version": "2012-10-17",
                "Statement": [
                    {
                        "Action": ["s3:deletebucket"],
                        "Resource": ["*"],
                        "Effect": "Allow",
                    }
                ],
            }
        }
        assert empty_policies == ["iam_perms"]

    def test_find_newly_added_permissions(self):
        old_policy = ROLE_POLICIES["all_services_used"]
        new_policy = ROLE_POLICIES["unused_ec2"]

        new_perms = repokid.utils.permissions.find_newly_added_permissions(
            old_policy, new_policy, minimize=False
        )
        assert new_perms == {"ec2:allocatehosts", "ec2:associateaddress"}

    def test_find_newly_added_permissions_minimize(self):
        old_policy = ROLE_POLICIES["all_services_used"]

# Path: tests/test_commands.py
# ROLE_POLICIES = {
#     "all_services_used": {
#         "iam_perms": {
#             "Version": "2012-10-17",
#             "Statement": [
#                 {
#                     "Action": ["iam:AddRoleToInstanceProfile", "iam:AttachRolePolicy"],
#                     "Resource": ["*"],
#                     "Effect": "Allow",
#                 }
#             ],
#         },
#         "s3_perms": {
#             "Version": "2012-10-17",
#             "Statement": [
#                 {
#                     "Action": ["s3:CreateBucket", "s3:DeleteBucket"],
#                     "Resource": ["*"],
#                     "Effect": "Allow",
#                 }
#             ],
#         },
#     },
#     "unused_ec2": {
#         "iam_perms": {
#             "Version": "2012-10-17",
#             "Statement": [
#                 {
#                     "Action": ["iam:AddRoleToInstanceProfile", "iam:AttachRolePolicy"],
#                     "Resource": ["*"],
#                     "Effect": "Allow",
#                 }
#             ],
#         },
#         "ec2_perms": {
#             "Version": "2012-10-17",
#             "Statement": [
#                 {
#                     "Action": ["ec2:AllocateHosts", "ec2:AssociateAddress"],
#                     "Resource": ["*"],
#                     "Effect": "Allow",
#                 }
#             ],
#         },
#     },
#     "additional_unused_ec2": {
#         "iam_perms": {
#             "Version": "2012-10-17",
#             "Statement": [
#                 {
#                     "Action": ["iam:AddRoleToInstanceProfile", "iam:AttachRolePolicy"],
#                     "Resource": ["*"],
#                     "Effect": "Allow",
#                 }
#             ],
#         },
#         "ec2_perms": {
#             "Version": "2012-10-17",
#             "Statement": [
#                 {
#                     "Action": ["ec2:AllocateHosts", "ec2:AssociateAddress"],
#                     "Resource": ["*"],
#                     "Effect": "Allow",
#                 }
#             ],
#         },
#     },
#     "unused_iam": {
#         "iam_perms": {
#             "Version": "2012-10-17",
#             "Statement": [
#                 {
#                     "Action": ["iam:AddRoleToInstanceProfile", "iam:AttachRolePolicy"],
#                     "Resource": ["*"],
#                     "Effect": "Allow",
#                 }
#             ],
#         },
#         "ec2_perms": {
#             "Version": "2012-10-17",
#             "Statement": [
#                 {
#                     "Action": ["ec2:AllocateHosts", "ec2:AssociateAddress"],
#                     "Resource": ["*"],
#                     "Effect": "Allow",
#                 }
#             ],
#         },
#     },
# }


# Path: tests/test_roledata.py
import repokid.utils.permissions
import repokid.utils.roledata
from tests.test_commands import ROLE_POLICIES

        (
            rewritten_policies,
            empty_policies,
        ) = repokid.utils.permissions.get_repoed_policy(policies, repoable_permissions)

        assert rewritten_policies == {
            "s3_perms": {
                "Version": "2012-10-17",
                "Statement": [
                    {
                        "Action": ["s3:deletebucket"],
                        "Resource": ["*"],
                        "Effect": "Allow",
                    }
                ],
            }
        }
        assert empty_policies == ["iam_perms"]

    def test_find_newly_added_permissions(self):
        old_policy = ROLE_POLICIES["all_services_used"]
        new_policy = ROLE_POLICIES["unused_ec2"]

        new_perms = repokid.utils.permissions.find_newly_added_permissions(
            old_policy, new_policy, minimize=False
        )
        assert new_perms == {"ec2:allocatehosts", "ec2:associateaddress"}

    def test_find_newly_added_permissions_minimize(self):
        old_policy = ROLE_POLICIES["all_services_used"]

        new_policy = ROLE_POLICIES["unused_ec2"]