summaryrefslogtreecommitdiff
path: root/openstackclient/tests
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2014-09-07 15:12:18 +0000
committerGerrit Code Review <review@openstack.org>2014-09-07 15:12:18 +0000
commit3317e0abf694c56cb3b24bdf2b2b10577ea47f6b (patch)
treee9d6285ae671ae35f9a2c04100a69c1d21c3b837 /openstackclient/tests
parentdcf658cc4e6c6df4e1543178d78ef70338c95d11 (diff)
parent0069adef5ccec501c36b8da1d2de2821a97afe07 (diff)
downloadpython-openstackclient-3317e0abf694c56cb3b24bdf2b2b10577ea47f6b.tar.gz
Merge "Add action 'user password set' for identiy v3"
Diffstat (limited to 'openstackclient/tests')
-rw-r--r--openstackclient/tests/identity/v3/test_user.py48
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):