def test_05_reduce_realms(self): realms = {'defrealm': {'default': False, 'option': '', 'resolver': [ {'priority': None, 'type': 'passwdresolver', 'name': 'deflocal'}]}, 'localsql': {'default': True, 'option': '', 'resolver': [ {'priority': None, 'type': 'sqlresolver', 'name': 'localusers2'}]}} # The policy dictionary contains much more entries, but for us only # the realm is relevant policies = [{'realm': []}] r = reduce_realms(realms, policies) self.assertTrue("defrealm" in r) self.assertTrue("localsql" in r) policies = [{'realm': []}, {'realm': ["defrealm"]}] r = reduce_realms(realms, policies) self.assertTrue("defrealm" in r) self.assertTrue("localsql" in r) policies = [{'realm': ["defrealm"]}, {'realm': []}] r = reduce_realms(realms, policies) self.assertTrue("defrealm" in r) self.assertTrue("localsql" in r) policies = [{'realm': ["localsql"]}, {'realm': ["defrealm"]}] r = reduce_realms(realms, policies) self.assertTrue("defrealm" in r, r) self.assertTrue("localsql" in r, r) policies = [{'realm': ["localsql"]}, {'realm': ["localsql", "defrealm"]}] r = reduce_realms(realms, policies) self.assertTrue("defrealm" in r) self.assertTrue("localsql" in r) policies = [{'realm': ["realm1", "localsql", "realm2"]}, {'realm': ["localsql", "realm1"]}] r = reduce_realms(realms, policies) self.assertTrue("defrealm" not in r) self.assertTrue("localsql" in r) r = reduce_realms(realms, None) self.assertTrue("defrealm" in r) self.assertTrue("localsql" in r)
def test_05_reduce_realms(self): realms = {'defrealm': {'default': False, 'option': '', 'resolver': [ {'priority': None, 'type': 'passwdresolver', 'name': 'deflocal'}]}, 'localsql': {'default': True, 'option': '', 'resolver': [ {'priority': None, 'type': 'sqlresolver', 'name': 'localusers2'}]}} # The policy dictionary contains much more entries, but for us only # the realm is relevant policies = [{'realm': []}] r = reduce_realms(realms, policies) self.assertTrue("defrealm" in r) self.assertTrue("localsql" in r) policies = [{'realm': []}, {'realm': ["defrealm"]}] r = reduce_realms(realms, policies) self.assertTrue("defrealm" in r) self.assertTrue("localsql" in r) policies = [{'realm': ["defrealm"]}, {'realm': []}] r = reduce_realms(realms, policies) self.assertTrue("defrealm" in r) self.assertTrue("localsql" in r) policies = [{'realm': ["localsql"]}, {'realm': ["defrealm"]}] r = reduce_realms(realms, policies) self.assertTrue("defrealm" in r, r) self.assertTrue("localsql" in r, r) policies = [{'realm': ["localsql"]}, {'realm': ["localsql", "defrealm"]}] r = reduce_realms(realms, policies) self.assertTrue("defrealm" in r) self.assertTrue("localsql" in r) policies = [{'realm': ["realm1", "localsql", "realm2"]}, {'realm': ["localsql", "realm1"]}] r = reduce_realms(realms, policies) self.assertTrue("defrealm" not in r) self.assertTrue("localsql" in r) r = reduce_realms(realms, None) self.assertTrue("defrealm" in r) self.assertTrue("localsql" in r)