Exemple #1
0
 def test_join_version(self):
     user_preference = filt.ServiceFilter(version='v2')
     service_default = filt.ServiceFilter()
     self.assertEqual('v2', user_preference.join(service_default).version)
     service_default = filt.ServiceFilter(
         version=filt.ServiceFilter.UNVERSIONED
     )
     self.assertEqual('', user_preference.join(service_default).version)
Exemple #2
0
 def test_match_region(self):
     sot = filt.ServiceFilter(service_type='identity')
     self.assertTrue(sot.match_region('East'))
     self.assertTrue(sot.match_region('West'))
     self.assertTrue(sot.match_region(None))
     sot = filt.ServiceFilter(service_type='identity', region='East')
     self.assertTrue(sot.match_region('East'))
     self.assertFalse(sot.match_region('West'))
     self.assertFalse(sot.match_region(None))
 def get_urls_region(self, sot):
     sf = service_filter.ServiceFilter(service_type='compute',
                                       region='RegionTwo')
     self.assertEqual(["http://compute.region2.public/v1"],
                      sot.get_urls(sf))
     sf = service_filter.ServiceFilter(service_type='compute',
                                       region='RegionOne')
     self.assertEqual(["http://compute.region1.public/v2.0"],
                      sot.get_urls(sf))
Exemple #4
0
 def test_join_interface(self):
     user_preference = filt.ServiceFilter(interface='public')
     service_default = filt.ServiceFilter(interface='admin')
     result = user_preference.join(service_default)
     self.assertEqual("public", result.interface)
     user_preference = filt.ServiceFilter(interface=None)
     service_default = filt.ServiceFilter(interface='admin')
     result = user_preference.join(service_default)
     self.assertEqual("admin", result.interface)
 def get_urls_name(self, sot):
     sf = service_filter.ServiceFilter(service_type='compute',
                                       service_name='nova')
     self.assertEqual(["http://compute.region1.public/v2.0"],
                      sot.get_urls(sf))
     sf = service_filter.ServiceFilter(service_type='compute',
                                       service_name='nova2')
     self.assertEqual(["http://compute.region2.public/v1"],
                      sot.get_urls(sf))
Exemple #6
0
 def test_join(self):
     a = filt.ServiceFilter(region='east')
     b = filt.ServiceFilter(service_type='identity')
     result = a.join(b)
     self.assertEqual("service_type=identity,interface=public,region=east",
                      six.text_type(result))
     self.assertEqual("service_type=any,interface=public,region=east",
                      six.text_type(a))
     self.assertEqual("service_type=identity,interface=public",
                      six.text_type(b))
Exemple #7
0
 def test_match_service_name(self):
     sot = filt.ServiceFilter(service_type='identity')
     self.assertTrue(sot.match_service_name('keystone'))
     self.assertTrue(sot.match_service_name('ldap'))
     self.assertTrue(sot.match_service_name(None))
     sot = filt.ServiceFilter(service_type='identity',
                              service_name='keystone')
     self.assertTrue(sot.match_service_name('keystone'))
     self.assertFalse(sot.match_service_name('ldap'))
     self.assertFalse(sot.match_service_name(None))
 def get_urls_interface(self, sot):
     sf = service_filter.ServiceFilter(service_type='identity',
                                       interface='admin')
     self.assertEqual(["http://identity.region1.admin/v1.1/123123"],
                      sot.get_urls(sf))
     sf = service_filter.ServiceFilter(service_type='identity',
                                       interface='internal')
     self.assertEqual(["http://identity.region1.internal/v1.1/123123"],
                      sot.get_urls(sf))
     sf = service_filter.ServiceFilter(service_type='identity',
                                       interface='public')
     self.assertEqual(["http://identity.region1.public/v1.1/123123"],
                      sot.get_urls(sf))
 def setUp(self):
     super(TestSession, self).setUp()
     self.xport = fakes.FakeTransport()
     self.auth = fakes.FakeAuthenticator()
     self.serv = service_filter.ServiceFilter(service_type='identity')
     self.sess = session.Session(self.xport, self.auth)
     self.expected = {'headers': {'X-Auth-Token': self.auth.TOKEN}}
Exemple #10
0
 def test_set_interface(self):
     sot = filt.ServiceFilter()
     sot.set_interface("PUBLICURL")
     self.assertEqual('public', sot.interface)
     sot.set_interface("INTERNALURL")
     self.assertEqual('internal', sot.interface)
     sot.set_interface("ADMINURL")
     self.assertEqual('admin', sot.interface)
Exemple #11
0
 def check(self):
     try:
         self.conn.authenticator.get_endpoint(
             self.conn.transport,
             service_filter.ServiceFilter(**kwargs))
         return method(self)
     except exceptions.EndpointNotFound as exc:
         self.skip(exc.message)
Exemple #12
0
 def test_interface(self):
     sot = filt.ServiceFilter(service_type='identity', interface='public')
     self.assertEqual("service_type=identity,interface=public",
                      six.text_type(sot))
     sot = filt.ServiceFilter(service_type='identity',
                              interface='internal')
     self.assertEqual("service_type=identity,interface=internal",
                      six.text_type(sot))
     sot = filt.ServiceFilter(service_type='identity', interface='admin')
     self.assertEqual("service_type=identity,interface=admin",
                      six.text_type(sot))
     sot = filt.ServiceFilter(service_type='identity',
                              interface='publicURL')
     self.assertEqual("service_type=identity,interface=public",
                      six.text_type(sot))
     sot = filt.ServiceFilter(service_type='identity',
                              interface='internalURL')
     self.assertEqual("service_type=identity,interface=internal",
                      six.text_type(sot))
     sot = filt.ServiceFilter(service_type='identity',
                              interface='adminURL')
     self.assertEqual("service_type=identity,interface=admin",
                      six.text_type(sot))
     self.assertRaises(exceptions.SDKException, filt.ServiceFilter,
                       service_type='identity', interface='b')
     sot = filt.ServiceFilter(service_type='identity', interface=None)
     self.assertEqual("service_type=identity", six.text_type(sot))
Exemple #13
0
 def test_init(self):
     sot = service_filter.ServiceFilter(
         'ServiceType', region='REGION1', service_name='ServiceName',
         version='1', api_version='1.23', requires_project_id=True)
     self.assertEqual('servicetype', sot.service_type)
     self.assertEqual('REGION1', sot.region)
     self.assertEqual('ServiceName', sot.service_name)
     self.assertEqual('1', sot.version)
     self.assertEqual('1.23', sot.api_version)
     self.assertTrue(sot.requires_project_id)
 def get_urls(self, sot):
     sf = service_filter.ServiceFilter(service_type='compute')
     exp = [
         "http://compute.region0.public/v1.1",
         "http://compute.region2.public/v1",
         "http://compute.region1.public/v2.0"
     ]
     self.assertEqual(exp, sot.get_urls(sf))
     sf = service_filter.ServiceFilter(service_type='image')
     self.assertEqual(["http://image.region1.public/v2"], sot.get_urls(sf))
     sf = service_filter.ServiceFilter(service_type='identity')
     self.assertEqual(["http://identity.region1.public/v1.1/123123"],
                      sot.get_urls(sf))
     sf = service_filter.ServiceFilter(service_type='object-store')
     self.assertEqual(["http://object-store.region1.public/"],
                      sot.get_urls(sf))
     sf = service_filter.ServiceFilter(service_type='object-store',
                                       version='v9')
     self.assertEqual(["http://object-store.region1.public/v9"],
                      sot.get_urls(sf))
     sf = service_filter.ServiceFilter(service_type='object-store')
     osf = object_store_service.ObjectStoreService()
     sf = sf.join(osf)
     self.assertEqual(["http://object-store.region1.public/v1"],
                      sot.get_urls(sf))
Exemple #15
0
 def test_minimum(self):
     sot = filt.ServiceFilter()
     self.assertEqual("service_type=any,interface=public",
                      six.text_type(sot))
Exemple #16
0
 def test_match_interface(self):
     sot = filt.ServiceFilter(service_type='identity',
                              interface='internal')
     self.assertFalse(sot.match_interface('admin'))
     self.assertTrue(sot.match_interface('internal'))
     self.assertFalse(sot.match_interface('public'))
Exemple #17
0
 def test_maximum(self):
     sot = filt.ServiceFilter(service_type='compute', interface='admin',
                              region='b', service_name='c')
     exp = "service_type=compute,interface=admin,region=b,service_name=c"
     self.assertEqual(exp, six.text_type(sot))
Exemple #18
0
 def test_match_service_type_any(self):
     sot = filt.ServiceFilter()
     self.assertTrue(sot.match_service_type('identity'))
     self.assertTrue(sot.match_service_type('compute'))