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
This commit is contained in:
Eric Brown
2014-01-14 09:19:42 -08:00
parent 23ac57383d
commit ec5d31dbb5

View File

@@ -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')