Exemple #1
0
 def test_context_effective_principals_admin(self):
     res = set(security.context_effective_principals(self.root, 'admin'))
     self.assertEqual(
         res,
         set([
             'system.Everyone', 'system.Authenticated', 'admin',
             'role:Admin', 'role:Owner'
         ]))
Exemple #2
0
 def test_roles_added_to_principals(self):
     root = self._fixture()
     root.add_groups('robin', ('role:Administrator', ))
     res = security.context_effective_principals(root, 'robin')
     self.assertEqual(res, [
         'system.Everyone', 'system.Authenticated', 'robin',
         'role:Administrator'
     ])
Exemple #3
0
 def test_groups_added_to_principals(self):
     self.root.add_groups('fredrik', (
         'group:developer',
         'group:Betahaus',
     ))
     res = security.context_effective_principals(self.root, 'fredrik')
     self.assertEqual(res, [
         'system.Everyone', 'system.Authenticated', 'fredrik',
         'group:Betahaus', 'group:developer'
     ])
Exemple #4
0
 def context_effective_principals(self, context):
     """ Special version of pyramid.security.effective_principals that
         adds groups based on context instead of request.context
     """
     return security.context_effective_principals(context, self.userid)
Exemple #5
0
 def context_effective_principals(self, context):
     """ Special version of pyramid.security.effective_principals that
         adds groups based on context instead of request.context
     """
     return security.context_effective_principals(context, self.userid)
Exemple #6
0
 def test_roles_added_to_principals(self):
     root = self._fixture()
     root.add_groups('robin', ('role:Administrator',))
     res = security.context_effective_principals(root, 'robin')
     self.assertEqual(res, ['system.Everyone', 'system.Authenticated',
                            'robin', 'role:Administrator'])
Exemple #7
0
 def test_groups_added_to_principals(self):
     root = self._fixture()
     root.add_groups('fredrik', ('group:developer', 'group:Betahaus',))
     res = security.context_effective_principals(root, 'fredrik')
     self.assertEqual(res, ['system.Everyone', 'system.Authenticated',
                            'fredrik', 'group:Betahaus', 'group:developer'])
Exemple #8
0
 def test_context_effective_principals_unauthenticated(self):
     root = self._fixture()
     res = security.context_effective_principals(root, None)
     self.assertEqual(res, ['system.Everyone'])
Exemple #9
0
 def test_context_effective_principals_normal_user(self):
     root = self._fixture()
     res = security.context_effective_principals(root, 'hanna')
     self.assertEqual(res, ['system.Everyone', 'system.Authenticated', 'hanna'])
Exemple #10
0
 def test_context_effective_principals_admin(self):
     root = self._fixture()
     res = set(security.context_effective_principals(root, 'admin'))
     self.assertEqual(res, set(['system.Everyone', 'system.Authenticated', 'admin', 'role:Administrator', 'role:Owner']))
Exemple #11
0
 def test_context_effective_principals_unauthenticated(self):
     res = security.context_effective_principals(self.root, None)
     self.assertEqual(res, ['system.Everyone'])
Exemple #12
0
 def test_context_effective_principals_normal_user(self):
     res = security.context_effective_principals(self.root, 'hanna')
     self.assertEqual(res,
                      ['system.Everyone', 'system.Authenticated', 'hanna'])