Expose multiple SQL backend usage validation error
File-based domain-specific configuration supports only one SQL backend. The method that checked how many SQL backends are enabled was not correct, and depending on the order of domains examined, may give the wrong result. A follow-on patch will fix this error. Co-Authored-By: Henry Nash <henryn@linux.vnet.ibm.com> Partial-Bug: #1410850 Change-Id: Idfc03ba5314acc7ebc8ed99f078b6a08130cc1dd
This commit is contained in:
parent
c4f13f37d1
commit
fdc150fe98
|
@ -12,6 +12,7 @@
|
|||
|
||||
"""Unit tests for core identity behavior."""
|
||||
|
||||
import itertools
|
||||
import os
|
||||
import uuid
|
||||
|
||||
|
@ -80,6 +81,45 @@ class TestDomainConfigs(tests.BaseTestCase):
|
|||
[domain_config_filename],
|
||||
'abc.def.com')
|
||||
|
||||
def test_config_for_multiple_sql_backend(self):
|
||||
domains_config = identity.DomainConfigs()
|
||||
|
||||
# Create the right sequence of is_sql in the drivers being
|
||||
# requested to expose the bug, which is that a False setting
|
||||
# means it forgets previous True settings.
|
||||
drivers = []
|
||||
files = []
|
||||
for idx, is_sql in enumerate((True, False, True)):
|
||||
drv = mock.Mock(is_sql=is_sql)
|
||||
drivers.append(drv)
|
||||
name = 'dummy.{0}'.format(idx)
|
||||
files.append(''.join((
|
||||
identity.DOMAIN_CONF_FHEAD,
|
||||
name,
|
||||
identity.DOMAIN_CONF_FTAIL)))
|
||||
|
||||
walk_fake = lambda *a, **kwa: (
|
||||
('/fake/keystone/domains/config', [], files), )
|
||||
|
||||
generic_driver = mock.Mock(is_sql=False)
|
||||
|
||||
assignment_api = mock.Mock()
|
||||
id_factory = itertools.count()
|
||||
assignment_api.get_domain_by_name.side_effect = (
|
||||
lambda name: {'id': next(id_factory), '_': 'fake_domain'})
|
||||
load_driver_mock = mock.Mock(side_effect=drivers)
|
||||
|
||||
with mock.patch.object(os, 'walk', walk_fake):
|
||||
with mock.patch.object(identity.cfg, 'ConfigOpts'):
|
||||
with mock.patch.object(domains_config, '_load_driver',
|
||||
load_driver_mock):
|
||||
# TODO(henry-nash): The following call should fail since
|
||||
# we are asking for two sql drivers. See bug #1410850.
|
||||
domains_config.setup_domain_drivers(
|
||||
generic_driver, assignment_api)
|
||||
|
||||
self.assertEqual(3, load_driver_mock.call_count)
|
||||
|
||||
|
||||
class TestDatabaseDomainConfigs(tests.TestCase):
|
||||
|
||||
|
|
Loading…
Reference in New Issue