summaryrefslogtreecommitdiff
path: root/tests/test_security.py
diff options
context:
space:
mode:
authorBert JW Regeer <xistence@0x58.com>2020-07-05 20:45:21 -0700
committerGitHub <noreply@github.com>2020-07-05 20:45:21 -0700
commit5269b28e728a470b94f194bf8febd46278b1f356 (patch)
treea7b0f7e1f227bae84baf33240d7ea1831c894ce7 /tests/test_security.py
parent48a04855ad4f1f1ae6af934090f35a4ad035ed67 (diff)
parent5f37acda1c8af7cb288e792e2c82f728fe254818 (diff)
downloadpyramid-5269b28e728a470b94f194bf8febd46278b1f356.tar.gz
pyramid-5269b28e728a470b94f194bf8febd46278b1f356.tar.bz2
pyramid-5269b28e728a470b94f194bf8febd46278b1f356.zip
Merge pull request #3598 from merwok/feature/is_authenticated
Add Request.is_authenticated and is_authenticated predicate
Diffstat (limited to 'tests/test_security.py')
-rw-r--r--tests/test_security.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/test_security.py b/tests/test_security.py
index bf2908100..72598f570 100644
--- a/tests/test_security.py
+++ b/tests/test_security.py
@@ -393,6 +393,29 @@ class TestUnAuthenticatedUserId(unittest.TestCase):
self.assertEqual(request.unauthenticated_userid, 'wat')
+class TestIsAuthenticated(unittest.TestCase):
+ def setUp(self):
+ testing.setUp()
+
+ def tearDown(self):
+ testing.tearDown()
+
+ def test_no_security_policy(self):
+ request = _makeRequest()
+ self.assertIs(request.is_authenticated, False)
+
+ def test_with_security_policy(self):
+ request = _makeRequest()
+ _registerSecurityPolicy(request.registry, '123')
+ self.assertIs(request.is_authenticated, True)
+
+ def test_with_legacy_security_policy(self):
+ request = _makeRequest()
+ _registerAuthenticationPolicy(request.registry, 'yo')
+ _registerLegacySecurityPolicy(request.registry)
+ self.assertEqual(request.authenticated_userid, 'yo')
+
+
class TestEffectivePrincipals(unittest.TestCase):
def setUp(self):
testing.setUp()