| | |
| | | |
| | | - Refactor ``pyramid.config`` into a package. |
| | | |
| | | - Removed the ``_set_security_policies`` method of the Configurator. |
| | | |
| | | Deprecations |
| | | ------------ |
| | | |
| | |
| | | from pyramid.interfaces import IExceptionResponse |
| | | from pyramid.interfaces import IDebugLogger |
| | | |
| | | from pyramid.authorization import ACLAuthorizationPolicy |
| | | from pyramid.events import ApplicationCreated |
| | | from pyramid.exceptions import ConfigurationError # bw compat |
| | | from pyramid.httpexceptions import default_exceptionresponse_view |
| | |
| | | # should be preferred rather than add-on author implementations (as |
| | | # per automatic conflict resolution). |
| | | |
| | | if authentication_policy and not authorization_policy: |
| | | authorization_policy = ACLAuthorizationPolicy() # default |
| | | |
| | | if authentication_policy: |
| | | self.set_authentication_policy(authentication_policy) |
| | | if authorization_policy: |
| | |
| | | self.registry.registerUtility(policy, IAuthorizationPolicy) |
| | | |
| | | @action_method |
| | | def _set_security_policies(self, authentication, authorization=None): |
| | | if (authorization is not None) and (not authentication): |
| | | raise ConfigurationError( |
| | | 'If the "authorization" is passed a value, ' |
| | | 'the "authentication" argument must also be ' |
| | | 'passed a value; authorization requires authentication.') |
| | | if authorization is None: |
| | | authorization = ACLAuthorizationPolicy() # default |
| | | self._set_authentication_policy(authentication) |
| | | self._set_authorization_policy(authorization) |
| | | |
| | | @action_method |
| | | def set_default_permission(self, permission): |
| | | """ |
| | | Set the default permission to be used by all subsequent |
| | |
| | | except HTTPForbidden, e: |
| | | self.assertEqual(e.message, |
| | | 'Unauthorized: <lambda> failed permission check') |
| | | else: |
| | | else: # pragma: no cover |
| | | raise AssertionError |
| | | |
| | | def test_secured_view_raises_forbidden_with_name(self): |
| | |
| | | except HTTPForbidden, e: |
| | | self.assertEqual(e.message, |
| | | 'Unauthorized: myview failed permission check') |
| | | else: |
| | | else: # pragma: no cover |
| | | raise AssertionError |
| | | |
| | | def test_predicate_mismatch_view_has_no_name(self): |
| | |
| | | result(None, None) |
| | | except PredicateMismatch, e: |
| | | self.assertEqual(e.detail, 'predicate mismatch for view <lambda>') |
| | | else: |
| | | else: # pragma: no cover |
| | | raise AssertionError |
| | | |
| | | def test_predicate_mismatch_view_has_name(self): |
| | |
| | | result(None, None) |
| | | except PredicateMismatch, e: |
| | | self.assertEqual(e.detail, 'predicate mismatch for view myview') |
| | | else: |
| | | else: # pragma: no cover |
| | | raise AssertionError |
| | | |
| | | def test_with_predicates_all(self): |