Ejemplo n.º 1
0
    def test_attach_to_AccessKey(self):
        _source_ctx, _target_ctx, _ctx = self._create_common_relationships(
            'test_attach_to', USER_TH,
            ['cloudify.nodes.Root', 'cloudify.nodes.aws.iam.AccessKey'])
        current_ctx.set(_ctx)

        self.fake_client.create_access_key = MagicMock(
            return_value={
                'AccessKey': {
                    'AccessKeyId': 'aws_access_key_id',
                    'SecretAccessKey': 'aws_secret_access_key'
                }
            })

        user.attach_to(ctx=_ctx, resource_config=None, iface=None)

        self.fake_client.create_access_key.assert_called_with(
            UserName='******')

        self.assertEqual(
            _source_ctx.instance.runtime_properties, {
                '_set_changed': True,
                'aws_resource_id': 'aws_resource_mock_id',
                'resource_config': {},
                'resource_id': 'prepare_attach_source'
            })

        self.assertEqual(
            _target_ctx.instance.runtime_properties, {
                'SecretAccessKey': 'aws_secret_access_key',
                'aws_resource_arn': 'aws_resource_mock_arn',
                'aws_resource_id': 'aws_access_key_id',
                'resource_id': 'prepare_attach_target'
            })
Ejemplo n.º 2
0
    def test_attach_to_LoginProfile_Create(self):
        _source_ctx, _target_ctx, _ctx = self._create_common_relationships(
            'test_attach_to', USER_TH,
            ['cloudify.nodes.Root', 'cloudify.nodes.aws.iam.LoginProfile'])
        current_ctx.set(_ctx)

        self.fake_client.create_login_profile = MagicMock(return_value={})

        user.attach_to(ctx=_ctx, resource_config=None, iface=None)

        self.fake_client.create_login_profile.assert_called_with(
            UserName='******')

        self.assertEqual(
            _source_ctx.instance.runtime_properties, {
                '_set_changed': True,
                'aws_resource_id': 'aws_resource_mock_id',
                'resource_config': {},
                'resource_id': 'prepare_attach_source'
            })