From 63e0ff2f6ce3a8275c262127e046fffbb1f1ff65 Mon Sep 17 00:00:00 2001 From: Pavlo Shchelokovskyy Date: Tue, 6 Jun 2017 14:15:42 +0000 Subject: Rework keystone auth for glance this patch changes the way glance client is instantiated, using keystoneauth sessions and adapters. In order to support glance API endpoint discovery from keystone catalog and more unified way of client loading, many options in `[glance]` config sections are deprecated, mostly those that specified a (set of) glance API endpoint(s) or parts of glance API address. Instead, a single option `[glance]endpoint_override` must be used when required to access a specific (possibly load-balanced) glance API endpoint without discovering it from keystone catalog. Another set of deprecated options are those that are duplicating keystoneauth session options in [glance] section. Also, intrinsic support for parsing the glance API URL from image ref set to the full glance REST path to the image is removed as it was not working any way since an 'http(s)://' image ref is not treated as a glance image. Change-Id: I6a93b71ac097e951dfc93fd1ee4d7ef483514f2c Partial-Bug: #1699547 Closes-Bug: #1699542 --- ironic/tests/unit/common/test_keystone.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'ironic/tests/unit/common/test_keystone.py') diff --git a/ironic/tests/unit/common/test_keystone.py b/ironic/tests/unit/common/test_keystone.py index 31c85baad..9babe028c 100644 --- a/ironic/tests/unit/common/test_keystone.py +++ b/ironic/tests/unit/common/test_keystone.py @@ -17,6 +17,7 @@ import mock from oslo_config import cfg from oslo_config import fixture +from ironic.common import context from ironic.common import exception from ironic.common import keystone from ironic.conf import auth as ironic_auth @@ -92,3 +93,14 @@ class KeystoneTestCase(base.TestCase): interface='admin') self.assertEqual('admin', adapter.interface) self.assertEqual(session, adapter.session) + + @mock.patch('keystoneauth1.service_token.ServiceTokenAuthWrapper') + @mock.patch('keystoneauth1.token_endpoint.Token') + def test_get_service_auth(self, token_mock, service_auth_mock): + ctxt = context.RequestContext(auth_token='spam') + mock_auth = mock.Mock() + self.assertEqual(service_auth_mock.return_value, + keystone.get_service_auth(ctxt, 'ham', mock_auth)) + token_mock.assert_called_once_with('ham', 'spam') + service_auth_mock.assert_called_once_with( + user_auth=token_mock.return_value, service_auth=mock_auth) -- cgit v1.2.1