Browse Source

Fix Django 1.11 Compatibility

Implements: blueprint dj111
Change-Id: Idfaef58b2a069006f6d792e43041dd136097c413
Co-Authored-By: Adrian Turjak <adriant@catalyst.net.nz>
Rob Cresswell 1 year ago
parent
commit
601e1ad44c
3 changed files with 10 additions and 3 deletions
  1. 2
    0
      openstack_auth/tests/settings.py
  2. 4
    2
      openstack_auth/tests/tests.py
  3. 4
    1
      openstack_auth/utils.py

+ 2
- 0
openstack_auth/tests/settings.py View File

@@ -13,6 +13,8 @@
13 13
 
14 14
 import os
15 15
 
16
+ALLOWED_HOSTS = ['*']
17
+
16 18
 DATABASES = {'default': {'ENGINE': 'django.db.backends.sqlite3'}}
17 19
 
18 20
 INSTALLED_APPS = [

+ 4
- 2
openstack_auth/tests/tests.py View File

@@ -1099,7 +1099,8 @@ class OpenStackAuthTestsV3(OpenStackAuthTestsMixin,
1099 1099
         url = reverse('login')
1100 1100
         response = self.client.get(url)
1101 1101
         self.assertEqual(response.status_code, 200)
1102
-        self.assertContains(response, 'name="domain" type="text"')
1102
+        self.assertContains(response, 'id="id_domain"')
1103
+        self.assertContains(response, 'name="domain"')
1103 1104
 
1104 1105
     def test_login_form_multidomain_dropdown(self):
1105 1106
         override = self.settings(OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT=True,
@@ -1113,7 +1114,8 @@ class OpenStackAuthTestsV3(OpenStackAuthTestsMixin,
1113 1114
         url = reverse('login')
1114 1115
         response = self.client.get(url)
1115 1116
         self.assertEqual(response.status_code, 200)
1116
-        self.assertContains(response, 'select id="id_domain" name="domain"')
1117
+        self.assertContains(response, 'id="id_domain"')
1118
+        self.assertContains(response, 'name="domain"')
1117 1119
         self.assertContains(response, 'option value="Default"')
1118 1120
         settings.OPENSTACK_KEYSTONE_DOMAIN_DROPDOWN = False
1119 1121
 

+ 4
- 1
openstack_auth/utils.py View File

@@ -17,7 +17,6 @@ import re
17 17
 
18 18
 from django.conf import settings
19 19
 from django.contrib import auth
20
-from django.contrib.auth import middleware
21 20
 from django.contrib.auth import models
22 21
 from django.utils import timezone
23 22
 from keystoneauth1.identity import v2 as v2_auth
@@ -62,6 +61,10 @@ def get_user(request):
62 61
 
63 62
 
64 63
 def patch_middleware_get_user():
64
+    # NOTE(adriant): We can't import middleware until our customer user model
65
+    # is actually registered, otherwise a call to get_user_model within the
66
+    # middleware module will fail.
67
+    from django.contrib.auth import middleware
65 68
     middleware.get_user = middleware_get_user
66 69
     auth.get_user = get_user
67 70
 

Loading…
Cancel
Save