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
This commit is contained in:
wangxiyuan 2018-09-05 10:21:51 +08:00
parent 2803f49cb1
commit 4fb7fef1ea
3 changed files with 21 additions and 2 deletions

View File

@ -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')

View File

@ -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,

View File

@ -0,0 +1,7 @@
---
fixes:
- >
[`bug 1789351 <https://bugs.launchpad.net/keystonemiddleware/+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.