diff options
| author | Stephen Finucane <sfinucan@redhat.com> | 2020-11-18 15:38:18 +0000 |
|---|---|---|
| committer | Stephen Finucane <sfinucan@redhat.com> | 2021-01-08 12:14:41 +0000 |
| commit | 8a0f3fc6a8b30328c575bb5c3fc21ddc4f500d9d (patch) | |
| tree | 3242d6a349c81f62f7bc43d6d334bd805b41fd11 /openstackclient/tests/unit/compute | |
| parent | 9a976ada8e79fa04e331bd38564892d77deef40c (diff) | |
| download | python-openstackclient-8a0f3fc6a8b30328c575bb5c3fc21ddc4f500d9d.tar.gz | |
compute: Add missing options for 'server set'
Add a new '--no-password' option to unset the password on an existing
server. In addition, add a new '--password' option that replaces the
interactive '--root-password' option. This makes sense given no other
commands uses interactive password options.
Checks that rely on specific API microversions now run before we execute
any action, to avoid situations where an update is only partially
applied.
Change-Id: Ibf8717efdd418a2d95215b4d9ab2acf0d57c4a70
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
Diffstat (limited to 'openstackclient/tests/unit/compute')
| -rw-r--r-- | openstackclient/tests/unit/compute/v2/test_server.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/openstackclient/tests/unit/compute/v2/test_server.py b/openstackclient/tests/unit/compute/v2/test_server.py index f046925a..0f33dd70 100644 --- a/openstackclient/tests/unit/compute/v2/test_server.py +++ b/openstackclient/tests/unit/compute/v2/test_server.py @@ -6207,6 +6207,7 @@ class TestServerSet(TestServer): 'update': None, 'reset_state': None, 'change_password': None, + 'clear_password': None, 'add_tag': None, 'set_tags': None, } @@ -6290,6 +6291,37 @@ class TestServerSet(TestServer): self.fake_servers[0], parsed_args.properties) self.assertIsNone(result) + def test_server_set_with_password(self): + arglist = [ + '--password', 'foo', + 'foo_vm', + ] + verifylist = [ + ('password', 'foo'), + ('server', 'foo_vm'), + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + self.cmd.take_action(parsed_args) + + self.fake_servers[0].change_password.assert_called_once_with('foo') + + def test_server_set_with_no_password(self): + arglist = [ + '--no-password', + 'foo_vm', + ] + verifylist = [ + ('no_password', True), + ('server', 'foo_vm'), + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + self.cmd.take_action(parsed_args) + + self.fake_servers[0].clear_password.assert_called_once_with() + + # TODO(stephenfin): Remove this in a future major version @mock.patch.object(getpass, 'getpass', return_value=mock.sentinel.fake_pass) def test_server_set_with_root_password(self, mock_getpass): |
