diff options
| author | Theron Luhn <theron@luhn.com> | 2019-03-03 08:49:58 -0800 |
|---|---|---|
| committer | Theron Luhn <theron@luhn.com> | 2019-03-03 08:55:02 -0800 |
| commit | 5abdd1d7636a8f7c5cda4c8fcf2669c3937c1186 (patch) | |
| tree | bcbf0d8499152be3efb4b592657a55b179421b2a /tests/test_security.py | |
| parent | 140fdbb54c467159313ede564dd3ad4077e30f20 (diff) | |
| download | pyramid-5abdd1d7636a8f7c5cda4c8fcf2669c3937c1186.tar.gz pyramid-5abdd1d7636a8f7c5cda4c8fcf2669c3937c1186.tar.bz2 pyramid-5abdd1d7636a8f7c5cda4c8fcf2669c3937c1186.zip | |
Implement new request.has_permission.
Deleted AuthorizationAPIMixin
Diffstat (limited to 'tests/test_security.py')
| -rw-r--r-- | tests/test_security.py | 30 |
1 files changed, 6 insertions, 24 deletions
diff --git a/tests/test_security.py b/tests/test_security.py index dd2c225d3..40b5cd061 100644 --- a/tests/test_security.py +++ b/tests/test_security.py @@ -455,43 +455,25 @@ class TestHasPermission(unittest.TestCase): testing.tearDown() def _makeOne(self): - from pyramid.security import AuthorizationAPIMixin + from pyramid.security import SecurityAPIMixin from pyramid.registry import Registry - mixin = AuthorizationAPIMixin() + mixin = SecurityAPIMixin() mixin.registry = Registry() mixin.context = object() return mixin - def test_no_authentication_policy(self): + def test_no_security_policy(self): request = self._makeOne() result = request.has_permission('view') self.assertTrue(result) - self.assertEqual(result.msg, 'No authentication policy in use.') + self.assertEqual(result.msg, 'No security policy in use.') - def test_with_no_authorization_policy(self): + def test_with_security_registered(self): request = self._makeOne() - _registerAuthenticationPolicy(request.registry, None) - self.assertRaises( - ValueError, request.has_permission, 'view', context=None - ) - - def test_with_authn_and_authz_policies_registered(self): - request = self._makeOne() - _registerAuthenticationPolicy(request.registry, None) - _registerAuthorizationPolicy(request.registry, 'yo') + _registerSecurityPolicy(request.registry, 'yo') self.assertEqual(request.has_permission('view', context=None), 'yo') - def test_with_no_reg_on_request(self): - from pyramid.threadlocal import get_current_registry - - registry = get_current_registry() - request = self._makeOne() - del request.registry - _registerAuthenticationPolicy(registry, None) - _registerAuthorizationPolicy(registry, 'yo') - self.assertEqual(request.has_permission('view'), 'yo') - def test_with_no_context_passed(self): request = self._makeOne() self.assertTrue(request.has_permission('view')) |
