当前位置: 首页>>代码示例>>Python>>正文


Python moto.mock_iam方法代码示例

本文整理汇总了Python中moto.mock_iam方法的典型用法代码示例。如果您正苦于以下问题:Python moto.mock_iam方法的具体用法?Python moto.mock_iam怎么用?Python moto.mock_iam使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在moto的用法示例。


在下文中一共展示了moto.mock_iam方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_create_service_role

# 需要导入模块: import moto [as 别名]
# 或者: from moto import mock_iam [as 别名]
def test_create_service_role(self):
        """Test create service role."""
        role_name = "ecsServiceRole"
        policy_name = "AmazonEC2ContainerServiceRolePolicy"
        with mock_iam():
            client = boto3.client("iam", region_name=REGION)

            with self.assertRaises(ClientError):
                client.get_role(RoleName=role_name)

            self.assertTrue(
                create_ecs_service_role(
                    context=self.context,
                    provider=self.provider,
                )
            )

            role = client.get_role(RoleName=role_name)

            self.assertIn("Role", role)
            self.assertEqual(role_name, role["Role"]["RoleName"])
            client.get_role_policy(
                RoleName=role_name,
                PolicyName=policy_name
            ) 
开发者ID:onicagroup,项目名称:runway,代码行数:27,代码来源:test_iam.py

示例2: test_create_service_role

# 需要导入模块: import moto [as 别名]
# 或者: from moto import mock_iam [as 别名]
def test_create_service_role(self):
        role_name = "ecsServiceRole"
        policy_name = "AmazonEC2ContainerServiceRolePolicy"
        with mock_iam():
            client = boto3.client("iam", region_name=REGION)

            with self.assertRaises(ClientError):
                client.get_role(RoleName=role_name)

            self.assertTrue(
                create_ecs_service_role(
                    context=self.context,
                    provider=self.provider,
                )
            )

            role = client.get_role(RoleName=role_name)

            self.assertIn("Role", role)
            self.assertEqual(role_name, role["Role"]["RoleName"])
            client.get_role_policy(
                RoleName=role_name,
                PolicyName=policy_name
            ) 
开发者ID:cloudtools,项目名称:stacker,代码行数:26,代码来源:test_iam.py

示例3: test_create_service_role_already_exists

# 需要导入模块: import moto [as 别名]
# 或者: from moto import mock_iam [as 别名]
def test_create_service_role_already_exists(self):
        role_name = "ecsServiceRole"
        policy_name = "AmazonEC2ContainerServiceRolePolicy"
        with mock_iam():
            client = boto3.client("iam", region_name=REGION)
            client.create_role(
                RoleName=role_name,
                AssumeRolePolicyDocument=get_ecs_assumerole_policy().to_json()
            )

            self.assertTrue(
                create_ecs_service_role(
                    context=self.context,
                    provider=self.provider,
                )
            )

            role = client.get_role(RoleName=role_name)

            self.assertIn("Role", role)
            self.assertEqual(role_name, role["Role"]["RoleName"])
            client.get_role_policy(
                RoleName=role_name,
                PolicyName=policy_name
            ) 
开发者ID:cloudtools,项目名称:stacker,代码行数:27,代码来源:test_iam.py

示例4: sh

# 需要导入模块: import moto [as 别名]
# 或者: from moto import mock_iam [as 别名]
def sh(self):
        with moto.mock_iam():
            sh = security_hub_rules.SecurityHubRules(logging)
            yield sh 
开发者ID:servian,项目名称:aws-auto-remediate,代码行数:6,代码来源:test_securityhub_iam.py

示例5: iam_client

# 需要导入模块: import moto [as 别名]
# 或者: from moto import mock_iam [as 别名]
def iam_client(aws_region):
    with mock_iam():
        yield boto3.client("iam", region_name=aws_region) 
开发者ID:apache,项目名称:airflow,代码行数:5,代码来源:test_batch_waiters.py

示例6: iam

# 需要导入模块: import moto [as 别名]
# 或者: from moto import mock_iam [as 别名]
def iam(sts, conn_dict):
    with mock_iam():
        yield boto3_cached_conn("iam", **conn_dict) 
开发者ID:Netflix-Skunkworks,项目名称:cloudaux,代码行数:5,代码来源:conftest.py

示例7: test_create_service_role_already_exists

# 需要导入模块: import moto [as 别名]
# 或者: from moto import mock_iam [as 别名]
def test_create_service_role_already_exists(self):
        """Test create service role already exists."""
        role_name = "ecsServiceRole"
        policy_name = "AmazonEC2ContainerServiceRolePolicy"
        with mock_iam():
            client = boto3.client("iam", region_name=REGION)
            client.create_role(
                RoleName=role_name,
                AssumeRolePolicyDocument=get_ecs_assumerole_policy().to_json()
            )

            self.assertTrue(
                create_ecs_service_role(
                    context=self.context,
                    provider=self.provider,
                )
            )

            role = client.get_role(RoleName=role_name)

            self.assertIn("Role", role)
            self.assertEqual(role_name, role["Role"]["RoleName"])
            client.get_role_policy(
                RoleName=role_name,
                PolicyName=policy_name
            ) 
开发者ID:onicagroup,项目名称:runway,代码行数:28,代码来源:test_iam.py

示例8: iam

# 需要导入模块: import moto [as 别名]
# 或者: from moto import mock_iam [as 别名]
def iam():
    with mock_iam():
        yield boto3.client("iam", region_name="us-east-1") 
开发者ID:Netflix-Skunkworks,项目名称:diffy,代码行数:5,代码来源:conftest.py


注:本文中的moto.mock_iam方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。