summaryrefslogtreecommitdiff
path: root/tests/test_integration.py
diff options
context:
space:
mode:
authorTheron Luhn <theron@luhn.com>2019-04-27 14:51:57 -0700
committerTheron Luhn <theron@luhn.com>2019-04-27 15:42:21 -0700
commitad611d2696701b611d2ef9dfe93567ecf6cb338d (patch)
tree6b4c226fd6c5f22b31d765397d2bdd070688d935 /tests/test_integration.py
parent5497c0f7166308031b3cc3ce2510d22eb214b2ef (diff)
downloadpyramid-ad611d2696701b611d2ef9dfe93567ecf6cb338d.tar.gz
pyramid-ad611d2696701b611d2ef9dfe93567ecf6cb338d.tar.bz2
pyramid-ad611d2696701b611d2ef9dfe93567ecf6cb338d.zip
Add simple integration tests for security.
Diffstat (limited to 'tests/test_integration.py')
-rw-r--r--tests/test_integration.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/test_integration.py b/tests/test_integration.py
index 72465dc93..331542d7d 100644
--- a/tests/test_integration.py
+++ b/tests/test_integration.py
@@ -521,6 +521,48 @@ class TestExceptionViewsApp(IntegrationBase, unittest.TestCase):
self.assertTrue(b'caught' in res.body)
+class TestSecurityApp(IntegrationBase, unittest.TestCase):
+ package = 'tests.pkgs.securityapp'
+
+ def test_public(self):
+ res = self.testapp.get('/public', status=200)
+ self.assertEqual(res.body, b'Hello')
+
+ def test_private_denied(self):
+ self.testapp.get('/private', status=403)
+
+ def test_private_allowed(self):
+ self.testapp.extra_environ = {'REMOTE_USER': 'bob'}
+ res = self.testapp.get('/private', status=200)
+ self.assertEqual(res.body, b'Secret')
+
+ def test_inaccessible(self):
+ self.testapp.get('/inaccessible', status=403)
+ self.testapp.extra_environ = {'REMOTE_USER': 'bob'}
+ self.testapp.get('/inaccessible', status=403)
+
+
+class TestLegacySecurityApp(IntegrationBase, unittest.TestCase):
+ package = 'tests.pkgs.legacysecurityapp'
+
+ def test_public(self):
+ res = self.testapp.get('/public', status=200)
+ self.assertEqual(res.body, b'Hello')
+
+ def test_private_denied(self):
+ self.testapp.get('/private', status=403)
+
+ def test_private_allowed(self):
+ self.testapp.extra_environ = {'REMOTE_USER': 'bob'}
+ res = self.testapp.get('/private', status=200)
+ self.assertEqual(res.body, b'Secret')
+
+ def test_inaccessible(self):
+ self.testapp.get('/inaccessible', status=403)
+ self.testapp.extra_environ = {'REMOTE_USER': 'bob'}
+ self.testapp.get('/inaccessible', status=403)
+
+
class TestConflictApp(unittest.TestCase):
package = 'tests.pkgs.conflictapp'