Ejemplo n.º 1
0
 def setUp(self):
     super(PolicyTestCase, self).setUp()
     rules = {
         "true": '@',
         "example:allowed": '@',
         "example:denied": "!",
         "example:get_http": "http://www.example.com",
         "example:my_file": "role:compute_admin or "
                            "project_id:%(project_id)s",
         "example:early_and_fail": "! and @",
         "example:early_or_success": "@ or !",
         "example:lowercase_admin": "role:admin or role:sysadmin",
         "example:uppercase_admin": "role:ADMIN or role:sysadmin",
     }
     policy.reset()
     policy.init()
     policy.set_rules(dict((k, common_policy.parse_rule(v))
                           for k, v in rules.items()))
     self.context = context.RequestContext('fake', 'fake', roles=['member'])
     self.target = {}
Ejemplo n.º 2
0
 def setUp(self):
     super(PolicyTestCase, self).setUp()
     rules = {
         "true": '@',
         "example:allowed": '@',
         "example:denied": "!",
         "example:get_http": "http://www.example.com",
         "example:my_file": "role:compute_admin or "
         "project_id:%(project_id)s",
         "example:early_and_fail": "! and @",
         "example:early_or_success": "@ or !",
         "example:lowercase_admin": "role:admin or role:sysadmin",
         "example:uppercase_admin": "role:ADMIN or role:sysadmin",
     }
     policy.reset()
     policy.init()
     policy.set_rules(
         dict((k, common_policy.parse_rule(v)) for k, v in rules.items()))
     self.context = context.RequestContext('fake', 'fake', roles=['member'])
     self.target = {}
Ejemplo n.º 3
0
 def set_rules(self, rules):
     policy = congress.common.policy._ENFORCER
     policy.set_rules(dict((k, common_policy.parse_rule(v)) for k, v in rules.items()))
Ejemplo n.º 4
0
 def _set_rules(self, default_rule):
     policy.reset()
     rules = dict((k, common_policy.parse_rule(v))
                  for k, v in self.rules.items())
     policy.init(rules=rules, default_rule=default_rule, use_conf=False)
Ejemplo n.º 5
0
 def set_rules(self, rules):
     policy = congress.common.policy._ENFORCER
     policy.set_rules(
         dict((k, common_policy.parse_rule(v)) for k, v in rules.items()))
Ejemplo n.º 6
0
 def _set_rules(self, default_rule):
     policy.reset()
     rules = dict(
         (k, common_policy.parse_rule(v)) for k, v in self.rules.items())
     policy.init(rules=rules, default_rule=default_rule, use_conf=False)