From ec5d31dbb5e3ec9563a42f907bbd8c912cf7dcb9 Mon Sep 17 00:00:00 2001 From: Eric Brown Date: Tue, 14 Jan 2014 09:19:42 -0800 Subject: [PATCH] Interactive prompt for create user Execution of the shell will now prompt the user for a password if argument '--pass' is specified without a following parameter. In that way, a user does not need to pass passwords on the command line. Usage example: $ keystone user-create --name bob --tenant admin --pass --enabled true New Password: Repeat New Password: Closes-Bug: #1100116 Change-Id: I1f6d6322830972dfad19ebe2fe63e91f82ed8033 --- v2_0/test_shell.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/v2_0/test_shell.py b/v2_0/test_shell.py index 645ab65..54ca0d4 100644 --- a/v2_0/test_shell.py +++ b/v2_0/test_shell.py @@ -13,6 +13,7 @@ import os import sys +import mock from mox3 import stubout import six from testtools import matchers @@ -102,6 +103,20 @@ class ShellTests(utils.TestCase): 'name': 'new-user', 'tenantId': None}}) + @mock.patch('sys.stdin', autospec=True) + def test_user_create_password_prompt(self, mock_stdin): + with mock.patch('getpass.getpass') as mock_getpass: + mock_getpass.return_value = 'newpass' + self.run_command('user-create --name new-user --pass') + self.fake_client.assert_called_anytime( + 'POST', '/users', + {'user': + {'email': None, + 'password': 'newpass', + 'enabled': True, + 'name': 'new-user', + 'tenantId': None}}) + def test_user_get(self): self.run_command('user-get 1') self.fake_client.assert_called_anytime('GET', '/users/1')