Fixed create_user_update_password scenario with keystone v3 endpoint

create_user_update_password failed with keystone v3 endpoint due to
API inconsistency. The method has been changed to users.update in v3
for admin endpoint.

users.update_password is going to update the user's password to which
the token belongs in v3. Unlike v2, It no longer works to update
the user password by admin user.

When calling users.update_password, the user id will
be extracted from the request context in keystone, which is why
users.update_password no longer requires user id to be passed as an arg.
The old password needs to be supplied for authentication.

Rally calls users.update_password in create_user_update_password in v3.
It basically tells keystone to update the admin user's password,
which will result a different behavior to v2.

Besides, user id is wrongly passed as the user's old password in v3,
which result an UnauthorizedException in keystone and fail the test.

This commit will use users.update to update the user password with
admin clients.

Change-Id: I063c0e488a2dddd72ed865c984efcd0fa596a850
Closes-Bug: 1469590
This commit is contained in:
Zhongcheng Lao 2015-08-13 17:45:15 +08:00
parent d9169b71f9
commit 8686f4487d
2 changed files with 23 additions and 2 deletions

View File

@ -226,8 +226,11 @@ class KeystoneScenario(scenario.OpenStackScenario):
:param user_id: id of the user
:param password: new password
"""
self.admin_clients("keystone").users.update_password(user_id,
password)
admin_clients = self.admin_clients("keystone")
if admin_clients.version in ["v3"]:
admin_clients.users.update(user_id, password=password)
else:
admin_clients.users.update_password(user_id, password)
@base.atomic_action_timer("keystone.create_ec2creds")
def _create_ec2credentials(self, user_id, tenant_id):

View File

@ -285,6 +285,24 @@ class KeystoneScenarioTestCase(test.ScenarioTestCase):
self._test_atomic_action_timer(scenario.atomic_actions(),
"keystone.update_user_password")
@mock.patch("rally.plugins.openstack.scenario.OpenStackScenario."
"admin_clients")
def test_update_user_password_v3(self,
mock_open_stack_scenario_admin_clients):
password = "pswd"
user = mock.MagicMock()
scenario = utils.KeystoneScenario()
type(mock_open_stack_scenario_admin_clients.return_value).version = (
mock.PropertyMock(return_value="v3"))
scenario._update_user_password(password=password, user_id=user.id)
mock_open_stack_scenario_admin_clients(
"keystone").users.update.assert_called_once_with(
user.id, password=password)
self._test_atomic_action_timer(scenario.atomic_actions(),
"keystone.update_user_password")
def test_get_service_by_name(self):
scenario = utils.KeystoneScenario()
svc_foo, svc_bar = mock.Mock(), mock.Mock()