Merge "Use more parts from keystoneauth"
This commit is contained in:
commit
86f1a55346
@ -174,7 +174,7 @@ class ClientTest(utils.TestCase):
|
|||||||
|
|
||||||
self.mock_object(client.httpclient, 'HTTPClient')
|
self.mock_object(client.httpclient, 'HTTPClient')
|
||||||
self.mock_object(client.ks_client, 'Client')
|
self.mock_object(client.ks_client, 'Client')
|
||||||
self.mock_object(client.discover, 'Discover')
|
self.mock_object(client.session.discover, 'Discover')
|
||||||
self.mock_object(client.session, 'Session')
|
self.mock_object(client.session, 'Session')
|
||||||
client_args = self._get_client_args(**kwargs)
|
client_args = self._get_client_args(**kwargs)
|
||||||
client_args['api_version'] = manilaclient.API_MIN_VERSION
|
client_args['api_version'] = manilaclient.API_MIN_VERSION
|
||||||
@ -198,7 +198,7 @@ class ClientTest(utils.TestCase):
|
|||||||
'region_id': 'SecondRegion', 'url': 'http://3.3.3.2'},
|
'region_id': 'SecondRegion', 'url': 'http://3.3.3.2'},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
client.discover.Discover.return_value.url_for.side_effect = (
|
client.session.discover.Discover.return_value.url_for.side_effect = (
|
||||||
fake_url_for)
|
fake_url_for)
|
||||||
client.ks_client.Client.return_value.auth_token.return_value = (
|
client.ks_client.Client.return_value.auth_token.return_value = (
|
||||||
'fake_token')
|
'fake_token')
|
||||||
@ -237,7 +237,7 @@ class ClientTest(utils.TestCase):
|
|||||||
def test_client_init_no_session_no_auth_token_v2(self, kwargs):
|
def test_client_init_no_session_no_auth_token_v2(self, kwargs):
|
||||||
self.mock_object(client.httpclient, 'HTTPClient')
|
self.mock_object(client.httpclient, 'HTTPClient')
|
||||||
self.mock_object(client.ks_client, 'Client')
|
self.mock_object(client.ks_client, 'Client')
|
||||||
self.mock_object(client.discover, 'Discover')
|
self.mock_object(client.session.discover, 'Discover')
|
||||||
self.mock_object(client.session, 'Session')
|
self.mock_object(client.session, 'Session')
|
||||||
client_args = self._get_client_args(**kwargs)
|
client_args = self._get_client_args(**kwargs)
|
||||||
client_args['api_version'] = manilaclient.API_MIN_VERSION
|
client_args['api_version'] = manilaclient.API_MIN_VERSION
|
||||||
@ -253,7 +253,7 @@ class ClientTest(utils.TestCase):
|
|||||||
'publicUrl': 'http://3.3.3.3', 'adminUrl': 'http://3.3.3.2'},
|
'publicUrl': 'http://3.3.3.3', 'adminUrl': 'http://3.3.3.2'},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
client.discover.Discover.return_value.url_for.side_effect = (
|
client.session.discover.Discover.return_value.url_for.side_effect = (
|
||||||
lambda v: 'url_v2.0' if v == 'v2.0' else None)
|
lambda v: 'url_v2.0' if v == 'v2.0' else None)
|
||||||
client.ks_client.Client.return_value.auth_token.return_value = (
|
client.ks_client.Client.return_value.auth_token.return_value = (
|
||||||
'fake_token')
|
'fake_token')
|
||||||
@ -280,7 +280,7 @@ class ClientTest(utils.TestCase):
|
|||||||
mocked_ks_client.authenticate.assert_called_with()
|
mocked_ks_client.authenticate.assert_called_with()
|
||||||
|
|
||||||
@mock.patch.object(client.ks_client, 'Client', mock.Mock())
|
@mock.patch.object(client.ks_client, 'Client', mock.Mock())
|
||||||
@mock.patch.object(client.discover, 'Discover', mock.Mock())
|
@mock.patch.object(client.session.discover, 'Discover', mock.Mock())
|
||||||
@mock.patch.object(client.session, 'Session', mock.Mock())
|
@mock.patch.object(client.session, 'Session', mock.Mock())
|
||||||
def test_client_init_no_session_no_auth_token_endpoint_not_found(self):
|
def test_client_init_no_session_no_auth_token_endpoint_not_found(self):
|
||||||
self.mock_object(client.httpclient, 'HTTPClient')
|
self.mock_object(client.httpclient, 'HTTPClient')
|
||||||
@ -288,14 +288,15 @@ class ClientTest(utils.TestCase):
|
|||||||
auth_urli='fake_url',
|
auth_urli='fake_url',
|
||||||
password='foo_password',
|
password='foo_password',
|
||||||
tenant_id='foo_tenant_id')
|
tenant_id='foo_tenant_id')
|
||||||
client.discover.Discover.return_value.url_for.return_value = None
|
discover = client.session.discover.Discover
|
||||||
|
discover.return_value.url_for.return_value = None
|
||||||
mocked_ks_client = client.ks_client.Client.return_value
|
mocked_ks_client = client.ks_client.Client.return_value
|
||||||
|
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
exceptions.CommandError, client.Client, **client_args)
|
exceptions.CommandError, client.Client, **client_args)
|
||||||
|
|
||||||
self.assertTrue(client.session.Session.called)
|
self.assertTrue(client.session.Session.called)
|
||||||
self.assertTrue(client.discover.Discover.called)
|
self.assertTrue(client.session.discover.Discover.called)
|
||||||
self.assertFalse(client.httpclient.HTTPClient.called)
|
self.assertFalse(client.httpclient.HTTPClient.called)
|
||||||
self.assertFalse(client.ks_client.Client.called)
|
self.assertFalse(client.ks_client.Client.called)
|
||||||
self.assertFalse(mocked_ks_client.service_catalog.get_endpoints.called)
|
self.assertFalse(mocked_ks_client.service_catalog.get_endpoints.called)
|
||||||
|
@ -12,10 +12,9 @@
|
|||||||
|
|
||||||
from debtcollector import removals
|
from debtcollector import removals
|
||||||
|
|
||||||
|
from keystoneauth1 import adapter
|
||||||
from keystoneauth1 import session
|
from keystoneauth1 import session
|
||||||
from keystoneclient import adapter
|
|
||||||
from keystoneclient import client as ks_client
|
from keystoneclient import client as ks_client
|
||||||
from keystoneclient import discover
|
|
||||||
|
|
||||||
import manilaclient
|
import manilaclient
|
||||||
from manilaclient.common import constants
|
from manilaclient.common import constants
|
||||||
@ -238,8 +237,7 @@ class Client(object):
|
|||||||
ks_session = session.Session(verify=verify, cert=self.cert)
|
ks_session = session.Session(verify=verify, cert=self.cert)
|
||||||
|
|
||||||
# Discover the supported keystone versions using the given url
|
# Discover the supported keystone versions using the given url
|
||||||
ks_discover = discover.Discover(
|
ks_discover = session.discover.Discover(ks_session, self.auth_url)
|
||||||
session=ks_session, auth_url=self.auth_url)
|
|
||||||
|
|
||||||
# Inspect the auth_url to see the supported version. If both v3 and v2
|
# Inspect the auth_url to see the supported version. If both v3 and v2
|
||||||
# are supported, then use the highest version if possible.
|
# are supported, then use the highest version if possible.
|
||||||
|
@ -12,10 +12,9 @@
|
|||||||
|
|
||||||
from debtcollector import removals
|
from debtcollector import removals
|
||||||
|
|
||||||
|
from keystoneauth1 import adapter
|
||||||
from keystoneauth1 import session
|
from keystoneauth1 import session
|
||||||
from keystoneclient import adapter
|
|
||||||
from keystoneclient import client as ks_client
|
from keystoneclient import client as ks_client
|
||||||
from keystoneclient import discover
|
|
||||||
|
|
||||||
import manilaclient
|
import manilaclient
|
||||||
from manilaclient.common import constants
|
from manilaclient.common import constants
|
||||||
@ -273,8 +272,7 @@ class Client(object):
|
|||||||
ks_session = session.Session(verify=verify, cert=self.cert)
|
ks_session = session.Session(verify=verify, cert=self.cert)
|
||||||
|
|
||||||
# Discover the supported keystone versions using the given url
|
# Discover the supported keystone versions using the given url
|
||||||
ks_discover = discover.Discover(
|
ks_discover = session.discover.Discover(ks_session, self.auth_url)
|
||||||
session=ks_session, auth_url=self.auth_url)
|
|
||||||
|
|
||||||
# Inspect the auth_url to see the supported version. If both v3 and v2
|
# Inspect the auth_url to see the supported version. If both v3 and v2
|
||||||
# are supported, then use the highest version if possible.
|
# are supported, then use the highest version if possible.
|
||||||
|
Loading…
Reference in New Issue
Block a user