Browse Source

Hide settings/change password on keystone v3

When using keystone v3, it was possible to change the user
password without knowing the old password.

Change-Id: I2e3721f9c8a1de4b9a5f85b230432844d2c83507
Closes-Bug: 1237989
Matthias Runge 5 years ago
parent
commit
d716bfcdbf

+ 5
- 2
openstack_dashboard/dashboards/settings/password/panel.py View File

@@ -18,6 +18,7 @@ from django.utils.translation import ugettext_lazy as _  # noqa
18 18
 
19 19
 import horizon
20 20
 
21
+from openstack_dashboard.api import keystone
21 22
 from openstack_dashboard.dashboards.settings import dashboard
22 23
 
23 24
 
@@ -25,5 +26,7 @@ class PasswordPanel(horizon.Panel):
25 26
     name = _("Change Password")
26 27
     slug = 'password'
27 28
 
28
-
29
-dashboard.Settings.register(PasswordPanel)
29
+# TODO(mrunge): remove restriction, when keystone v3 has a update own user
30
+# function and checks passwords properly.
31
+if keystone.VERSIONS.active == 2:
32
+    dashboard.Settings.register(PasswordPanel)

+ 18
- 2
openstack_dashboard/dashboards/settings/password/tests.py View File

@@ -14,6 +14,7 @@
14 14
 #    License for the specific language governing permissions and limitations
15 15
 #    under the License.
16 16
 
17
+from django.core.urlresolvers import NoReverseMatch  # noqa
17 18
 from django.core.urlresolvers import reverse  # noqa
18 19
 from django import http
19 20
 
@@ -22,14 +23,19 @@ from mox import IsA  # noqa
22 23
 from openstack_dashboard import api
23 24
 from openstack_dashboard.test import helpers as test
24 25
 
25
-
26
-INDEX_URL = reverse('horizon:settings:password:index')
26
+# TODO(mrunge): remove, when keystone v3 supports
27
+# change_own_password, incl. password validation
28
+kver = api.keystone.VERSIONS.active
29
+if kver == 2:
30
+    INDEX_URL = reverse('horizon:settings:password:index')
27 31
 
28 32
 
29 33
 class ChangePasswordTests(test.TestCase):
30 34
 
31 35
     @test.create_stubs({api.keystone: ('user_update_own_password', )})
32 36
     def test_change_password(self):
37
+        if kver == 3:
38
+            self.skipTest('Password change in keystone v3 unsupported')
33 39
         api.keystone.user_update_own_password(IsA(http.HttpRequest),
34 40
                                               'oldpwd',
35 41
                                               'normalpwd',).AndReturn(None)
@@ -44,6 +50,8 @@ class ChangePasswordTests(test.TestCase):
44 50
         self.assertNoFormErrors(res)
45 51
 
46 52
     def test_change_validation_passwords_not_matching(self):
53
+        if kver == 3:
54
+            self.skipTest('Password change in keystone v3 unsupported')
47 55
         formData = {'method': 'PasswordForm',
48 56
                     'current_password': 'currpasswd',
49 57
                     'new_password': 'testpassword',
@@ -54,6 +62,8 @@ class ChangePasswordTests(test.TestCase):
54 62
 
55 63
     @test.create_stubs({api.keystone: ('user_update_own_password', )})
56 64
     def test_change_password_shows_message_on_login_page(self):
65
+        if kver == 3:
66
+            self.skipTest('Password change in keystone v3 unsupported')
57 67
         api.keystone.user_update_own_password(IsA(http.HttpRequest),
58 68
                                               'oldpwd',
59 69
                                               'normalpwd').AndReturn(None)
@@ -67,3 +77,9 @@ class ChangePasswordTests(test.TestCase):
67 77
 
68 78
         info_msg = "Password changed. Please log in again to continue."
69 79
         self.assertContains(res, info_msg)
80
+
81
+    def test_on_keystone_v3_disabled(self):
82
+        try:
83
+            reverse('horizon:settings:password:index')
84
+        except NoReverseMatch:
85
+            pass

Loading…
Cancel
Save