Exemple #1
0
 def test_templatized_enforcement(self):
     target_mine = {'project_id': 'fake'}
     target_not_mine = {'project_id': 'another'}
     action = "example:my_file"
     policy.enforce(self.context, action, target_mine)
     self.assertRaises(exception.PolicyNotAllowed, policy.enforce,
                       self.context, action, target_not_mine)
Exemple #2
0
 def test_modified_policy_reloads(self):
     action = "example:test"
     with open(self.tmpfilename, "w") as policyfile:
         policyfile.write("""{"example:test": []}""")
     policy.enforce(self.context, action, self.target)
     with open(self.tmpfilename, "w") as policyfile:
         policyfile.write("""{"example:test": ["false:false"]}""")
     # NOTE(vish): reset stored policy cache so we don't have to sleep(1)
     policy._POLICY_CACHE = {}
     self.assertRaises(exception.PolicyNotAllowed, policy.enforce,
                       self.context, action, self.target)
Exemple #3
0
    def test_enforce_http_true(self):

        def fakeurlopen(url, post_data):
            return StringIO.StringIO("True")
        self.stubs.Set(urllib2, 'urlopen', fakeurlopen)
        action = "example:get_http"
        target = {}
        result = policy.enforce(self.context, action, target)
        self.assertEqual(result, None)
Exemple #4
0
 def test_enforce_good_action(self):
     action = "example:allowed"
     policy.enforce(self.context, action, self.target)
Exemple #5
0
 def test_early_OR_enforcement(self):
     action = "example:early_or_success"
     policy.enforce(self.context, action, self.target)