Drop remaining code for Identity v2 API
... because it was removed long time ago. Change-Id: Ie54d7403be402390c6925c2233a393087fbe73ae Signed-off-by: Takashi Kajinami <kajinamit@oss.nttdata.com>
This commit is contained in:
1 parent
5b82d7e2d4
commit
b54735d17a
3 files changed
+2
-71
No files matched your search
@@ -19,7 +19,6 @@ import keystoneauth1.identity.generic as auth_plugin
|
||||
from keystoneauth1 import session as ks_session
|
||||
import mistralclient.api.httpclient as api
|
||||
from mistralclient import auth as mistral_auth
|
||||
from oslo_serialization import jsonutils
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@@ -34,21 +33,7 @@ class KeystoneAuthHandler(mistral_auth.AuthHandler):
|
||||
for Keystone authentication.
|
||||
"""
|
||||
reqs = self._separate_target_reqs(req)
|
||||
try:
|
||||
result = self._authenticate(reqs, session)
|
||||
except Exception as e:
|
||||
if "Cannot use v2 authentication with domain scope" in str(e):
|
||||
LOG.warning("Client tried to use v2 authentication with "
|
||||
"domain scope. Domain parameters are assumed "
|
||||
"to be erroneously set. Retrying "
|
||||
"authentication without them. "
|
||||
"Request parameters: %s" % str(reqs))
|
||||
domainless_reqs = [reqs[0],
|
||||
self._remove_domain(reqs[1])]
|
||||
result = self._authenticate(domainless_reqs, session)
|
||||
else:
|
||||
raise
|
||||
return result
|
||||
return self._authenticate(reqs, session)
|
||||
|
||||
@staticmethod
|
||||
def _separate_target_reqs(req):
|
||||
@@ -71,24 +56,6 @@ class KeystoneAuthHandler(mistral_auth.AuthHandler):
|
||||
|
||||
return [r, target_r]
|
||||
|
||||
@staticmethod
|
||||
def _remove_domain(req):
|
||||
"""Remove all domain parameters from req.
|
||||
|
||||
Keystoneauth with V2 does not accept domain parameters. This
|
||||
is an incompatible change from Keystoneclient but it would
|
||||
unnecessarily break clients of Mistral. It is safe to remove
|
||||
domain parameters if V2 auth is targeted.
|
||||
|
||||
:param req: Request dict containing list of parameters required
|
||||
:return: Request dict without domains
|
||||
"""
|
||||
r = {}
|
||||
for key in req:
|
||||
if "domain" not in key:
|
||||
r[key] = req[key]
|
||||
return r
|
||||
|
||||
@staticmethod
|
||||
def _get_auth(api_key=None, auth_token=None, auth_url=None,
|
||||
project_domain_id=None, project_domain_name=None,
|
||||
@@ -209,19 +176,6 @@ class KeystoneAuthHandler(mistral_auth.AuthHandler):
|
||||
api.TARGET_AUTH_URI: target_auth._plugin.auth_url,
|
||||
})
|
||||
|
||||
access = target_auth.get_access(target_session)
|
||||
service_catalog = access.service_catalog
|
||||
|
||||
if self._is_service_catalog_v2(service_catalog):
|
||||
access_data = access._data["access"]
|
||||
if not len(access_data['serviceCatalog']):
|
||||
LOG.warning(
|
||||
"Service Catalog empty, some authentication"
|
||||
"credentials may be missing. This can cause"
|
||||
"malfunction in the Mistral action executions.")
|
||||
sc_json = jsonutils.dumps(access_data)
|
||||
auth_response[api.TARGET_SERVICE_CATALOG] = sc_json
|
||||
|
||||
if not auth_response:
|
||||
LOG.debug("No valid token or password + user provided. "
|
||||
"Continuing without authentication")
|
||||
|
||||
@@ -109,8 +109,6 @@ class BaseClientTest(base.BaseTestCase):
|
||||
mistral_url_for_http = http_client_mock.call_args[0][0]
|
||||
self.assertEqual(MISTRAL_HTTP_URL, mistral_url_for_http)
|
||||
|
||||
@mock.patch('mistralclient.auth.keystone.KeystoneAuthHandler'
|
||||
'._is_service_catalog_v2', return_value=True)
|
||||
@mock.patch('keystoneauth1.identity.generic.Password')
|
||||
@mock.patch('keystoneauth1.session.Session')
|
||||
@mock.patch('mistralclient.api.httpclient.HTTPClient')
|
||||
@@ -118,8 +116,7 @@ class BaseClientTest(base.BaseTestCase):
|
||||
self,
|
||||
http_client_mock,
|
||||
session_mock,
|
||||
password_mock,
|
||||
catalog_type_mock
|
||||
password_mock
|
||||
):
|
||||
|
||||
session = mock.MagicMock()
|
||||
@@ -140,12 +137,6 @@ class BaseClientTest(base.BaseTestCase):
|
||||
'X-Auth-Token': 'authtoken'
|
||||
})
|
||||
|
||||
mock_access = mock.MagicMock()
|
||||
mock_catalog = mock.MagicMock()
|
||||
mock_catalog.catalog = {}
|
||||
mock_access.service_catalog = mock_catalog
|
||||
auth.get_access = mock.Mock(return_value=mock_access)
|
||||
|
||||
client.client(
|
||||
auth_url=AUTH_HTTP_URL_v3,
|
||||
username='user',
|
||||
@@ -174,7 +165,6 @@ class BaseClientTest(base.BaseTestCase):
|
||||
'target_project_name': 'tmistralp',
|
||||
'target_username': 'tmistral',
|
||||
'target_region_name': 'tregion',
|
||||
'target_service_catalog': "{}"
|
||||
}
|
||||
|
||||
for key in expected_values:
|
||||
|
||||
@@ -30,19 +30,6 @@ class TestKeystone(base.BaseClientV2Test):
|
||||
self.assertIsNotNone(elements["token"])
|
||||
self.assertIsNotNone(elements["project_id"])
|
||||
|
||||
def test_remove_domain(self):
|
||||
params = {
|
||||
"param1": "p",
|
||||
"target_param2": "p2",
|
||||
"user_domain_param3": "p3",
|
||||
"target_project_domain_param4": "p4"
|
||||
}
|
||||
dedomained = self.keystone._remove_domain(params)
|
||||
self.assertIn("param1", dedomained)
|
||||
self.assertIn("target_param2", dedomained)
|
||||
self.assertNotIn("user_domain_param3", dedomained)
|
||||
self.assertNotIn("target_project_domain_param4", dedomained)
|
||||
|
||||
def test_separate_target_reqs(self):
|
||||
params = {
|
||||
"a": 1,
|
||||
|
||||
Reference in new issue
Block a user