diff --git a/functionaltests/__init__.py b/functionaltests/__init__.py index 9b21b312..cdcb9659 100644 --- a/functionaltests/__init__.py +++ b/functionaltests/__init__.py @@ -15,6 +15,7 @@ limitations under the License. """ import os +from oslo.config import cfg from tempest import config @@ -33,3 +34,12 @@ if os.path.exists(conf_file): CONF.set_config_path(conf_file) +CONF.register_group(cfg.OptGroup('keymanager')) +CONF.register_opt(cfg.StrOpt('url'), group='keymanager') +CONF.register_opt(cfg.StrOpt('username'), group='keymanager') +CONF.register_opt(cfg.StrOpt('password'), group='keymanager') +CONF.register_opt(cfg.StrOpt('project_name'), group='keymanager') +CONF.register_opt(cfg.StrOpt('project_id'), group='keymanager') +CONF.register_opt(cfg.IntOpt('max_payload_size', default=10000), + group='keymanager') +CONF.register_opt(cfg.StrOpt('project_domain_name'), group='keymanager') diff --git a/functionaltests/base.py b/functionaltests/base.py new file mode 100644 index 00000000..9df8576f --- /dev/null +++ b/functionaltests/base.py @@ -0,0 +1,51 @@ +""" +Copyright 2015 Rackspace + +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 logging +import os + +import oslotest.base as oslotest +from barbicanclient import client +from keystoneclient.auth import identity +from keystoneclient import session +from tempest import config + +CONF = config.CONF + + +class BaseTestCase(oslotest.BaseTestCase): + max_payload_size = CONF.keymanager.max_payload_size + max_sized_payload = u'a' * max_payload_size + oversized_payload = 'a' * (max_payload_size + 1) + max_field_size = 255 + max_sized_field = 'a' * max_field_size + oversized_field = 'a' * (max_field_size + 1) + + @classmethod + def setUpClass(cls): + cls.LOG = logging.getLogger(cls._get_full_case_name()) + super(BaseTestCase, cls).setUpClass() + + def tearDown(self): + super(BaseTestCase, self).tearDown() + self.LOG.info('Finished: %s\n', self._testMethodName) + + @classmethod + def _get_full_case_name(cls): + name = '{module}:{case_name}'.format( + module=cls.__module__, + case_name=cls.__name__ + ) + return name diff --git a/functionaltests/cli/__init__.py b/functionaltests/cli/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/functionaltests/cli/base.py b/functionaltests/cli/base.py new file mode 100644 index 00000000..45fb3773 --- /dev/null +++ b/functionaltests/cli/base.py @@ -0,0 +1,46 @@ +""" +Copyright 2015 Rackspace + +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 exceptions as exc + +from functionaltests.base import BaseTestCase +from barbicanclient import barbican + + +class CmdLineTestCase(BaseTestCase): + + def setUp(self): + self.LOG.info('Starting: %s', self._testMethodName) + super(CmdLineTestCase, self).setUp() + + self.cmdline_client = barbican.Barbican() + + def issue_barbican_command(self, argv): + """ Issue the barbican command and return its output. + + :param argv: dict of keyword arguments to pass to the command. This + does NOT include "barbican" - that's not needed. + :return: list of strings returned by the command, one list element + per line of output. This means the caller doesn't have to worry about + parsing newlines, etc. If there is a problem then this method + will return None + """ + result = None + try: + self.cmdline_client.run(argv) + except exc.SystemExit: + result = self.cmdline_client.stdout.getvalue() + return result diff --git a/functionaltests/cli/v1/__init__.py b/functionaltests/cli/v1/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/functionaltests/cli/v1/functional/__init__.py b/functionaltests/cli/v1/functional/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/functionaltests/cli/v1/smoke/__init__.py b/functionaltests/cli/v1/smoke/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/functionaltests/cli/v1/smoke/test_help.py b/functionaltests/cli/v1/smoke/test_help.py new file mode 100644 index 00000000..fc9dc7d8 --- /dev/null +++ b/functionaltests/cli/v1/smoke/test_help.py @@ -0,0 +1,38 @@ +# Copyright (c) 2015 Rackspace, Inc. +# +# 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 functionaltests.cli.base import CmdLineTestCase +from functionaltests import utils +from testtools import testcase + + +@utils.parameterized_test_case +class HelpTestCase(CmdLineTestCase): + + def setUp(self): + super(HelpTestCase, self).setUp() + + def tearDown(self): + super(HelpTestCase, self).tearDown() + + @utils.parameterized_dataset({ + 'dash_h': [['-h']], + 'doubledash_help': [['--help']] + }) + @testcase.attr('positive') + def test_help(self, argv): + result = self.issue_barbican_command(argv) + self.assertIsNotNone(result, "{0} returned None".format(argv)) + self.assertGreater(len(result), 0, "{0} invalid length".format(argv)) diff --git a/functionaltests/client/__init__.py b/functionaltests/client/__init__.py index a6e9b3ec..e69de29b 100644 --- a/functionaltests/client/__init__.py +++ b/functionaltests/client/__init__.py @@ -1,36 +0,0 @@ -""" -Copyright 2015 Rackspace - -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 oslo.config import cfg -from tempest import config - -CONF = config.CONF - -# Use local tempest conf if one is available. -# This usually means we're running tests outside of devstack -if os.path.exists('./etc/functional_tests.conf'): - CONF.set_config_path('./etc/functional_tests.conf') - -CONF.register_group(cfg.OptGroup('keymanager')) -CONF.register_opt(cfg.StrOpt('url'), group='keymanager') -CONF.register_opt(cfg.StrOpt('username'), group='keymanager') -CONF.register_opt(cfg.StrOpt('password'), group='keymanager') -CONF.register_opt(cfg.StrOpt('project_name'), group='keymanager') -CONF.register_opt(cfg.StrOpt('project_id'), group='keymanager') -CONF.register_opt(cfg.IntOpt('max_payload_size', default=10000), - group='keymanager') -CONF.register_opt(cfg.StrOpt('project_domain_name'), group='keymanager') diff --git a/functionaltests/client/base.py b/functionaltests/client/base.py index e27a8717..ace11bf2 100644 --- a/functionaltests/client/base.py +++ b/functionaltests/client/base.py @@ -14,9 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. """ import logging -import os -import oslotest.base as oslotest +from functionaltests.base import BaseTestCase from barbicanclient import client from keystoneclient.auth import identity from keystoneclient import session @@ -24,24 +23,8 @@ from tempest import config CONF = config.CONF -# Use local tempest conf if one is available. -# This usually means we're running tests outside of devstack -if os.path.exists('./etc/functional_tests.conf'): - CONF.set_config_path('./etc/functional_tests.conf') - -class TestCase(oslotest.BaseTestCase): - max_payload_size = CONF.keymanager.max_payload_size - max_sized_payload = u'a' * max_payload_size - oversized_payload = 'a' * (max_payload_size + 1) - max_field_size = 255 - max_sized_field = 'a' * max_field_size - oversized_field = 'a' * (max_field_size + 1) - - @classmethod - def setUpClass(cls): - cls.LOG = logging.getLogger(cls._get_full_case_name()) - super(TestCase, cls).setUpClass() +class TestCase(BaseTestCase): def setUp(self): self.LOG.info('Starting: %s', self._testMethodName) @@ -67,15 +50,3 @@ class TestCase(oslotest.BaseTestCase): endpoint=CONF.keymanager.url, project_id=CONF.keymanager.project_id, session=self.sess) - - def tearDown(self): - super(TestCase, self).tearDown() - self.LOG.info('Finished: %s\n', self._testMethodName) - - @classmethod - def _get_full_case_name(cls): - name = '{module}:{case_name}'.format( - module=cls.__module__, - case_name=cls.__name__ - ) - return name