コード例 #1
0
    def test_create_service_account_invalid_data(self, *args):
        params = {
            'name': 'SpaceONE',
            'provider': 'aws',
            'data': {
                'account_id2': '000321654'
            },
            'domain_id': utils.generate_id('domain')
        }

        self.transaction.method = 'create'
        service_account_svc = ServiceAccountService(
            transaction=self.transaction)

        with self.assertRaises(ERROR_INVALID_PARAMETER):
            service_account_svc.create_service_account(params)
コード例 #2
0
    def test_create_service_account(self, *args):
        params = {
            'name': 'SpaceONE',
            'provider': 'aws',
            'data': {
                'account_id': '000321654'
            },
            'tags': {
                'key': 'value'
            },
            'domain_id': utils.generate_id('domain')
        }

        self.transaction.method = 'create'
        service_account_svc = ServiceAccountService(
            transaction=self.transaction)
        service_account_vo = service_account_svc.create_service_account(
            params.copy())

        print_data(service_account_vo.to_dict(), 'test_create_service_account')
        ServiceAccountInfo(service_account_vo)

        self.assertIsInstance(service_account_vo, ServiceAccount)
        self.assertEqual(params['name'], service_account_vo.name)
        self.assertEqual(params['provider'], service_account_vo.provider)
        self.assertEqual(params['domain_id'], service_account_vo.domain_id)
        self.assertEqual(params.get('data', {}), service_account_vo.data)
        self.assertEqual(params.get('tags', {}), service_account_vo.tags)
コード例 #3
0
    def test_create_service_account_with_project(self, *args):
        params = {
            'name': 'SpaceONE',
            'provider': 'aws',
            'data': {
                'account_id': '000321654'
            },
            'project_id': self.project_id,
            'domain_id': self.domain_id
        }

        self.transaction.method = 'create'
        service_account_svc = ServiceAccountService(
            transaction=self.transaction)
        service_account_vo = service_account_svc.create_service_account(
            params.copy())

        print_data(service_account_vo.to_dict(),
                   'test_create_service_account_with_project')
        ServiceAccountInfo(service_account_vo)

        self.assertIsInstance(service_account_vo, ServiceAccount)
        self.assertIsInstance(service_account_vo.project, Project)
        self.assertEqual(service_account_vo.project.project_id,
                         params['project_id'])
コード例 #4
0
    def test_delete_project_exist_service_account(self, *args):
        params = {
            'name': 'SpaceONE',
            'provider': 'aws',
            'data': {
                'account_id': '000321654'
            },
            'project_id': self.project_id,
            'domain_id': self.domain_id
        }

        self.transaction.method = 'create'
        service_account_svc = ServiceAccountService(
            transaction=self.transaction)
        service_account_vo = service_account_svc.create_service_account(
            params.copy())
        ServiceAccountInfo(service_account_vo)

        with self.assertRaises(ERROR_EXIST_RESOURCE):
            self.project_vo.delete()