當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。