def test_get_token(self):
     test_id = "test_id"
     scObj = auth.ServiceCatalog()
     scObj.root_key = "root_key"
     scObj.catalog = dict()
     scObj.catalog[scObj.root_key] = dict()
     scObj.catalog[scObj.root_key]['token'] = dict()
     scObj.catalog[scObj.root_key]['token']['id'] = test_id
     self.assertEqual(test_id, scObj.get_token())
    def test__load(self):
        url = "random_url"
        auth.ServiceCatalog._url_for = Mock(return_value=url)

        # when service_url is None
        scObj = auth.ServiceCatalog()
        scObj.region = None
        scObj.service_url = None
        scObj._load()
        self.assertEqual(url, scObj.public_url)
        self.assertEqual(url, scObj.management_url)

        # service url is not None
        service_url = "service_url"
        scObj = auth.ServiceCatalog()
        scObj.region = None
        scObj.service_url = service_url
        scObj._load()
        self.assertEqual(service_url, scObj.public_url)
        self.assertEqual(service_url, scObj.management_url)
Ejemplo n.º 3
0
 def authenticate(self):
     catalog = {
         'access': {
             'serviceCatalog': self.username.service_catalog,
             'token': {
                 'id': self.username.token.id,
             }
         }
     }
     return auth.ServiceCatalog(catalog,
                                service_type=self.service_type,
                                service_name=self.service_name)
Ejemplo n.º 4
0
 def authenticate(self):
     catalog = {
         'access': {
             'serviceCatalog': self.username.service_catalog,
             'token': {
                 'id': self.username.token.id,
             }
         }
     }
     if not with_trove:
         return None
     return auth.ServiceCatalog(catalog,
                                service_type=self.service_type,
                                service_name=self.service_name,
                                region=self.region)
    def test__url_for(self):
        scObj = auth.ServiceCatalog()

        # case for no endpoint found
        self.case_no_endpoint_match(scObj)

        # case for empty service catalog
        self.case_endpoing_with_empty_catalog(scObj)

        # more than one matching endpoints
        self.case_ambiguous_endpoint(scObj)

        # happy case
        self.case_unique_endpoint(scObj)

        # testing if-statements in for-loop to iterate services in catalog
        self.case_iterating_services_in_catalog(scObj)
    def case_iterating_services_in_catalog(self, scObj):
        service1 = scObj.catalog[scObj.root_key]['serviceCatalog'][0]

        scObj.catalog = dict()
        scObj.root_key = "access"
        scObj.catalog[scObj.root_key] = dict()
        scObj.service_type = "no_match"

        scObj.catalog[scObj.root_key]['serviceCatalog'] = [service1]
        self.assertRaises(exceptions.EndpointNotFound, scObj._url_for)

        scObj.service_type = "database"
        scObj.service_name = "no_match"
        self.assertRaises(exceptions.EndpointNotFound, scObj._url_for)

        # no endpoints and no 'serviceCatalog' in catalog => raise exception
        scObj = auth.ServiceCatalog()
        scObj.catalog = dict()
        scObj.root_key = "access"
        scObj.catalog[scObj.root_key] = dict()
        scObj.catalog[scObj.root_key]['serviceCatalog'] = []
        self.assertRaises(exceptions.EndpointNotFound, scObj._url_for,
                          attr="test_attr", filter_value="test_attr_value")
 def test_get_public_url(self):
     test_public_url = "test_public_url"
     scObj = auth.ServiceCatalog()
     scObj.public_url = test_public_url
     self.assertEqual(test_public_url, scObj.get_public_url())
 def test_get_management_url(self):
     test_mng_url = "test_management_url"
     scObj = auth.ServiceCatalog()
     scObj.management_url = test_mng_url
     self.assertEqual(test_mng_url, scObj.get_management_url())