Enable settings/change password on keystone v3

There is a new API in v3 for users to update their own password.

Change-Id: I30e1f4682dab6e29968f38f04fa71e0e3720d5e1
Closes-Bug: #1239757
This commit is contained in:
Zhenguo Niu 2013-12-04 16:03:56 +08:00 committed by niu-zglinux
parent 857ccf9ccc
commit e027878791
4 changed files with 9 additions and 24 deletions

View File

@ -396,11 +396,11 @@ def user_update_password(request, user, password, admin=True):
def user_update_own_password(request, origpassword, password):
client = keystoneclient(request, admin=False)
client.user_id = request.user.id
if VERSIONS.active < 3:
client.user_id = request.user.id
return client.users.update_own_password(origpassword, password)
else:
return client.users.update(request.user.id, password=password)
return client.users.update_password(origpassword, password)
def user_update_tenant(request, user, project, admin=True):

View File

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

View File

@ -23,19 +23,14 @@ from mox import IsA # noqa
from openstack_dashboard import api
from openstack_dashboard.test import helpers as test
# TODO(mrunge): remove, when keystone v3 supports
# change_own_password, incl. password validation
kver = api.keystone.VERSIONS.active
if kver == 2:
INDEX_URL = reverse('horizon:settings:password:index')
INDEX_URL = reverse('horizon:settings:password:index')
class ChangePasswordTests(test.TestCase):
@test.create_stubs({api.keystone: ('user_update_own_password', )})
def test_change_password(self):
if kver == 3:
self.skipTest('Password change in keystone v3 unsupported')
api.keystone.user_update_own_password(IsA(http.HttpRequest),
'oldpwd',
'normalpwd',).AndReturn(None)
@ -50,8 +45,6 @@ class ChangePasswordTests(test.TestCase):
self.assertNoFormErrors(res)
def test_change_validation_passwords_not_matching(self):
if kver == 3:
self.skipTest('Password change in keystone v3 unsupported')
formData = {'method': 'PasswordForm',
'current_password': 'currpasswd',
'new_password': 'testpassword',
@ -62,8 +55,6 @@ class ChangePasswordTests(test.TestCase):
@test.create_stubs({api.keystone: ('user_update_own_password', )})
def test_change_password_shows_message_on_login_page(self):
if kver == 3:
self.skipTest('Password change in keystone v3 unsupported')
api.keystone.user_update_own_password(IsA(http.HttpRequest),
'oldpwd',
'normalpwd').AndReturn(None)
@ -77,9 +68,3 @@ class ChangePasswordTests(test.TestCase):
info_msg = "Password changed. Please log in again to continue."
self.assertContains(res, info_msg)
def test_on_keystone_v3_disabled(self):
try:
reverse('horizon:settings:password:index')
except NoReverseMatch:
pass

View File

@ -211,3 +211,6 @@ FLAVOR_EXTRA_KEYS = {
('quota:outbound_average', 'Quota: Outbound average'),
]
}
# The openstack_auth.user.Token object isn't JSON-serializable ATM
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'