summaryrefslogtreecommitdiff
path: root/tests/pkgs/permbugapp/__init__.py
diff options
context:
space:
mode:
authorMichael Merickel <github@m.merickel.org>2018-10-15 09:03:53 -0500
committerGitHub <noreply@github.com>2018-10-15 09:03:53 -0500
commit81576ee51564c49d5ff3c1c07f214f22a8438231 (patch)
tree5b3fe0b39a0fc33d545733d821738845909f638c /tests/pkgs/permbugapp/__init__.py
parent433efe06191a7007ca8c5bf8fafee5c7c1439ebb (diff)
parent17e3abf320f6d9cd90f7e5a0352280c2fef584af (diff)
downloadpyramid-81576ee51564c49d5ff3c1c07f214f22a8438231.tar.gz
pyramid-81576ee51564c49d5ff3c1c07f214f22a8438231.tar.bz2
pyramid-81576ee51564c49d5ff3c1c07f214f22a8438231.zip
Merge pull request #3387 from mmerickel/src-folder-refactor
refactor pyramid tests into a tests folder and package into a src folder
Diffstat (limited to 'tests/pkgs/permbugapp/__init__.py')
-rw-r--r--tests/pkgs/permbugapp/__init__.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/pkgs/permbugapp/__init__.py b/tests/pkgs/permbugapp/__init__.py
new file mode 100644
index 000000000..4868427a5
--- /dev/null
+++ b/tests/pkgs/permbugapp/__init__.py
@@ -0,0 +1,22 @@
+from pyramid.compat import escape
+from pyramid.security import view_execution_permitted
+from pyramid.response import Response
+
+def x_view(request): # pragma: no cover
+ return Response('this is private!')
+
+def test(context, request):
+ # should return false
+ msg = 'Allow ./x? %s' % repr(view_execution_permitted(
+ context, request, 'x'))
+ return Response(escape(msg))
+
+def includeme(config):
+ from pyramid.authentication import AuthTktAuthenticationPolicy
+ from pyramid.authorization import ACLAuthorizationPolicy
+ authn_policy = AuthTktAuthenticationPolicy('seekt1t', hashalg='sha512')
+ authz_policy = ACLAuthorizationPolicy()
+ config.set_authentication_policy(authn_policy)
+ config.set_authorization_policy(authz_policy)
+ config.add_view(test, name='test')
+ config.add_view(x_view, name='x', permission='private')