Beispiel #1
0
 def test_context_api_v3(self, mock_config, mock_get_host_ip, mock_unit_get,
                         mock_determine_api_port,
                         mock_IdentityServiceContext, mock_relation_ids,
                         mock_related_units, mock_relation_get,
                         mock_leader_get, mock_os_release):
     _relinfo = {
         'auth_protocol': 'http',
         'service_protocol': 'http',
         'auth_host': 'kshost',
         'service_host': 'kshost',
         'auth_port': '5000',
         'service_username': '******',
         'service_password': '******',
         'service_domain': 'service_domain',
         'service_tenant': 'svctenant',
         'service_port': 'svcport',
         'api_version': '3',
         'admin_domain_id': 'admin_dom_id',
         'service_tenant_id': 'svc_tenant_id',
     }
     self.maxDiff = None
     mock_relation_ids.return_value = ['rid1']
     mock_related_units.return_value = ['ksunit/0']
     mock_relation_get.side_effect = lambda x, y, z: _relinfo[x]
     mock_config.return_value = None
     mock_os_release.return_value = 'queens'
     ctxt = swift_context.SwiftIdentityContext()
     self.assertEqual(ctxt()['api_version'], '3')
     self.assertEqual(ctxt()['admin_domain_id'], 'admin_dom_id')
     self.assertEqual(ctxt()['service_tenant_id'], 'svc_tenant_id')
     self.assertEqual(ctxt()['admin_domain_name'], 'service_domain')
     self.assertEqual(ctxt()['admin_tenant_name'], 'svctenant')
Beispiel #2
0
 def test_context_api_v2(self, mock_config, mock_get_host_ip, mock_unit_get,
                         mock_determine_api_port,
                         mock_IdentityServiceContext, mock_relation_ids,
                         mock_related_units, mock_relation_get,
                         mock_leader_get):
     _relinfo = {
         'auth_protocol': 'http',
         'service_protocol': 'http',
         'auth_host': 'kshost',
         'service_host': 'kshost',
         'auth_port': '5000',
         'service_username': '******',
         'service_password': '******',
         'service_tenant': 'svctenant',
         'service_port': 'svcport',
         'admin_token': 'token',
         'api_version': None,
     }
     mock_config.return_value = None
     mock_relation_ids.return_value = ['rid1']
     mock_related_units.return_value = ['ksunit/0']
     mock_relation_get.side_effect = lambda x, y, z: _relinfo[x]
     ctxt = swift_context.SwiftIdentityContext()
     self.assertEqual(ctxt()['api_version'], '2')