def test_constant_literal_accept(self): check = policy.GenericCheck("True", '%(enabled)s') self.assertEqual(check(dict(enabled=True), {}, self.enforcer), True)
def test_constant_string_accept(self): check = policy.GenericCheck("'spam'", '%(name)s') self.assertEqual(check(dict(name='spam'), {}, self.enforcer), True)
def test_constant_literal_mismatch(self): check = policy.GenericCheck("True", '%(enabled)s') self.assertEqual(check(dict(enabled=False), {}, self.enforcer), False)
def test_constant_string_mismatch(self): check = policy.GenericCheck("'spam'", '%(name)s') self.assertEqual(check(dict(name='ham'), {}, self.enforcer), False)
def test_no_key_match_in_target(self): check = policy.GenericCheck('name', '%(name)s') self.assertEqual( check(dict(name1='spam'), dict(name='spam'), self.enforcer), False)
def test_accept(self): check = policy.GenericCheck('name', '%(name)s') self.assertEqual( check(dict(name='spam'), dict(name='spam'), self.enforcer), True)
def test_cred_mismatch(self): check = policy.GenericCheck('name', '%(name)s') self.assertEqual( check(dict(name='spam'), dict(name='ham'), self.enforcer), False)
def test_no_cred(self): check = policy.GenericCheck('name', '%(name)s') self.assertEqual(check(dict(name='spam'), {}, self.enforcer), False)