Пример #1
0
    def test_constant_literal_accept(self):
        check = policy.GenericCheck("True", '%(enabled)s')

        self.assertEqual(check(dict(enabled=True), {}, self.enforcer), True)
Пример #2
0
    def test_constant_string_accept(self):
        check = policy.GenericCheck("'spam'", '%(name)s')

        self.assertEqual(check(dict(name='spam'), {}, self.enforcer), True)
Пример #3
0
    def test_constant_literal_mismatch(self):
        check = policy.GenericCheck("True", '%(enabled)s')

        self.assertEqual(check(dict(enabled=False), {}, self.enforcer), False)
Пример #4
0
    def test_constant_string_mismatch(self):
        check = policy.GenericCheck("'spam'", '%(name)s')

        self.assertEqual(check(dict(name='ham'), {}, self.enforcer), False)
Пример #5
0
    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)
Пример #6
0
    def test_accept(self):
        check = policy.GenericCheck('name', '%(name)s')

        self.assertEqual(
            check(dict(name='spam'), dict(name='spam'), self.enforcer), True)
Пример #7
0
    def test_cred_mismatch(self):
        check = policy.GenericCheck('name', '%(name)s')

        self.assertEqual(
            check(dict(name='spam'), dict(name='ham'), self.enforcer), False)
Пример #8
0
    def test_no_cred(self):
        check = policy.GenericCheck('name', '%(name)s')

        self.assertEqual(check(dict(name='spam'), {}, self.enforcer), False)