From 341f07582ef5aa782c817ab2feab5828ac15c003 Mon Sep 17 00:00:00 2001 From: Rui Chen Date: Sat, 1 Apr 2017 14:52:21 +0800 Subject: [PATCH] Add help commands withouth auth in functional A special scenairo is that users want to check the commands help message, but don't set authentication info at all. Add a related functional test case to cover it. Change-Id: I7b09701df24d6f6dfcf369f89212f72e753be6e4 --- .../tests/functional/common/test_help.py | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/openstackclient/tests/functional/common/test_help.py b/openstackclient/tests/functional/common/test_help.py index 211c52b1de..e31d3b869c 100644 --- a/openstackclient/tests/functional/common/test_help.py +++ b/openstackclient/tests/functional/common/test_help.py @@ -10,6 +10,8 @@ # License for the specific language governing permissions and limitations # under the License. +import os + from openstackclient.tests.functional import base @@ -71,3 +73,48 @@ class HelpTests(base.TestCase): self.assertIn('List networks', raw_output) raw_output = self.openstack('network create --help') self.assertIn('Create new network', raw_output) + + def test_commands_help_no_auth(self): + """Check help commands without auth info.""" + # Pop all auth info + auth_info = {key: os.environ.pop(key) + for key in os.environ.keys() + if key.startswith('OS_')} + + raw_output = self.openstack('help') + self.assertIn('usage: openstack', raw_output) + raw_output = self.openstack('--help') + self.assertIn('usage: openstack', raw_output) + + raw_output = self.openstack('help network list') + self.assertIn('List networks', raw_output) + raw_output = self.openstack('network list --help') + self.assertIn('List networks', raw_output) + + raw_output = self.openstack('help volume list') + self.assertIn('List volumes', raw_output) + raw_output = self.openstack('volume list --help') + self.assertIn('List volumes', raw_output) + + raw_output = self.openstack('help server list') + self.assertIn('List servers', raw_output) + raw_output = self.openstack('server list --help') + self.assertIn('List servers', raw_output) + + raw_output = self.openstack('help user list') + self.assertIn('List users', raw_output) + raw_output = self.openstack('user list --help') + self.assertIn('List users', raw_output) + + raw_output = self.openstack('help image list') + self.assertIn('List available images', raw_output) + raw_output = self.openstack('image list --help') + self.assertIn('List available images', raw_output) + + raw_output = self.openstack('help container list') + self.assertIn('List containers', raw_output) + raw_output = self.openstack('container list --help') + self.assertIn('List containers', raw_output) + + # Restore auth info + os.environ.update(auth_info)