import webob
+from keystoneclient.auth.identity.generic import token
+from keystoneclient import client
from keystoneclient import exceptions
-from keystoneclient.v3 import client
+from keystoneclient import session
from cinder.api import extensions
from cinder.api.openstack import wsgi
order to do quota operations properly.
"""
try:
- keystone = client.Client(auth_url=CONF.keymgr.encryption_auth_url,
- token=context.auth_token,
- project_id=context.project_id)
+ auth_plugin = token.Token(
+ auth_url=CONF.keystone_authtoken.auth_uri,
+ token=context.auth_token,
+ project_id=context.project_id)
+ client_session = session.Session(auth=auth_plugin)
+ keystone = client.Client(auth_url=CONF.keystone_authtoken.auth_uri,
+ session=client_session)
project = keystone.projects.get(id, subtree_as_ids=subtree_as_ids)
except exceptions.NotFound:
msg = (_("Tenant ID: %s does not exist.") % id)
from cinder import test
from cinder.tests.unit import test_db_api
+from keystonemiddleware import auth_token
from oslo_config import cfg
+from oslo_config import fixture as config_fixture
CONF = cfg.CONF
self.req.environ['cinder.context'].project_id = 'foo'
self._create_project_hierarchy()
- self.auth_url = CONF.keymgr.encryption_auth_url
+
+ self.auth_url = 'http://localhost:5000'
+ self.fixture = self.useFixture(config_fixture.Config(auth_token.CONF))
+ self.fixture.config(auth_uri=self.auth_url, group='keystone_authtoken')
def _create_project_hierarchy(self):
"""Sets an environment used for nested quotas tests.
def _get_project(self, context, id, subtree_as_ids=False):
return self.project_by_id.get(id, self.FakeProject())
- @mock.patch('keystoneclient.v3.client.Client')
- def test_keystone_client_instantiation(self, ksclient_class):
+ @mock.patch('keystoneclient.client.Client')
+ @mock.patch('keystoneclient.session.Session')
+ def test_keystone_client_instantiation(self, ksclient_session,
+ ksclient_class):
context = self.req.environ['cinder.context']
self.controller._get_project(context, context.project_id)
ksclient_class.assert_called_once_with(auth_url=self.auth_url,
- token=context.auth_token,
- project_id=context.project_id)
+ session=ksclient_session())
- @mock.patch('keystoneclient.v3.client.Client')
+ @mock.patch('keystoneclient.client.Client')
def test_get_project(self, ksclient_class):
context = self.req.environ['cinder.context']
keystoneclient = ksclient_class.return_value