Exemplo n.º 1
0
 def _test_enforce_http(self, return_value):
     self.useFixture(fixture.HttpCheckFixture(return_value=return_value))
     action = self.getUniqueString()
     rules_json = {action: "http:" + self.getUniqueString()}
     rules = oslo_policy.Rules.load(json.dumps(rules_json))
     self.enforcer.set_rules(rules)
     return self.enforcer.enforce(rule=action, target={}, creds={})
Exemplo n.º 2
0
 def test_enforce_http_false(self):
     self.useFixture(op_fixture.HttpCheckFixture(False))
     action = "example:get_http"
     target = {}
     self.assertRaises(oslo_policy.PolicyNotAuthorized,
                       policy.enforce, self.context,
                       action, target)
Exemplo n.º 3
0
 def test_enforce_http_true(self):
     self.useFixture(op_fixture.HttpCheckFixture())
     action = "example:get_http"
     target = {}
     result = policy.enforce(self.context, action, target)
     self.assertTrue(result)