summaryrefslogtreecommitdiff
path: root/keystone/tests/unit/server/test_keystone_flask.py
diff options
context:
space:
mode:
authormorgan fainberg <morgan.fainberg@gmail.com>2018-09-18 10:54:59 -0700
committerMorgan Fainberg <morgan.fainberg@gmail.com>2018-10-09 23:23:03 -0700
commitd97832e8e826e37171b727072c720a9b589998dd (patch)
treec0da33ed74c8518561731fbd00cbe38790d9d747 /keystone/tests/unit/server/test_keystone_flask.py
parent8e33c782320ae1014f9b69b484b5b6c3cf0593f6 (diff)
downloadkeystone-d97832e8e826e37171b727072c720a9b589998dd.tar.gz
Convert auth to flask native dispatching
Convert the /auth paths to flask native dispatching. A minor change to additional_urls was implemented to ensure all urls are added at once instead of individually (causing an over- write issue within flask as a single resource may only have a single set of URL mappings). Alternate URLs now support adding alternate JSON Home rel links. This is to support the case of OS-FEDERATION auth routes moving to /auth. The old JSON Home entries must exist but reference the new paths. This port includes the following test changes (needed due to the way flask handles requests and the way requests are passed through the auth system): * Implemented keystone.common.render_token (module) containing render_token_response_from_model and use it instead of keystone.common.controller.render_token_response_from_model. Minor differences occur in render_token_response_from_model in the keystone.common.render_token module, this is simply for referencing data from flask instead of the request object. * Test cases have been modified to no longer rely on the auth controller(s) directly * Test cases now use "make_request" as a context manager since authenticate/authenticate_for_token directly reference the flask contexts and must have an explicit context pushed. * Test cases no longer pass request objects into methods such as authenticate/authenticate_for_token or similar methods on the auth plugins * Test cases for federation reference the token model now where possible instead of the rendered token response. Rendered token responses are generated where needed. * Auth Plugin Configuration is done in test core as well. This is because Auth controller does not exist. NOTE: This is a massive change, but must of these changes were now easily uncoupled because of how far reaching auth is. Change-Id: I636928102875760726cc3493775a2be48e774fd7 Partial-Bug: #1776504
Diffstat (limited to 'keystone/tests/unit/server/test_keystone_flask.py')
-rw-r--r--keystone/tests/unit/server/test_keystone_flask.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/keystone/tests/unit/server/test_keystone_flask.py b/keystone/tests/unit/server/test_keystone_flask.py
index a0deff326..69ea3343d 100644
--- a/keystone/tests/unit/server/test_keystone_flask.py
+++ b/keystone/tests/unit/server/test_keystone_flask.py
@@ -15,6 +15,7 @@ import uuid
import fixtures
import flask
import flask_restful
+import functools
from oslo_policy import policy
from oslo_serialization import jsonutils
from testtools import matchers
@@ -402,11 +403,19 @@ class TestKeystoneFlaskCommon(rest.RestfulTestCase):
expected_status_code=420)
def test_construct_resource_map(self):
+ resource_name = 'arguments'
param_relation = json_home.build_v3_parameter_relation(
'argument_id')
+ alt_rel_func = functools.partial(
+ json_home.build_v3_extension_resource_relation,
+ extension_name='extension', extension_version='1.0')
url = '/v3/arguments/<string:argument_id>'
- old_url = ['/v3/old_arguments/<string:argument_id>']
- resource_name = 'arguments'
+ old_url = [dict(
+ url='/v3/old_arguments/<string:argument_id>',
+ json_home=flask_common.construct_json_home_data(
+ rel='arguments',
+ resource_relation_func=alt_rel_func)
+ )]
mapping = flask_common.construct_resource_map(
resource=_TestResourceWithCollectionInfo,
@@ -420,13 +429,17 @@ class TestKeystoneFlaskCommon(rest.RestfulTestCase):
self.assertEqual(_TestResourceWithCollectionInfo,
mapping.resource)
self.assertEqual(url, mapping.url)
- self.assertEqual(old_url, mapping.alternate_urls)
self.assertEqual(json_home.build_v3_resource_relation(resource_name),
mapping.json_home_data.rel)
self.assertEqual(json_home.Status.EXPERIMENTAL,
mapping.json_home_data.status)
self.assertEqual({'argument_id': param_relation},
mapping.json_home_data.path_vars)
+ # Check the alternate URL data is populated sanely
+ self.assertEqual(1, len(mapping.alternate_urls))
+ alt_url_data = mapping.alternate_urls[0]
+ self.assertEqual(old_url[0]['url'], alt_url_data['url'])
+ self.assertEqual(old_url[0]['json_home'], alt_url_data['json_home'])
def test_instantiate_and_register_to_app(self):
# Test that automatic instantiation and registration to app works.