diff options
| author | Mouad Benchchaoui <m.benchchaoui@x-ion.de> | 2014-07-10 13:23:35 +0200 |
|---|---|---|
| committer | Steve Martinelli <stevemar@ca.ibm.com> | 2014-09-07 02:37:54 -0400 |
| commit | 0069adef5ccec501c36b8da1d2de2821a97afe07 (patch) | |
| tree | 6d4cb9db017547989aa225281e28221d8c6f3341 /openstackclient/tests | |
| parent | 8e12949958143e7db9783ef6246e6b09def0ad8e (diff) | |
| download | python-openstackclient-0069adef5ccec501c36b8da1d2de2821a97afe07.tar.gz | |
Add action 'user password set' for identiy v3
This new action will allow a user to change their own password by
either providing the new password as an argument (--password) or by
being prompted to enter the new password.
In both cases user will be prompted to enter their current password
as required by the v3 API.
Closes-Bug: #1337245
Change-Id: I5e1e0fd2b46a4502318da57f7cce2b236fb2d93d
Diffstat (limited to 'openstackclient/tests')
| -rw-r--r-- | openstackclient/tests/identity/v3/test_user.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/openstackclient/tests/identity/v3/test_user.py b/openstackclient/tests/identity/v3/test_user.py index 569d9140..42df5773 100644 --- a/openstackclient/tests/identity/v3/test_user.py +++ b/openstackclient/tests/identity/v3/test_user.py @@ -13,7 +13,9 @@ # under the License. # +import contextlib import copy + import mock from openstackclient.identity.v3 import user @@ -944,6 +946,52 @@ class TestUserSet(TestUser): ) +class TestUserSetPassword(TestUser): + + def setUp(self): + super(TestUserSetPassword, self).setUp() + self.cmd = user.SetPasswordUser(self.app, None) + + @staticmethod + @contextlib.contextmanager + def _mock_get_password(*passwords): + mocker = mock.Mock(side_effect=passwords) + with mock.patch("openstackclient.common.utils.get_password", mocker): + yield + + def test_user_password_change(self): + current_pass = 'old_pass' + new_pass = 'new_pass' + arglist = [ + '--password', new_pass, + ] + verifylist = [ + ('password', new_pass), + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + # Mock getting user current password. + with self._mock_get_password(current_pass): + self.cmd.take_action(parsed_args) + + self.users_mock.update_password.assert_called_with( + current_pass, new_pass + ) + + def test_user_create_password_prompt(self): + current_pass = 'old_pass' + new_pass = 'new_pass' + parsed_args = self.check_parser(self.cmd, [], []) + + # Mock getting user current and new password. + with self._mock_get_password(current_pass, new_pass): + self.cmd.take_action(parsed_args) + + self.users_mock.update_password.assert_called_with( + current_pass, new_pass + ) + + class TestUserShow(TestUser): def setUp(self): |
