Browse Source

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
wangxiyuan 7 months ago
parent
commit
4fb7fef1ea

+ 1
- 1
keystonemiddleware/auth_token/__init__.py View File

@@ -548,7 +548,7 @@ class AuthProtocol(BaseAuthProtocol):
548 548
                                    _base.AUTHTOKEN_GROUP,
549 549
                                    list_opts(),
550 550
                                    conf)
551
-        if self._conf.oslo_conf_obj != cfg.CONF:
551
+        if self._conf.oslo_conf_obj is not cfg.CONF:
552 552
             oslo_cache.configure(self._conf.oslo_conf_obj)
553 553
 
554 554
         token_roles_required = self._conf.get('service_token_roles_required')

+ 13
- 1
keystonemiddleware/tests/unit/auth_token/test_config.py View File

@@ -60,7 +60,9 @@ class TestAuthPluginLocalOsloConfig(base.BaseAuthTokenTestCase):
60 60
             'password': uuid.uuid4().hex,
61 61
         }
62 62
 
63
-        content = ("[keystone_authtoken]\n"
63
+        content = ("[DEFAULT]\n"
64
+                   "test_opt=15\n"
65
+                   "[keystone_authtoken]\n"
64 66
                    "auth_type=%(auth_type)s\n"
65 67
                    "www_authenticate_uri=%(www_authenticate_uri)s\n"
66 68
                    "auth_url=%(www_authenticate_uri)s\n"
@@ -99,6 +101,16 @@ class TestAuthPluginLocalOsloConfig(base.BaseAuthTokenTestCase):
99 101
             self.assertEqual(self.oslo_options[option],
100 102
                              conf_get(app, option))
101 103
 
104
+    def test_passed_oslo_configuration_with_deprecated_ones(self):
105
+        deprecated_opt = cfg.IntOpt('test_opt', deprecated_for_removal=True)
106
+        cfg.CONF.register_opt(deprecated_opt)
107
+        cfg.CONF(args=[],
108
+                 default_config_files=[self.conf_file_fixture.path])
109
+        conf = {'oslo_config_config': cfg.CONF}
110
+
111
+        # success to init AuthProtocol
112
+        self._create_app(conf)
113
+
102 114
     def test_passed_oslo_configuration_wins(self):
103 115
         """oslo_config_config has precedence over oslo_config_project."""
104 116
         conf = {'oslo_config_project': self.project,

+ 7
- 0
releasenotes/notes/bug-1789351-102e2e5119be38b4.yaml View File

@@ -0,0 +1,7 @@
1
+---
2
+fixes:
3
+  - >
4
+    [`bug 1789351 <https://bugs.launchpad.net/keystonemiddleware/+bug/1789351>`_]
5
+    Fixed the bug that when initialize `AuthProtocol`, it'll raise "dictionary
6
+    changed size during iteration" error if the input `CONF` object contains
7
+    deprecated options.

Loading…
Cancel
Save