Exemplo n.º 1
0
 def test_authorize_admin_actions_with_nonadmin_context_throws(self):
     """Check if non-admin context passed to admin actions throws
        Policy not authorized exception
     """
     for action in policy_engine.get_rules().keys():
         self.assertRaises(os_policy.PolicyNotAuthorized,
                           policy_engine.authorize,
                           self.noadmin_context, action, self.target)
Exemplo n.º 2
0
 def test_authorize_admin_actions_with_nonadmin_context_throws(self):
     """Check if non-admin context passed to admin actions throws
        Policy not authorized exception
     """
     for action in policy_engine.get_rules().keys():
         self.assertRaises(os_policy.PolicyNotAuthorized,
                           policy_engine.authorize, self.noadmin_context,
                           action, self.target)
Exemplo n.º 3
0
 def _assert_rules(self, policies_list):
     for policy_name in policies_list:
         registered_rule = policy.get_rules()[policy_name]
         if hasattr(registered_rule, 'rules'):
             self.assertEqual(len(registered_rule.rules),
                              len(policies_list[policy_name]))
         for role in policies_list[policy_name]:
             ctx = self._get_request_context(role)
             self.assertTrue(policy.authorize(ctx.context, policy_name, {}))
Exemplo n.º 4
0
 def test_authorize_admin_actions_with_admin_context(self):
     for action in policy_engine.get_rules().keys():
         policy_engine.authorize(self.admin_context, action, self.target)
Exemplo n.º 5
0
 def test_authorize_admin_actions_with_admin_context(self):
     for action in policy_engine.get_rules().keys():
         policy_engine.authorize(self.admin_context, action, self.target)