summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2011-08-18 22:50:04 -0400
committerChris McDonough <chrism@plope.com>2011-08-18 22:50:04 -0400
commit66da9b2f683ace2c0fa3ce24a607d4239c760434 (patch)
tree22788f1f3c3a8922dce8ce5f9bda8cf68454bc24
parentd08bb9f5d36b5dffda0af13ebb45f1c253e85df8 (diff)
downloadpyramid-66da9b2f683ace2c0fa3ce24a607d4239c760434.tar.gz
pyramid-66da9b2f683ace2c0fa3ce24a607d4239c760434.tar.bz2
pyramid-66da9b2f683ace2c0fa3ce24a607d4239c760434.zip
coverage
-rw-r--r--CHANGES.txt2
-rw-r--r--pyramid/config/__init__.py4
-rw-r--r--pyramid/config/security.py12
-rw-r--r--pyramid/tests/test_config/test_views.py8
4 files changed, 10 insertions, 16 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index dede9cf53..fb45ede81 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -100,6 +100,8 @@ Internal
- Refactor ``pyramid.config`` into a package.
+- Removed the ``_set_security_policies`` method of the Configurator.
+
Deprecations
------------
diff --git a/pyramid/config/__init__.py b/pyramid/config/__init__.py
index 38f2698bd..113ef4e06 100644
--- a/pyramid/config/__init__.py
+++ b/pyramid/config/__init__.py
@@ -16,6 +16,7 @@ from zope.configuration.xmlconfig import registerCommonDirectives
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
@@ -315,6 +316,9 @@ class Configurator(
# 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:
diff --git a/pyramid/config/security.py b/pyramid/config/security.py
index 58c735968..4a4b7a1ad 100644
--- a/pyramid/config/security.py
+++ b/pyramid/config/security.py
@@ -52,18 +52,6 @@ class SecurityConfiguratorMixin(object):
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
diff --git a/pyramid/tests/test_config/test_views.py b/pyramid/tests/test_config/test_views.py
index b1cf8e72f..d62909603 100644
--- a/pyramid/tests/test_config/test_views.py
+++ b/pyramid/tests/test_config/test_views.py
@@ -949,7 +949,7 @@ class TestViewDeriver(unittest.TestCase):
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):
@@ -971,7 +971,7 @@ class TestViewDeriver(unittest.TestCase):
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):
@@ -988,7 +988,7 @@ class TestViewDeriver(unittest.TestCase):
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):
@@ -1004,7 +1004,7 @@ class TestViewDeriver(unittest.TestCase):
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):