Merge "Remove auth_token condition in clients"
This commit is contained in:
@@ -100,10 +100,6 @@ class OpenStackClients(object):
|
||||
return self._nova[service_type]
|
||||
|
||||
con = self.context
|
||||
if self.auth_token is None:
|
||||
logger.error(_("Nova connection failed, no auth_token!"))
|
||||
return None
|
||||
|
||||
computeshell = novashell.OpenStackComputeShell()
|
||||
extensions = computeshell._discover_extensions("1.1")
|
||||
|
||||
@@ -137,10 +133,6 @@ class OpenStackClients(object):
|
||||
return self._swift
|
||||
|
||||
con = self.context
|
||||
if self.auth_token is None:
|
||||
logger.error(_("Swift connection failed, no auth_token!"))
|
||||
return None
|
||||
|
||||
endpoint_type = self._get_client_option('swift', 'endpoint_type')
|
||||
args = {
|
||||
'auth_version': '2.0',
|
||||
@@ -192,10 +184,6 @@ class OpenStackClients(object):
|
||||
return self._cinder
|
||||
|
||||
con = self.context
|
||||
if self.auth_token is None:
|
||||
logger.error(_("Cinder connection failed, no auth_token!"))
|
||||
return None
|
||||
|
||||
endpoint_type = self._get_client_option('cinder', 'endpoint_type')
|
||||
args = {
|
||||
'service_type': 'volume',
|
||||
@@ -223,10 +211,6 @@ class OpenStackClients(object):
|
||||
return self._trove
|
||||
|
||||
con = self.context
|
||||
if self.auth_token is None:
|
||||
logger.error(_("Trove connection failed, no auth_token!"))
|
||||
return None
|
||||
|
||||
endpoint_type = self._get_client_option('trove', 'endpoint_type')
|
||||
args = {
|
||||
'service_type': service_type,
|
||||
@@ -253,11 +237,7 @@ class OpenStackClients(object):
|
||||
if self._ceilometer:
|
||||
return self._ceilometer
|
||||
|
||||
if self.auth_token is None:
|
||||
logger.error(_("Ceilometer connection failed, no auth_token!"))
|
||||
return None
|
||||
con = self.context
|
||||
|
||||
endpoint_type = self._get_client_option('ceilometer', 'endpoint_type')
|
||||
endpoint = self.url_for(service_type='metering',
|
||||
endpoint_type=endpoint_type)
|
||||
@@ -300,10 +280,6 @@ class OpenStackClients(object):
|
||||
return self._heat
|
||||
|
||||
con = self.context
|
||||
if self.auth_token is None:
|
||||
logger.error(_("Heat connection failed, no auth_token!"))
|
||||
return None
|
||||
|
||||
endpoint_type = self._get_client_option('heat', 'endpoint_type')
|
||||
args = {
|
||||
'auth_url': con.auth_url,
|
||||
|
||||
@@ -16,6 +16,7 @@ import mock
|
||||
from heat.engine import clients
|
||||
from heat.tests.common import HeatTestCase
|
||||
from heatclient import client as heatclient
|
||||
from keystoneclient import exceptions as keystone_exceptions
|
||||
|
||||
|
||||
class ClientsTest(HeatTestCase):
|
||||
@@ -56,3 +57,32 @@ class ClientsTest(HeatTestCase):
|
||||
obj._heat = None
|
||||
obj.heat()
|
||||
self.assertEqual('url_from_config', mock_call.call_args[0][1])
|
||||
|
||||
@mock.patch.object(heatclient, 'Client')
|
||||
def test_clients_heat_no_auth_token(self, mock_call):
|
||||
con = mock.Mock()
|
||||
con.auth_url = "http://auth.example.com:5000/v2.0"
|
||||
con.tenant_id = "b363706f891f48019483f8bd6503c54b"
|
||||
con.auth_token = None
|
||||
obj = clients.Clients(con)
|
||||
obj._get_heat_url = mock.Mock(name="_get_heat_url")
|
||||
obj._get_heat_url.return_value = None
|
||||
obj.url_for = mock.Mock(name="url_for")
|
||||
obj.url_for.return_value = "url_from_keystone"
|
||||
self.assertRaises(keystone_exceptions.AuthorizationFailure, obj.heat)
|
||||
|
||||
@mock.patch.object(heatclient, 'Client')
|
||||
def test_clients_heat_cached(self, mock_call):
|
||||
con = mock.Mock()
|
||||
con.auth_url = "http://auth.example.com:5000/v2.0"
|
||||
con.tenant_id = "b363706f891f48019483f8bd6503c54b"
|
||||
con.auth_token = "3bcc3d3a03f44e3d8377f9247b0ad155"
|
||||
obj = clients.Clients(con)
|
||||
obj._get_heat_url = mock.Mock(name="_get_heat_url")
|
||||
obj._get_heat_url.return_value = None
|
||||
obj.url_for = mock.Mock(name="url_for")
|
||||
obj.url_for.return_value = "url_from_keystone"
|
||||
obj._heat = None
|
||||
heat = obj.heat()
|
||||
heat_cached = obj.heat()
|
||||
self.assertEqual(heat, heat_cached)
|
||||
|
||||
Reference in New Issue
Block a user