Exemple #1
0
 def test_nonexisting_policy_file_load(self):
     policy_files = {
         'dinosaur': 'no_godzilla.json',
     }
     policy.reset()
     with self.settings(POLICY_FILES=policy_files):
         enforcer = policy._get_enforcer()
         self.assertEqual(0, len(enforcer))
Exemple #2
0
 def test_check_credentials_default(self):
     policy.reset()
     enforcer = policy._get_enforcer()
     scope = enforcer['with_default']
     user = utils.get_user()
     credentials = policy._user_to_credentials(user)
     target = {
         'project_id': user.project_id,
         'tenant_id': user.project_id,
         'user_id': user.id,
         'domain_id': user.user_domain_id,
         'user.domain_id': user.user_domain_id,
         'group.domain_id': user.user_domain_id,
         'project.domain_id': user.user_domain_id,
     }
     is_valid = policy._check_credentials(scope, 'action', target,
                                          credentials)
     self.assertFalse(is_valid)
Exemple #3
0
 def test_check_credentials_default(self):
     policy.reset()
     enforcer = policy._get_enforcer()
     scope = enforcer['with_default']
     user = utils.get_user()
     credentials = policy._user_to_credentials(user)
     target = {
         'project_id': user.project_id,
         'tenant_id': user.project_id,
         'user_id': user.id,
         'domain_id': user.user_domain_id,
         'user.domain_id': user.user_domain_id,
         'group.domain_id': user.user_domain_id,
         'project.domain_id': user.user_domain_id,
     }
     is_valid = policy._check_credentials(scope, 'action', target,
                                          credentials)
     self.assertFalse(is_valid)
 def test_policy_reset(self):
     policy._get_enforcer()
     self.assertEqual(2, len(policy._ENFORCER))
     policy.reset()
     self.assertIsNone(policy._ENFORCER)
 def test_policy_file_load(self):
     policy.reset()
     enforcer = policy._get_enforcer()
     self.assertEqual(2, len(enforcer))
     self.assertTrue('identity' in enforcer)
     self.assertTrue('compute' in enforcer)
 def test_policy_reset(self):
     policy._get_enforcer()
     self.assertEqual(2, len(policy._ENFORCER))
     policy.reset()
     self.assertIsNone(policy._ENFORCER)
 def test_policy_file_load(self):
     policy.reset()
     enforcer = policy._get_enforcer()
     self.assertEqual(2, len(enforcer))
     self.assertTrue('identity' in enforcer)
     self.assertTrue('compute' in enforcer)
 def test_policy_file_load(self):
     policy_backend.reset()
     enforcer = policy_backend._get_enforcer()
     self.assertEqual(2, len(enforcer))
     self.assertIn('identity', enforcer)
     self.assertIn('compute', enforcer)
Exemple #9
0
 def test_nonexisting_policy_file_load(self):
     policy.reset()
     enforcer = policy._get_enforcer()
     self.assertEqual(0, len(enforcer))