Beispiel #1
0
    def test_create_service_account(self, mock_parse_request, *args):
        params = {
            'name': utils.random_string(),
            'data': {
                'account_id': '000123456'
            },
            'provider': 'aws',
            'tags': {
                'key': 'value'
            },
            'domain_id': utils.generate_id('domain')
        }
        mock_parse_request.return_value = (params, {})

        service_account_servicer = ServiceAccount()
        service_account_info = service_account_servicer.create({}, {})

        print_message(service_account_info, 'test_create_service_account')

        self.assertIsInstance(service_account_info, service_account_pb2.ServiceAccountInfo)
        self.assertEqual(service_account_info.name, params['name'])
        self.assertDictEqual(MessageToDict(service_account_info.data), params['data'])
        self.assertDictEqual(MessageToDict(service_account_info.tags), params['tags'])
        self.assertEqual(service_account_info.domain_id, params['domain_id'])
        self.assertIsNotNone(getattr(service_account_info, 'created_at', None))
Beispiel #2
0
    def test_get_service_account(self, mock_parse_request, *args):
        mock_parse_request.return_value = ({}, {})

        service_account_servicer = ServiceAccount()
        service_account_info = service_account_servicer.get({}, {})

        print_message(service_account_info, 'test_get_service_account')

        self.assertIsInstance(service_account_info, service_account_pb2.ServiceAccountInfo)
Beispiel #3
0
    def test_delete_service_account(self, mock_parse_request, *args):
        mock_parse_request.return_value = ({}, {})

        service_account_servicer = ServiceAccount()
        service_account_info = service_account_servicer.delete({}, {})

        print_message(service_account_info, 'test_delete_service_account')

        self.assertIsInstance(service_account_info, Empty)
Beispiel #4
0
    def test_list_service_accounts(self, mock_parse_request, *args):
        mock_parse_request.return_value = ({}, {})

        service_account_servicer = ServiceAccount()
        service_accounts_info = service_account_servicer.list({}, {})

        print_message(service_accounts_info, 'test_list_service_account')

        self.assertIsInstance(service_accounts_info, service_account_pb2.ServiceAccountsInfo)
        self.assertIsInstance(service_accounts_info.results[0], service_account_pb2.ServiceAccountInfo)
        self.assertEqual(service_accounts_info.total_count, 10)
Beispiel #5
0
    def test_update_service_account(self, mock_parse_request, *args):
        params = {
            'name': utils.random_string(),
            'tags': {
                'update_key': 'update_value'
            }
        }
        mock_parse_request.return_value = (params, {})

        service_account_servicer = ServiceAccount()
        service_account_info = service_account_servicer.update({}, {})

        print_message(service_account_info, 'test_update_service_account')

        self.assertIsInstance(service_account_info, service_account_pb2.ServiceAccountInfo)
        self.assertEqual(service_account_info.name, params['name'])
        self.assertDictEqual(MessageToDict(service_account_info.tags), params['tags'])