Make config parser case sensitivity in configure-verifier
Options in config file should be case sensitive, some projects like octavia-tempest-plugin can't set some value as expected: [load_balancer] RBAC_test_type = owner_or_admin Use `conf.optionxform = str` to prevent case transformation[1]. [1] https://docs.python.org/3/library/configparser.html Change-Id: I34d85b835aaa7a3737577b75ec9e6f2b02f90ead Closes-Bug: #1877930
This commit is contained in:
parent
ab365e9bbb
commit
e1ad05c781
@ -17,6 +17,17 @@ Changelog
|
||||
.. Release notes for existing releases are MUTABLE! If there is something that
|
||||
was missed or can be improved, feel free to change it!
|
||||
|
||||
[unreleased]
|
||||
------------
|
||||
|
||||
Fixed
|
||||
~~~~~
|
||||
|
||||
* [verification component] Make config parser case sensitivity in
|
||||
configure-verifier
|
||||
|
||||
`Launchpad-bug #1877930 <https://launchpad.net/bugs/1877930>`_
|
||||
|
||||
[3.1.0] - 2020-05-08
|
||||
--------------------
|
||||
|
||||
|
@ -333,6 +333,7 @@ class VerifyCommands(object):
|
||||
if extra_options:
|
||||
if os.path.isfile(extra_options):
|
||||
conf = configparser.ConfigParser()
|
||||
conf.optionxform = str
|
||||
conf.read(extra_options)
|
||||
extra_options = dict(conf._sections)
|
||||
for s in extra_options:
|
||||
|
@ -73,6 +73,7 @@ def create_dir(dir_path):
|
||||
|
||||
def extend_configfile(extra_options, conf_path):
|
||||
conf_object = configparser.ConfigParser()
|
||||
conf_object.optionxform = str
|
||||
conf_object.read(conf_path)
|
||||
|
||||
conf_object = add_extra_options(extra_options, conf_object)
|
||||
@ -86,6 +87,7 @@ def extend_configfile(extra_options, conf_path):
|
||||
|
||||
|
||||
def add_extra_options(extra_options, conf_object):
|
||||
conf_object.optionxform = str
|
||||
for section in extra_options:
|
||||
if section not in (conf_object.sections() + ["DEFAULT"]):
|
||||
conf_object.add_section(section)
|
||||
|
@ -80,11 +80,14 @@ class UtilsTestCase(test.TestCase):
|
||||
def test_add_extra_options(self):
|
||||
conf = configparser.ConfigParser()
|
||||
extra_options = {"section": {"foo": "bar"},
|
||||
"section2": {"option": "value"}}
|
||||
"section2": {"option": "value"},
|
||||
"section3": {"CamelCaseOption": "CamelCaseValue"}}
|
||||
|
||||
conf = utils.add_extra_options(extra_options, conf)
|
||||
|
||||
expected = {"section": ("foo", "bar"), "section2": ("option", "value")}
|
||||
expected = {"section": ("foo", "bar"),
|
||||
"section2": ("option", "value"),
|
||||
"section3": ("CamelCaseOption", "CamelCaseValue")}
|
||||
for section, option in expected.items():
|
||||
result = conf.items(section)
|
||||
self.assertIn(option, result)
|
||||
|
Loading…
Reference in New Issue
Block a user