summaryrefslogtreecommitdiff
path: root/cinderclient/tests/unit
diff options
context:
space:
mode:
authorAbhijeet Malawade <abhijeet.malawade@gmail.com>2016-04-27 04:40:17 +0530
committerAbhijeet Malawade <abhijeet.malawade@gmail.com>2016-04-27 06:37:19 +0530
commit24deab10906670a50129d7cb4974a8dff6aca687 (patch)
tree5ed7c93135f9c8f461068feff6a733cc8323aad7 /cinderclient/tests/unit
parent8d79acda0f5ff0e33ece7c84e65f5168b9b465bf (diff)
downloadpython-cinderclient-24deab10906670a50129d7cb4974a8dff6aca687.tar.gz
Fix authentication issue
Fix authentication issue if password is provided from tty prompt. Set options.os_password to user input from prompt, as it gets used to create auth object otherwise it will give authentication error. Change-Id: I0246473f2165f1464d731e0ae9b4afa0b61dcbcc Closes-Bug: #1575656
Diffstat (limited to 'cinderclient/tests/unit')
-rw-r--r--cinderclient/tests/unit/test_shell.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/cinderclient/tests/unit/test_shell.py b/cinderclient/tests/unit/test_shell.py
index a2439f2..5319543 100644
--- a/cinderclient/tests/unit/test_shell.py
+++ b/cinderclient/tests/unit/test_shell.py
@@ -142,6 +142,7 @@ class ShellTest(utils.TestCase):
for count in range(1, 4):
self.list_volumes_on_service(count)
+ @mock.patch('keystoneclient.auth.identity.v2.Password')
@mock.patch('keystoneclient.adapter.Adapter.get_token',
side_effect=ks_exc.ConnectionRefused())
@mock.patch('keystoneclient.discover.Discover',
@@ -149,11 +150,19 @@ class ShellTest(utils.TestCase):
@mock.patch('sys.stdin', side_effect=mock.MagicMock)
@mock.patch('getpass.getpass', return_value='password')
def test_password_prompted(self, mock_getpass, mock_stdin, mock_discover,
- mock_token):
+ mock_token, mock_password):
self.make_env(exclude='OS_PASSWORD')
_shell = shell.OpenStackCinderShell()
self.assertRaises(ks_exc.ConnectionRefused, _shell.main, ['list'])
mock_getpass.assert_called_with('OS Password: ')
+ # Verify that Password() is called with value of param 'password'
+ # equal to mock_getpass.return_value.
+ mock_password.assert_called_with(
+ self.FAKE_ENV['OS_AUTH_URL'],
+ password=mock_getpass.return_value,
+ tenant_id='',
+ tenant_name=self.FAKE_ENV['OS_TENANT_NAME'],
+ username=self.FAKE_ENV['OS_USERNAME'])
@mock.patch.object(requests, "request")
@mock.patch.object(pkg_resources, "iter_entry_points")