Permalink
Browse files

Merge pull request #3442 from Estartu/master

changed  principals_allowed_by_permission to act differently if permissive is True or False
  • Loading branch information...
mmerickel committed Jan 11, 2019
2 parents 00a46e5 + 2d091dc commit 7bd9da72c63124c7ca007f4fa2113633bba5c403
Showing with 11 additions and 1 deletion.
  1. +4 −1 src/pyramid/testing.py
  2. +7 −0 tests/test_testing.py
@@ -89,7 +89,10 @@ def permits(self, context, principals, permission):
return self.permissive

def principals_allowed_by_permission(self, context, permission):
return self.effective_principals(None)
if self.permissive:
return self.effective_principals(None)
else:
return []


class DummyTemplateRenderer(object):
@@ -63,6 +63,13 @@ def test_principals_allowed_by_permission(self):
result = policy.principals_allowed_by_permission(None, None)
self.assertEqual(result, [Everyone, Authenticated, 'user', 'group1'])

def test_principals_allowed_by_permission_not_permissive(self):
policy = self._makeOne('user', ('group1',))
policy.permissive = False

result = policy.principals_allowed_by_permission(None, None)
self.assertEqual(result, [])

def test_forget(self):
policy = self._makeOne()
self.assertEqual(policy.forget(None), [])

0 comments on commit 7bd9da7

Please sign in to comment.