예제 #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))
예제 #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)
예제 #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)
예제 #4
0
 def test_policy_reset(self):
     policy._get_enforcer()
     self.assertEqual(2, len(policy._ENFORCER))
     policy.reset()
     self.assertIsNone(policy._ENFORCER)
예제 #5
0
 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)
예제 #6
0
 def test_policy_reset(self):
     policy._get_enforcer()
     self.assertEqual(2, len(policy._ENFORCER))
     policy.reset()
     self.assertIsNone(policy._ENFORCER)
예제 #7
0
 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)
예제 #8
0
 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)
예제 #9
0
 def test_nonexisting_policy_file_load(self):
     policy.reset()
     enforcer = policy._get_enforcer()
     self.assertEqual(0, len(enforcer))