Fix token flush fails with recursion depth exception

keystone-manage token_flush was failing with a recursion depth
exception error. This is because when a property was referenced in
token.persistence.Manager it would go into an infinite recursion
trying to resolve it. token.persistence.PersistenceManager should
have been used instead.

Note that I added a test for keystone.cli TokenFlush, but for some
reason it doesn't actually expose the problem. I'll leave it there
since it increases coverage.

Change-Id: If5af4fe0811a59157c2f68d06c264815409689e1
Closes-Bug: #1363224
This commit is contained in:
Brant Knudson 2014-08-29 14:35:55 -05:00 committed by Morgan Fainberg
parent e0d83776bd
commit 4a587f2bfc
2 changed files with 30 additions and 1 deletions

View File

@ -172,7 +172,7 @@ class TokenFlush(BaseApp):
@classmethod @classmethod
def main(cls): def main(cls):
token_manager = token.persistence.Manager() token_manager = token.persistence.PersistenceManager()
token_manager.driver.flush_expired_tokens() token_manager.driver.flush_expired_tokens()

View File

@ -0,0 +1,29 @@
# Copyright 2014 IBM Corp.
#
# 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 keystone import cli
from keystone import tests
from keystone.tests.ksfixtures import database
class CliTestCase(tests.SQLDriverOverrides, tests.TestCase):
def config_files(self):
config_files = super(CliTestCase, self).config_files()
config_files.append(tests.dirs.tests_conf('backend_sql.conf'))
return config_files
def test_token_flush(self):
self.useFixture(database.Database())
self.load_backends()
cli.TokenFlush.main()