Merge "Federation mapping debug should show direct_maps values"

This commit is contained in:
Zuul 2019-09-20 10:21:03 +00:00 committed by Gerrit Code Review
commit 97b3054d4a
3 changed files with 37 additions and 0 deletions

View File

@ -243,6 +243,10 @@ class DirectMaps(object):
def __init__(self):
self._matches = []
def __str__(self):
"""return the direct map array as a string."""
return '%s' % self._matches
def add(self, values):
"""Add a matched value to the list of matches.

View File

@ -1866,6 +1866,32 @@ class TestMappingEngineTester(unit.BaseTestCase):
self.assertRaises(exception.ValidationError,
mapping_engine.main)
def test_mapping_engine_tester_logs_direct_maps(self):
tempfilejson = self.useFixture(temporaryfile.SecureTempFile())
tmpfilejsonname = tempfilejson.file_name
updated_mapping = copy.deepcopy(mapping_fixtures.MAPPING_SMALL)
with open(tmpfilejsonname, 'w') as f:
f.write(jsonutils.dumps(updated_mapping))
self.command_rules = tmpfilejsonname
tempfile = self.useFixture(temporaryfile.SecureTempFile())
tmpfilename = tempfile.file_name
with open(tmpfilename, 'w') as f:
f.write("\n")
f.write("UserName:me\n")
f.write("orgPersonType:NoContractor\n")
f.write("LastName:Bo\n")
f.write("FirstName:Jill\n")
self.command_input = tmpfilename
self.command_prefix = None
self.command_engine_debug = True
self.useFixture(fixtures.MockPatchObject(
CONF, 'command', self.FakeConfCommand(self)))
mapping_engine = cli.MappingEngineTester()
logging = self.useFixture(fixtures.FakeLogger(level=log.DEBUG))
mapping_engine.main()
expected_msg = "direct_maps: [['me']]"
self.assertThat(logging.output, matchers.Contains(expected_msg))
class CliStatusTestCase(unit.SQLDriverOverrides, unit.TestCase):

View File

@ -0,0 +1,7 @@
---
fixes:
- |
[`bug 1841486 <https://bugs.launchpad.net/keystone/+bug/1841486>`_]
The ``keystone-manage mapping_engine --engine-debug`` CLI tool now outputs
useful information about the direct mappings from an assertion after
processing mapping rules.