Pass dictionary as creds in policy tests

According to the documentation strings for the ``enforce`` method, the
``creds`` parameter is expected to be a dictionary. The implementation
also treats it like a dictionary.

This commit updates three of the tests in test_policy.py to pass a
dictionary into enforce instead of just a string called 'creds'.

Change-Id: Id05a41b84123aeb57b193bba97cb9e8442587a51
This commit is contained in:
Lance Bragstad 2018-06-28 19:02:46 +00:00
parent 8f74e2ba28
commit 13a4e789bc
1 changed files with 7 additions and 4 deletions

View File

@ -697,15 +697,17 @@ class CheckFunctionTestCase(base.PolicyBaseTestCase):
def test_check_explicit(self):
rule = base.FakeCheck()
result = self.enforcer.enforce(rule, 'target', 'creds')
self.assertEqual(('target', 'creds', self.enforcer), result)
creds = {}
result = self.enforcer.enforce(rule, 'target', creds)
self.assertEqual(('target', creds, self.enforcer), result)
def test_check_no_rules(self):
# Clear the policy.json file created in setUp()
self.create_config_file('policy.json', "{}")
self.enforcer.default_rule = None
self.enforcer.load_rules()
result = self.enforcer.enforce('rule', 'target', 'creds')
creds = {}
result = self.enforcer.enforce('rule', 'target', creds)
self.assertFalse(result)
def test_check_with_rule(self):
@ -722,7 +724,8 @@ class CheckFunctionTestCase(base.PolicyBaseTestCase):
self.create_config_file('policy.json', jsonutils.dumps({"a_rule": []}))
self.enforcer.default_rule = None
self.enforcer.load_rules()
result = self.enforcer.enforce('rule', 'target', 'creds')
creds = {}
result = self.enforcer.enforce('rule', 'target', creds)
self.assertFalse(result)
def test_check_raise_default(self):