def get_Auth_Token(self): self.mocking = False try: if conf.block_storage_driver.swift.testing.is_mocking: self.mocking = True except: self.mocking = False if not self.mocking: auth_url = str(conf.block_storage_driver.swift.testing.auth_url) username = str(conf.block_storage_driver.swift.testing.username) password = str(conf.block_storage_driver.swift.testing.password) try: os_options = dict() storage_url, token = \ Conn.get_keystoneclient_2_0( auth_url=auth_url, user=username, key=password, os_options=os_options) except ClientException as e: sys.exit(str(e)) else: storage_url = \ str(conf.block_storage_driver.swift.testing.storage_url) token = 'mocking_token' self._hdrs = {"x-project-id": self.create_project_id(), "x-auth-token": self.create_auth_token()} return storage_url, token
def test_get_keystone_client_2_0(self): # check the correct auth version is passed to get_auth_keystone os_options = {'tenant_name': 'asdf'} req_args = {'auth_version': '2.0'} c.get_auth_keystone = fake_get_auth_keystone(os_options, required_kwargs=req_args) url, token = c.get_keystoneclient_2_0('http://www.test.com', 'asdf', 'asdf', os_options=os_options) self.assertTrue(url.startswith("http")) self.assertTrue(token)