Remove unused context from AuthInfo
The AuthInfo.context attribute is not used anywhere and all the testing therefore just passes a None value rather than even try and provide real values. Let's get rid of it. Change-Id: I7b69b53915def44f531cbda80c875c7b9b114169
This commit is contained in:
parent
c104f9fbc2
commit
e39486a15e
|
@ -132,13 +132,12 @@ class AuthInfo(object):
|
|||
"""Encapsulation of "auth" request."""
|
||||
|
||||
@staticmethod
|
||||
def create(context, auth=None, scope_only=False):
|
||||
auth_info = AuthInfo(context, auth=auth)
|
||||
def create(auth=None, scope_only=False):
|
||||
auth_info = AuthInfo(auth=auth)
|
||||
auth_info._validate_and_normalize_auth_data(scope_only)
|
||||
return auth_info
|
||||
|
||||
def __init__(self, context, auth=None):
|
||||
self.context = context
|
||||
def __init__(self, auth=None):
|
||||
self.auth = auth
|
||||
self._scope_data = (None, None, None, None)
|
||||
# self._scope_data is (domain_id, project_id, trust_ref, unscoped)
|
||||
|
@ -395,7 +394,7 @@ class Auth(controller.V3Controller):
|
|||
include_catalog = 'nocatalog' not in request.params
|
||||
|
||||
try:
|
||||
auth_info = AuthInfo.create(request.context_dict, auth=auth)
|
||||
auth_info = AuthInfo.create(auth=auth)
|
||||
auth_context = AuthContext(extras={},
|
||||
method_names=[],
|
||||
bind={})
|
||||
|
|
|
@ -92,7 +92,7 @@ class TokenlessAuthHelper(object):
|
|||
auth['scope'] = self._build_scope_info()
|
||||
|
||||
# NOTE(chioleong): We'll let AuthInfo validate the scope for us
|
||||
auth_info = controllers.AuthInfo.create({}, auth, scope_only=True)
|
||||
auth_info = controllers.AuthInfo.create(auth, scope_only=True)
|
||||
return auth_info.get_scope()
|
||||
|
||||
def get_mapped_user(self, project_id=None, domain_id=None):
|
||||
|
|
|
@ -55,7 +55,6 @@ class TestAuthPlugin(unit.SQLDriverOverrides, unit.TestCase):
|
|||
auth_data = {'identity': auth_data}
|
||||
self.assertRaises(exception.AuthMethodNotSupported,
|
||||
auth.controllers.AuthInfo.create,
|
||||
None,
|
||||
auth_data)
|
||||
|
||||
def test_addition_auth_steps(self):
|
||||
|
@ -69,7 +68,7 @@ class TestAuthPlugin(unit.SQLDriverOverrides, unit.TestCase):
|
|||
auth_data[METHOD_NAME] = {
|
||||
'test': 'test'}
|
||||
auth_data = {'identity': auth_data}
|
||||
auth_info = auth.controllers.AuthInfo.create(None, auth_data)
|
||||
auth_info = auth.controllers.AuthInfo.create(auth_data)
|
||||
auth_context = {'extras': {}, 'method_names': []}
|
||||
try:
|
||||
self.api.authenticate(self.make_request(), auth_info, auth_context)
|
||||
|
@ -84,7 +83,7 @@ class TestAuthPlugin(unit.SQLDriverOverrides, unit.TestCase):
|
|||
auth_data[METHOD_NAME] = {
|
||||
'response': EXPECTED_RESPONSE}
|
||||
auth_data = {'identity': auth_data}
|
||||
auth_info = auth.controllers.AuthInfo.create(None, auth_data)
|
||||
auth_info = auth.controllers.AuthInfo.create(auth_data)
|
||||
auth_context = {'extras': {}, 'method_names': []}
|
||||
self.api.authenticate(self.make_request(), auth_info, auth_context)
|
||||
self.assertEqual(DEMO_USER_ID, auth_context['user_id'])
|
||||
|
@ -94,7 +93,7 @@ class TestAuthPlugin(unit.SQLDriverOverrides, unit.TestCase):
|
|||
auth_data[METHOD_NAME] = {
|
||||
'response': uuid.uuid4().hex}
|
||||
auth_data = {'identity': auth_data}
|
||||
auth_info = auth.controllers.AuthInfo.create(None, auth_data)
|
||||
auth_info = auth.controllers.AuthInfo.create(auth_data)
|
||||
auth_context = {'extras': {}, 'method_names': []}
|
||||
self.assertRaises(exception.Unauthorized,
|
||||
self.api.authenticate,
|
||||
|
@ -145,8 +144,7 @@ class TestMapped(unit.TestCase):
|
|||
method_name: {'protocol': method_name},
|
||||
}
|
||||
}
|
||||
auth_info = auth.controllers.AuthInfo.create(request.context_dict,
|
||||
auth_data)
|
||||
auth_info = auth.controllers.AuthInfo.create(auth_data)
|
||||
auth_context = {'extras': {},
|
||||
'method_names': [],
|
||||
'user_id': uuid.uuid4().hex}
|
||||
|
@ -173,7 +171,7 @@ class TestMapped(unit.TestCase):
|
|||
with mock.patch.object(auth.plugins.mapped.Mapped,
|
||||
'authenticate',
|
||||
return_value=None) as authenticate:
|
||||
auth_info = auth.controllers.AuthInfo.create(None, auth_data)
|
||||
auth_info = auth.controllers.AuthInfo.create(auth_data)
|
||||
request = self.make_request(environ={'REMOTE_USER': 'foo@idp.com'})
|
||||
self.api.authenticate(request, auth_info, auth_context)
|
||||
# make sure Mapped plugin got invoked with the correct payload
|
||||
|
|
|
@ -1315,8 +1315,7 @@ class RestfulTestCase(unit.SQLDriverOverrides, rest.RestfulTestCase,
|
|||
if not auth_data:
|
||||
auth_data = self.build_authentication_request(
|
||||
kerberos=kerberos)['auth']
|
||||
no_context = None
|
||||
auth_info = auth.controllers.AuthInfo.create(no_context, auth_data)
|
||||
auth_info = auth.controllers.AuthInfo.create(auth_data)
|
||||
auth_context = {'extras': {}, 'method_names': []}
|
||||
return self.make_request(environ=environment), auth_info, auth_context
|
||||
|
||||
|
|
|
@ -56,7 +56,6 @@ class TestAuthInfo(common_auth.AuthTestMixin, testcase.TestCase):
|
|||
auth_data['identity']['token'] = {'id': uuid.uuid4().hex}
|
||||
self.assertRaises(exception.ValidationError,
|
||||
auth.controllers.AuthInfo.create,
|
||||
None,
|
||||
auth_data)
|
||||
|
||||
def test_unsupported_auth_method(self):
|
||||
|
@ -65,7 +64,6 @@ class TestAuthInfo(common_auth.AuthTestMixin, testcase.TestCase):
|
|||
auth_data = {'identity': auth_data}
|
||||
self.assertRaises(exception.AuthMethodNotSupported,
|
||||
auth.controllers.AuthInfo.create,
|
||||
None,
|
||||
auth_data)
|
||||
|
||||
def test_missing_auth_method_data(self):
|
||||
|
@ -73,7 +71,6 @@ class TestAuthInfo(common_auth.AuthTestMixin, testcase.TestCase):
|
|||
auth_data = {'identity': auth_data}
|
||||
self.assertRaises(exception.ValidationError,
|
||||
auth.controllers.AuthInfo.create,
|
||||
None,
|
||||
auth_data)
|
||||
|
||||
def test_project_name_no_domain(self):
|
||||
|
@ -83,7 +80,6 @@ class TestAuthInfo(common_auth.AuthTestMixin, testcase.TestCase):
|
|||
project_name='abc')['auth']
|
||||
self.assertRaises(exception.ValidationError,
|
||||
auth.controllers.AuthInfo.create,
|
||||
None,
|
||||
auth_data)
|
||||
|
||||
def test_both_project_and_domain_in_scope(self):
|
||||
|
@ -94,7 +90,6 @@ class TestAuthInfo(common_auth.AuthTestMixin, testcase.TestCase):
|
|||
domain_name='test')['auth']
|
||||
self.assertRaises(exception.ValidationError,
|
||||
auth.controllers.AuthInfo.create,
|
||||
None,
|
||||
auth_data)
|
||||
|
||||
def test_get_method_names_duplicates(self):
|
||||
|
@ -104,8 +99,7 @@ class TestAuthInfo(common_auth.AuthTestMixin, testcase.TestCase):
|
|||
password='test')['auth']
|
||||
auth_data['identity']['methods'] = ['password', 'token',
|
||||
'password', 'password']
|
||||
context = None
|
||||
auth_info = auth.controllers.AuthInfo.create(context, auth_data)
|
||||
auth_info = auth.controllers.AuthInfo.create(auth_data)
|
||||
self.assertEqual(['password', 'token'],
|
||||
auth_info.get_method_names())
|
||||
|
||||
|
@ -113,8 +107,7 @@ class TestAuthInfo(common_auth.AuthTestMixin, testcase.TestCase):
|
|||
auth_data = self.build_authentication_request(
|
||||
user_id='test',
|
||||
password='test')['auth']
|
||||
context = None
|
||||
auth_info = auth.controllers.AuthInfo.create(context, auth_data)
|
||||
auth_info = auth.controllers.AuthInfo.create(auth_data)
|
||||
|
||||
method_name = uuid.uuid4().hex
|
||||
self.assertRaises(exception.ValidationError,
|
||||
|
@ -129,7 +122,6 @@ class TestAuthInfo(common_auth.AuthTestMixin, testcase.TestCase):
|
|||
auth_data['scope']['domain'] = []
|
||||
self.assertRaises(exception.ValidationError,
|
||||
auth.controllers.AuthInfo.create,
|
||||
None,
|
||||
auth_data)
|
||||
|
||||
def test_empty_project_in_scope(self):
|
||||
|
@ -140,7 +132,6 @@ class TestAuthInfo(common_auth.AuthTestMixin, testcase.TestCase):
|
|||
auth_data['scope']['project'] = []
|
||||
self.assertRaises(exception.ValidationError,
|
||||
auth.controllers.AuthInfo.create,
|
||||
None,
|
||||
auth_data)
|
||||
|
||||
|
||||
|
@ -2070,7 +2061,7 @@ class TokenAPITests(object):
|
|||
auth_data['identity']['methods'] = ["password", "external"]
|
||||
auth_data['identity']['external'] = {}
|
||||
api = auth.controllers.Auth()
|
||||
auth_info = auth.controllers.AuthInfo(None, auth_data)
|
||||
auth_info = auth.controllers.AuthInfo(auth_data)
|
||||
auth_context = {'extras': {}, 'method_names': []}
|
||||
self.assertRaises(exception.Unauthorized,
|
||||
api.authenticate,
|
||||
|
|
Loading…
Reference in New Issue