horizon/openstack_dashboard/test
Mathieu Gagné 8851866aad Fix django.contrib.auth.middleware monkey patching
The "request" attribute is not available in
openstack_auth.backend.KeystoneBackend.get_user when session data is restored
and it's the first request to happen after a server restart.

As stated by the function document, the "request" attribute needs to be
monkey-patched by openstack_auth.utils.patch_middleware_get_user
for this function to work properly.

This should happen in openstack_auth.urls at import time. But there is nowhere
in Horizon where this module is imported at startup. It's only introspected
by openstack_dashboard.urls due to AUTHENTICATION_URLS setting.

Without this monkey-patching, the whole authentication mechanism falls back
to "AnonymousUser" and you will get redirected to the login page due
to horizon.exceptions.NotAuthenticated being raised by
horizon.decorators.require_auth as request.user.is_authenticated will be False.

But if a user requests a page under auth/, it will have the side-effect of
monkey-patching django.contrib.auth.middleware as expected. This means that
once this request is completed, all following requests to pages other than
the ones under auth/ will have there sessions properly restored and
you will be properly authenticated.

Therefore this change introduces a dummy middleware which sole purpose is
to perform this monkey-patching as early as possible.

There is also some cleanup to get rid of the previous attempts at
monkeypatching.

Closes-bug: #1764622

Conflicts:
	openstack_dashboard/settings.py
	openstack_dashboard/test/helpers.py

Change-Id: Ib9912090a87b716e7f5710f6f360b0df168ec2e3
(cherry picked from commit 0d16361326)
2018-11-20 21:24:04 +09:00
..
integration_tests Merge "integration test fixes" 2018-07-17 01:59:17 +00:00
jasmine Remove unused jasmine_tests.py 2015-05-13 12:39:00 -06:00
selenium openstack_dashboard: Move test files to match module structure 2017-12-09 21:38:06 +09:00
templates Splits OpenStack Dashboard bits from framework app code. 2012-10-11 11:47:50 -07:00
test_data Show generic group info in volume and volume snapshot pages 2018-07-03 13:24:24 +03:00
test_panels Drop unnecessary executable flags 2017-12-27 21:32:48 +00:00
test_plugins Use default Django test runner instead of nose 2018-06-08 15:21:12 +03:00
unit Merge "Add DNS parameters to Floating IP panels" 2018-07-23 19:29:55 +00:00
__init__.py Revamp of testing machinery. 2012-04-23 22:24:21 -07:00
error_pages_urls.py hacking: noqa cleanup in openstack_dashboard 2017-03-17 19:38:47 +00:00
extensible_header_urls.py Drop unnecessary executable flags 2017-12-27 21:32:48 +00:00
helpers.py Fix django.contrib.auth.middleware monkey patching 2018-11-20 21:24:04 +09:00
settings.py Generic volume group support 2018-06-09 06:39:18 +00:00
urls.py Fix Angular errors in openstack_auth 2018-03-17 18:36:01 +09:00