summaryrefslogtreecommitdiff
path: root/keystoneclient/tests
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-03-04 00:40:15 +0000
committerGerrit Code Review <review@openstack.org>2015-03-04 00:40:15 +0000
commit94e01e20d1f27a44b0543734f3125077cd06fc88 (patch)
tree36dc7a9743cb00e9be3e96225df1271aaefd1e88 /keystoneclient/tests
parent3e2035bf8823f87cb736a526d4f084487066d33e (diff)
parent0ef042c72393b61f32a351eda04996f3eb6b7e59 (diff)
downloadpython-keystoneclient-94e01e20d1f27a44b0543734f3125077cd06fc88.tar.gz
Merge "Import functional CLI tests from tempest"
Diffstat (limited to 'keystoneclient/tests')
-rw-r--r--keystoneclient/tests/functional/base.py32
-rw-r--r--keystoneclient/tests/functional/test_cli.py143
-rw-r--r--keystoneclient/tests/functional/test_fake.py25
3 files changed, 143 insertions, 57 deletions
diff --git a/keystoneclient/tests/functional/base.py b/keystoneclient/tests/functional/base.py
deleted file mode 100644
index 2f8eff5..0000000
--- a/keystoneclient/tests/functional/base.py
+++ /dev/null
@@ -1,32 +0,0 @@
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import os
-
-from tempest_lib.cli import base
-
-
-class TestCase(base.ClientTestBase):
-
- def _get_clients(self):
- path = os.path.join(os.path.abspath('.'), '.tox/functional/bin')
- cli_dir = os.environ.get('OS_KEYSTONECLIENT_EXEC_DIR', path)
-
- return base.CLIClient(
- username=os.environ.get('OS_USERNAME'),
- password=os.environ.get('OS_PASSWORD'),
- tenant_name=os.environ.get('OS_TENANT_NAME'),
- uri=os.environ.get('OS_AUTH_URL'),
- cli_dir=cli_dir)
-
- def keystone(self, *args, **kwargs):
- return self.clients.keystone(*args, **kwargs)
diff --git a/keystoneclient/tests/functional/test_cli.py b/keystoneclient/tests/functional/test_cli.py
new file mode 100644
index 0000000..8400e7c
--- /dev/null
+++ b/keystoneclient/tests/functional/test_cli.py
@@ -0,0 +1,143 @@
+
+# Copyright 2013 OpenStack Foundation
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import os
+import re
+
+from tempest_lib.cli import base
+from tempest_lib import exceptions
+
+
+class SimpleReadOnlyKeystoneClientTest(base.ClientTestBase):
+ """Basic, read-only tests for Keystone CLI client.
+
+ Checks return values and output of read-only commands.
+ These tests do not presume any content, nor do they create
+ their own. They only verify the structure of output if present.
+ """
+
+ def _get_clients(self):
+ path = os.path.join(os.path.abspath('.'), '.tox/functional/bin')
+ cli_dir = os.environ.get('OS_KEYSTONECLIENT_EXEC_DIR', path)
+
+ return base.CLIClient(
+ username=os.environ.get('OS_USERNAME'),
+ password=os.environ.get('OS_PASSWORD'),
+ tenant_name=os.environ.get('OS_TENANT_NAME'),
+ uri=os.environ.get('OS_AUTH_URL'),
+ cli_dir=cli_dir)
+
+ def keystone(self, *args, **kwargs):
+ return self.clients.keystone(*args, **kwargs)
+
+ def test_admin_fake_action(self):
+ self.assertRaises(exceptions.CommandFailed,
+ self.keystone,
+ 'this-does-not-exist')
+
+ def test_admin_catalog_list(self):
+ out = self.keystone('catalog')
+ catalog = self.parser.details_multiple(out, with_label=True)
+ for svc in catalog:
+ if svc.get('__label'):
+ self.assertTrue(svc['__label'].startswith('Service:'),
+ msg=('Invalid beginning of service block: '
+ '%s' % svc['__label']))
+ # check that region and publicURL exists. One might also
+ # check for adminURL and internalURL. id seems to be optional
+ # and is missing in the catalog backend
+ self.assertIn('publicURL', svc.keys())
+ self.assertIn('region', svc.keys())
+
+ def test_admin_endpoint_list(self):
+ out = self.keystone('endpoint-list')
+ endpoints = self.parser.listing(out)
+ self.assertTableStruct(endpoints, [
+ 'id', 'region', 'publicurl', 'internalurl',
+ 'adminurl', 'service_id'])
+
+ def test_admin_endpoint_service_match(self):
+ endpoints = self.parser.listing(self.keystone('endpoint-list'))
+ services = self.parser.listing(self.keystone('service-list'))
+ svc_by_id = {}
+ for svc in services:
+ svc_by_id[svc['id']] = svc
+ for endpoint in endpoints:
+ self.assertIn(endpoint['service_id'], svc_by_id)
+
+ def test_admin_role_list(self):
+ roles = self.parser.listing(self.keystone('role-list'))
+ self.assertTableStruct(roles, ['id', 'name'])
+
+ def test_admin_service_list(self):
+ services = self.parser.listing(self.keystone('service-list'))
+ self.assertTableStruct(services, ['id', 'name', 'type', 'description'])
+
+ def test_admin_tenant_list(self):
+ tenants = self.parser.listing(self.keystone('tenant-list'))
+ self.assertTableStruct(tenants, ['id', 'name', 'enabled'])
+
+ def test_admin_user_list(self):
+ users = self.parser.listing(self.keystone('user-list'))
+ self.assertTableStruct(users, [
+ 'id', 'name', 'enabled', 'email'])
+
+ def test_admin_user_role_list(self):
+ user_roles = self.parser.listing(self.keystone('user-role-list'))
+ self.assertTableStruct(user_roles, [
+ 'id', 'name', 'user_id', 'tenant_id'])
+
+ def test_admin_discover(self):
+ discovered = self.keystone('discover')
+ self.assertIn('Keystone found at http', discovered)
+ self.assertIn('supports version', discovered)
+
+ def test_admin_help(self):
+ help_text = self.keystone('help')
+ lines = help_text.split('\n')
+ self.assertFirstLineStartsWith(lines, 'usage: keystone')
+
+ commands = []
+ cmds_start = lines.index('Positional arguments:')
+ cmds_end = lines.index('Optional arguments:')
+ command_pattern = re.compile('^ {4}([a-z0-9\-\_]+)')
+ for line in lines[cmds_start:cmds_end]:
+ match = command_pattern.match(line)
+ if match:
+ commands.append(match.group(1))
+ commands = set(commands)
+ wanted_commands = set(('catalog', 'endpoint-list', 'help',
+ 'token-get', 'discover', 'bootstrap'))
+ self.assertFalse(wanted_commands - commands)
+
+ def test_admin_bashcompletion(self):
+ self.keystone('bash-completion')
+
+ def test_admin_ec2_credentials_list(self):
+ creds = self.keystone('ec2-credentials-list')
+ creds = self.parser.listing(creds)
+ self.assertTableStruct(creds, ['tenant', 'access', 'secret'])
+
+ # Optional arguments:
+
+ def test_admin_version(self):
+ self.keystone('', flags='--version')
+
+ def test_admin_debug_list(self):
+ self.keystone('catalog', flags='--debug')
+
+ def test_admin_timeout(self):
+ self.keystone('catalog', flags='--timeout %d' % 15)
diff --git a/keystoneclient/tests/functional/test_fake.py b/keystoneclient/tests/functional/test_fake.py
deleted file mode 100644
index 3aecba2..0000000
--- a/keystoneclient/tests/functional/test_fake.py
+++ /dev/null
@@ -1,25 +0,0 @@
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from keystoneclient.tests.functional import base
-
-
-class FakeTests(base.TestCase):
-
- # NOTE(jamielennox): These are purely to have something that passes to
- # submit to the gate. After that is working this file can be removed and
- # the real tests can begin to be ported from tempest.
-
- def test_version(self):
- # NOTE(jamilennox): lol, 1st bug: version goes to stderr - can't test
- # value, however it tests that return value = 0 automatically.
- self.keystone('', flags='--version')