diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-03-20 04:55:46 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-03-20 04:55:46 +0000 |
| commit | 3a70a2f9281fdfec6f770cfb60fcd2dce5a77c5f (patch) | |
| tree | bda536f5e8ec77339c6185bb0bc409abdb2e0545 /tests | |
| parent | 632fb0a8cb4eddf76ce0695472601d69115149a9 (diff) | |
| parent | 193374af3860e17ed03bb0431d823046079ae444 (diff) | |
| download | keystone-3a70a2f9281fdfec6f770cfb60fcd2dce5a77c5f.tar.gz keystone-3a70a2f9281fdfec6f770cfb60fcd2dce5a77c5f.tar.xz keystone-3a70a2f9281fdfec6f770cfb60fcd2dce5a77c5f.zip | |
Merge "Fixes LP #954089 - Service list templated catalog"
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/backend_sql.conf | 3 | ||||
| -rw-r--r-- | tests/default_fixtures.py | 21 | ||||
| -rw-r--r-- | tests/test_backend.py | 20 | ||||
| -rw-r--r-- | tests/test_backend_kvs.py | 7 | ||||
| -rw-r--r-- | tests/test_backend_templated.py | 57 | ||||
| -rw-r--r-- | tests/test_keystoneclient.py | 8 |
6 files changed, 105 insertions, 11 deletions
diff --git a/tests/backend_sql.conf b/tests/backend_sql.conf index bbe4343a..a9ca1239 100644 --- a/tests/backend_sql.conf +++ b/tests/backend_sql.conf @@ -13,3 +13,6 @@ driver = keystone.token.backends.sql.Token [ec2] driver = keystone.contrib.ec2.backends.sql.Ec2 + +[catalog] +driver = keystone.catalog.backends.sql.Catalog diff --git a/tests/default_fixtures.py b/tests/default_fixtures.py index 74f419a8..177d6824 100644 --- a/tests/default_fixtures.py +++ b/tests/default_fixtures.py @@ -39,3 +39,24 @@ ROLES = [ {'id': 'keystone_admin', 'name': 'Keystone Admin'}, {'id': 'useless', 'name': 'Useless'}, ] + +SERVICES = [ + { + 'id': 'COMPUTE_ID', + 'type': 'compute', + 'name': 'Nova', + 'description': 'OpenStack Compute service' + }, + { + 'id': 'IDENTITY_ID', + 'type': 'identity', + 'name': 'Keystone', + 'description': 'OpenStack Identity service' + }, + { + 'id': 'IMAGE_ID', + 'type': 'image', + 'name': 'Glance', + 'description': 'OpenStack Image service' + }, +] diff --git a/tests/test_backend.py b/tests/test_backend.py index 0bf01174..658f864d 100644 --- a/tests/test_backend.py +++ b/tests/test_backend.py @@ -317,3 +317,23 @@ class TokenTests(object): self.assertDictEquals(data_ref, data) new_data_ref = self.token_api.get_token(token_id) self.assertEqual(data_ref, new_data_ref) + + +class CatalogTests(object): + + def test_service_crud(self): + new_service = {'id': 'MY_SERVICE', 'type': 'myservice', + 'name': 'My Service', 'description': 'My description'} + res = self.catalog_api.create_service(new_service['id'], new_service) + self.assertDictEquals(res, new_service) + + service_id = new_service['id'] + self.catalog_api.delete_service(service_id) + self.assertRaises(exception.ServiceNotFound, + self.catalog_api.delete_service, service_id) + self.assertRaises(exception.ServiceNotFound, + self.catalog_api.get_service, service_id) + + def test_service_list(self): + services = self.catalog_api.list_services() + self.assertEqual(3, len(services)) diff --git a/tests/test_backend_kvs.py b/tests/test_backend_kvs.py index 0f24c429..6dc626e5 100644 --- a/tests/test_backend_kvs.py +++ b/tests/test_backend_kvs.py @@ -35,13 +35,14 @@ class KvsToken(test.TestCase, test_backend.TokenTests): self.token_api = token_kvs.Token(db={}) -class KvsCatalog(test.TestCase): +class KvsCatalog(test.TestCase, test_backend.CatalogTests): def setUp(self): super(KvsCatalog, self).setUp() self.catalog_api = catalog_kvs.Catalog(db={}) - self._load_fixtures() + self.load_fixtures(default_fixtures) + self._load_fake_catalog() - def _load_fixtures(self): + def _load_fake_catalog(self): self.catalog_foobar = self.catalog_api._create_catalog( 'foo', 'bar', {'RegionFoo': {'service_bar': {'foo': 'bar'}}}) diff --git a/tests/test_backend_templated.py b/tests/test_backend_templated.py new file mode 100644 index 00000000..3773cc99 --- /dev/null +++ b/tests/test_backend_templated.py @@ -0,0 +1,57 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2012 OpenStack LLC +# +# 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 keystone import test +from keystone.catalog.backends import templated as catalog_templated + +import test_backend +import default_fixtures + +DEFAULT_CATALOG_TEMPLATES = os.path.abspath(os.path.join( + os.path.dirname(__file__), + 'default_catalog.templates')) + + +class TestTemplatedCatalog(test.TestCase, test_backend.CatalogTests): + + DEFAULT_FIXTURE = { + 'RegionOne': { + 'compute': { + 'adminURL': 'http://localhost:8774/v1.1/bar', + 'publicURL': 'http://localhost:8774/v1.1/bar', + 'internalURL': 'http://localhost:8774/v1.1/bar', + 'name': "'Compute Service'" + }, + 'identity': { + 'adminURL': 'http://localhost:35357/v2.0', + 'publicURL': 'http://localhost:5000/v2.0', + 'internalURL': 'http://localhost:35357/v2.0', + 'name': "'Identity Service'" + } + } + } + + def setUp(self): + super(TestTemplatedCatalog, self).setUp() + self.opt_in_group('catalog', template_file=DEFAULT_CATALOG_TEMPLATES) + self.catalog_api = catalog_templated.TemplatedCatalog() + self.load_fixtures(default_fixtures) + + def test_get_catalog(self): + catalog_ref = self.catalog_api.get_catalog('foo', 'bar') + self.assertDictEquals(catalog_ref, self.DEFAULT_FIXTURE) diff --git a/tests/test_keystoneclient.py b/tests/test_keystoneclient.py index 4029ea76..7241ca6b 100644 --- a/tests/test_keystoneclient.py +++ b/tests/test_keystoneclient.py @@ -175,14 +175,6 @@ class KeystoneClientTests(object): self.get_client, user_ref) - # TODO(termie): I'm not really sure that this is testing much - def test_endpoints(self): - raise nose.exc.SkipTest('Not implemented due to bug 933555') - - client = self.get_client(admin=True) - token = client.auth_token - endpoints = client.tokens.endpoints(token=token) - # FIXME(ja): this test should require the "keystone:admin" roled # (probably the role set via --keystone_admin_role flag) # FIXME(ja): add a test that admin endpoint is only sent to admin user |
