diff options
author | Henry Nash <henryn@linux.vnet.ibm.com> | 2014-10-07 10:01:47 +0100 |
---|---|---|
committer | Henry Nash <henryn@linux.vnet.ibm.com> | 2014-10-07 10:05:44 +0100 |
commit | 8af522af96c4bc0f6d0f7de48f6433fd19115d54 (patch) | |
tree | 9949bf19b02f9cbb5d53c40b351662267cf02df1 | |
parent | 5a615fc637a5a18d1d5d4b9595fe56170d739e7f (diff) | |
download | keystone-8af522af96c4bc0f6d0f7de48f6433fd19115d54.tar.gz |
Remove deprecated KVS trust backend.
The trust backend is one of the KVS backends that was marked as
deprecated, for removal in Kilo. This patch removes it.
Partially implements: bp removed-as-of-kilo
Change-Id: Ib67cd33419d09e219d90ab8c50d375964a12640c
-rw-r--r-- | keystone/tests/core.py | 2 | ||||
-rw-r--r-- | keystone/tests/test_backend_kvs.py | 23 | ||||
-rw-r--r-- | keystone/trust/backends/kvs.py | 121 |
3 files changed, 1 insertions, 145 deletions
diff --git a/keystone/tests/core.py b/keystone/tests/core.py index a22afdff3..9e69f970c 100644 --- a/keystone/tests/core.py +++ b/keystone/tests/core.py @@ -378,7 +378,7 @@ class TestCase(BaseTestCase): driver='keystone.token.persistence.backends.kvs.Token') self.config_fixture.config( group='trust', - driver='keystone.trust.backends.kvs.Trust') + driver='keystone.trust.backends.sql.Trust') self.config_fixture.config( group='saml', certfile=signing_certfile, keyfile=signing_keyfile) self.config_fixture.config( diff --git a/keystone/tests/test_backend_kvs.py b/keystone/tests/test_backend_kvs.py index 1b70451ac..52b5003d9 100644 --- a/keystone/tests/test_backend_kvs.py +++ b/keystone/tests/test_backend_kvs.py @@ -20,8 +20,6 @@ import six from keystone import config from keystone import exception from keystone import tests -from keystone.tests import default_fixtures -from keystone.tests.ksfixtures import database from keystone.tests import test_backend @@ -104,24 +102,6 @@ class KvsToken(tests.TestCase, test_backend.TokenTests): self.assertEqual(expected_user_token_list, user_token_list) -class KvsTrust(tests.TestCase, test_backend.TrustTests): - def setUp(self): - super(KvsTrust, self).setUp() - # Need to load the SQL database support for the fixtures - self.useFixture(database.Database()) - self.load_backends() - self.load_fixtures(default_fixtures) - - def config_overrides(self): - super(KvsTrust, self).config_overrides() - self.config_fixture.config( - group='trust', - driver='keystone.trust.backends.kvs.Trust') - self.config_fixture.config( - group='catalog', - driver='keystone.catalog.backends.kvs.Catalog') - - class KvsCatalog(tests.TestCase, test_backend.CatalogTests): def setUp(self): super(KvsCatalog, self).setUp() @@ -131,9 +111,6 @@ class KvsCatalog(tests.TestCase, test_backend.CatalogTests): def config_overrides(self): super(KvsCatalog, self).config_overrides() self.config_fixture.config( - group='trust', - driver='keystone.trust.backends.kvs.Trust') - self.config_fixture.config( group='catalog', driver='keystone.catalog.backends.kvs.Catalog') diff --git a/keystone/trust/backends/kvs.py b/keystone/trust/backends/kvs.py deleted file mode 100644 index e5b049fed..000000000 --- a/keystone/trust/backends/kvs.py +++ /dev/null @@ -1,121 +0,0 @@ -# Copyright 2012 OpenStack Foundation -# -# 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. -""" -An in memory implementation of the trusts API. -only to be used for testing purposes -""" -import copy - -from oslo.utils import timeutils - -from keystone.common import kvs -from keystone import exception -from keystone.openstack.common import versionutils -from keystone import trust as keystone_trust - - -def _filter_trust(ref, deleted=False): - if ref['deleted_at'] and not deleted: - return None - if (ref.get('expires_at') and timeutils.utcnow() > ref['expires_at'] and - not deleted): - return None - remaining_uses = ref.get('remaining_uses') - # Do not return trusts that can't be used anymore - if remaining_uses is not None and not deleted: - if remaining_uses <= 0: - return None - ref = copy.deepcopy(ref) - return ref - - -class Trust(kvs.Base, keystone_trust.Driver): - - @versionutils.deprecated(versionutils.deprecated.JUNO, - in_favor_of='keystone.trust.backends.sql', - remove_in=+1, - what='keystone.trust.backends.kvs') - def __init__(self): - super(Trust, self).__init__() - - def create_trust(self, trust_id, trust, roles): - trust_ref = copy.deepcopy(trust) - trust_ref['id'] = trust_id - trust_ref['deleted_at'] = None - trust_ref['roles'] = roles - if (trust_ref.get('expires_at') and - trust_ref['expires_at'].tzinfo is not None): - trust_ref['expires_at'] = (timeutils.normalize_time - (trust_ref['expires_at'])) - - self.db.set('trust-%s' % trust_id, trust_ref) - trustee_user_id = trust_ref['trustee_user_id'] - trustee_list = self.db.get('trustee-%s' % trustee_user_id, []) - trustee_list.append(trust_id) - self.db.set('trustee-%s' % trustee_user_id, trustee_list) - trustor_user_id = trust_ref['trustor_user_id'] - trustor_list = self.db.get('trustor-%s' % trustor_user_id, []) - trustor_list.append(trust_id) - self.db.set('trustor-%s' % trustor_user_id, trustor_list) - return trust_ref - - def consume_use(self, trust_id): - try: - orig_ref = self.db.get('trust-%s' % trust_id) - except exception.NotFound: - raise exception.TrustNotFound(trust_id=trust_id) - remaining_uses = orig_ref.get('remaining_uses') - if remaining_uses is None: - # unlimited uses, do nothing - return - elif remaining_uses > 0: - ref = copy.deepcopy(orig_ref) - ref['remaining_uses'] -= 1 - self.db.set('trust-%s' % trust_id, ref) - else: - raise exception.TrustUseLimitReached(trust_id=trust_id) - - def get_trust(self, trust_id, deleted=False): - try: - ref = self.db.get('trust-%s' % trust_id) - return _filter_trust(ref, deleted=deleted) - except exception.NotFound: - return None - - def delete_trust(self, trust_id): - try: - ref = self.db.get('trust-%s' % trust_id) - except exception.NotFound: - raise exception.TrustNotFound(trust_id=trust_id) - ref['deleted_at'] = timeutils.utcnow() - self.db.set('trust-%s' % trust_id, ref) - - def list_trusts(self): - trusts = [] - for key, value in self.db.items(): - if key.startswith("trust-") and not value['deleted_at']: - trusts.append(value) - return trusts - - def list_trusts_for_trustee(self, trustee_user_id): - trusts = [] - for trust in self.db.get('trustee-%s' % trustee_user_id, []): - trusts.append(self.get_trust(trust)) - return trusts - - def list_trusts_for_trustor(self, trustor_user_id): - trusts = [] - for trust in self.db.get('trustor-%s' % trustor_user_id, []): - trusts.append(self.get_trust(trust)) - return trusts |