From 4fb7fef1eab2a981b8e366091073b6ee2d80ee6a Mon Sep 17 00:00:00 2001 From: wangxiyuan Date: Wed, 5 Sep 2018 10:21:51 +0800 Subject: [PATCH] No need to compare CONF content When setup AuthProtocol class, if the CONF object contains deprecated options, An Error "dictionary changed size during iteration" will raise when comparing the CONF content. Changing "!=" to "is not" here to avoid compare the CONF content anymore. Change-Id: I820aa244160db4f81149d2576386c86b46de0084 Closes-bug: #1789351 --- keystonemiddleware/auth_token/__init__.py | 2 +- .../tests/unit/auth_token/test_config.py | 14 +++++++++++++- .../notes/bug-1789351-102e2e5119be38b4.yaml | 7 +++++++ 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/bug-1789351-102e2e5119be38b4.yaml diff --git a/keystonemiddleware/auth_token/__init__.py b/keystonemiddleware/auth_token/__init__.py index 46a6b1e5..4ac73886 100644 --- a/keystonemiddleware/auth_token/__init__.py +++ b/keystonemiddleware/auth_token/__init__.py @@ -548,7 +548,7 @@ class AuthProtocol(BaseAuthProtocol): _base.AUTHTOKEN_GROUP, list_opts(), conf) - if self._conf.oslo_conf_obj != cfg.CONF: + if self._conf.oslo_conf_obj is not cfg.CONF: oslo_cache.configure(self._conf.oslo_conf_obj) token_roles_required = self._conf.get('service_token_roles_required') diff --git a/keystonemiddleware/tests/unit/auth_token/test_config.py b/keystonemiddleware/tests/unit/auth_token/test_config.py index 6b824afe..6a253a11 100644 --- a/keystonemiddleware/tests/unit/auth_token/test_config.py +++ b/keystonemiddleware/tests/unit/auth_token/test_config.py @@ -60,7 +60,9 @@ class TestAuthPluginLocalOsloConfig(base.BaseAuthTokenTestCase): 'password': uuid.uuid4().hex, } - content = ("[keystone_authtoken]\n" + content = ("[DEFAULT]\n" + "test_opt=15\n" + "[keystone_authtoken]\n" "auth_type=%(auth_type)s\n" "www_authenticate_uri=%(www_authenticate_uri)s\n" "auth_url=%(www_authenticate_uri)s\n" @@ -99,6 +101,16 @@ class TestAuthPluginLocalOsloConfig(base.BaseAuthTokenTestCase): self.assertEqual(self.oslo_options[option], conf_get(app, option)) + def test_passed_oslo_configuration_with_deprecated_ones(self): + deprecated_opt = cfg.IntOpt('test_opt', deprecated_for_removal=True) + cfg.CONF.register_opt(deprecated_opt) + cfg.CONF(args=[], + default_config_files=[self.conf_file_fixture.path]) + conf = {'oslo_config_config': cfg.CONF} + + # success to init AuthProtocol + self._create_app(conf) + def test_passed_oslo_configuration_wins(self): """oslo_config_config has precedence over oslo_config_project.""" conf = {'oslo_config_project': self.project, diff --git a/releasenotes/notes/bug-1789351-102e2e5119be38b4.yaml b/releasenotes/notes/bug-1789351-102e2e5119be38b4.yaml new file mode 100644 index 00000000..65f5555f --- /dev/null +++ b/releasenotes/notes/bug-1789351-102e2e5119be38b4.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - > + [`bug 1789351 `_] + Fixed the bug that when initialize `AuthProtocol`, it'll raise "dictionary + changed size during iteration" error if the input `CONF` object contains + deprecated options.