summaryrefslogtreecommitdiff
path: root/src/zope/component/tests/test_security.py
diff options
context:
space:
mode:
authorJason Madden <jamadden@gmail.com>2017-06-29 12:44:25 -0500
committerJason Madden <jamadden@gmail.com>2017-06-30 11:01:09 -0500
commit712bb8e078de20e01311cfe57d8dccfbbdcbe9b3 (patch)
tree4cb7d4e9cc901fe144d168b77eea235a08932787 /src/zope/component/tests/test_security.py
parent43d7351318eb373d1f4f500b70e4e461048c16f4 (diff)
downloadzope-component-issue29.tar.gz
100% coverageissue29
Add change note and badge to readme. Remove unused class and function. Omit standalonetests.py entirely from coverage. Another unused class. Incorporate feedback in test__api.py * Bring back _callFUT and make the queryAdapterInContext tests call it * Change raise NotImplentedError into specific fails_if_called() calls. Remove redundant argument now that all test in Test_adapts pass under all versions. Remove NotImplementedError from test_globalregistry.py Remove NotImplementedError from test_hookable.py Remove NotImplementedError from test_registry.py Remove NotImplementedError from test_security.py Remove NotImplementedError from test_zcml.py Remove NotImplementedError from test_factory.py Document ZCML feature and devmode. Really accept all arguments unless opted out.
Diffstat (limited to 'src/zope/component/tests/test_security.py')
-rw-r--r--src/zope/component/tests/test_security.py46
1 files changed, 18 insertions, 28 deletions
diff --git a/src/zope/component/tests/test_security.py b/src/zope/component/tests/test_security.py
index df85129..ea5c72f 100644
--- a/src/zope/component/tests/test_security.py
+++ b/src/zope/component/tests/test_security.py
@@ -15,7 +15,10 @@
"""
import unittest
+from zope.component.tests import skipIfNoSecurity
+from zope.component.tests import fails_if_called
+@skipIfNoSecurity
class PermissionProxyTests(unittest.TestCase):
def _getTargetClass(self):
@@ -38,7 +41,7 @@ class PermissionProxyTests(unittest.TestCase):
proxy = self._makeOne(foo)
self.assertEqual(providedBy(proxy), providedBy(foo))
-
+@skipIfNoSecurity
class Test__checker(unittest.TestCase):
def _callFUT(self, *args, **kw):
@@ -55,12 +58,12 @@ class Test__checker(unittest.TestCase):
from zope.interface import Interface
class IFoo(Interface):
def bar(self):
- pass
+ "bar"
def baz(self):
- pass
+ "baz"
class ISpam(Interface):
def qux(self):
- pass
+ "qux"
checker = self._callFUT(object(), 'testing', (IFoo, ISpam), ())
self.assertEqual(checker.get_permissions,
{'bar': 'testing', 'baz': 'testing', 'qux': 'testing'})
@@ -72,7 +75,7 @@ class Test__checker(unittest.TestCase):
{'foo': 'testing', 'bar': 'testing'})
self.assertFalse(checker.set_permissions)
-
+@skipIfNoSecurity
class Test_proxify(unittest.TestCase):
def _callFUT(self, *args, **kw):
@@ -81,8 +84,7 @@ class Test_proxify(unittest.TestCase):
def _makeContext(self):
class _Context(object):
- def bar(self):
- pass
+ bar = fails_if_called(self)
return _Context()
def test_no_checker_no_provides(self):
@@ -93,7 +95,7 @@ class Test_proxify(unittest.TestCase):
from zope.interface import Interface
class IFoo(Interface):
def bar(self):
- pass
+ "bar"
ctx = self._makeContext()
self.assertRaises(ValueError, self._callFUT, ctx, provides=IFoo)
@@ -103,7 +105,7 @@ class Test_proxify(unittest.TestCase):
from zope.proxy import getProxiedObject
class IFoo(Interface):
def bar(self):
- pass
+ "bar"
ctx = self._makeContext()
proxy = self._callFUT(ctx, provides=IFoo, permission='zope.Public')
self.assertTrue(getProxiedObject(proxy) is ctx)
@@ -116,7 +118,7 @@ class Test_proxify(unittest.TestCase):
from zope.proxy import getProxiedObject
class IFoo(Interface):
def bar(self):
- pass
+ "bar"
ctx = self._makeContext()
proxy = self._callFUT(ctx, provides=IFoo, permission='testing')
self.assertTrue(getProxiedObject(proxy) is ctx)
@@ -132,7 +134,7 @@ class Test_proxify(unittest.TestCase):
self.assertTrue(getProxiedObject(proxy) is ctx)
self.assertTrue(proxy.__Security_checker__ is _CHECKER)
-
+@skipIfNoSecurity
class Test_protectedFactory(unittest.TestCase):
def _callFUT(self, *args, **kw):
@@ -144,10 +146,9 @@ class Test_protectedFactory(unittest.TestCase):
from zope.security.checker import CheckerPublic
class IFoo(Interface):
def bar(self):
- pass
+ "bar"
class _Factory(object):
- def bar(self):
- pass
+ bar = fails_if_called(self)
protected = self._callFUT(_Factory, IFoo, 'zope.Public')
self.assertTrue(protected.factory is _Factory)
foo = protected()
@@ -159,17 +160,16 @@ class Test_protectedFactory(unittest.TestCase):
from zope.security.proxy import getTestProxyItems
class IFoo(Interface):
def bar(self):
- pass
+ "bar"
class _Factory(object):
__slots__ = ('one',)
- def bar(self):
- pass
+ bar = fails_if_called(self)
protected = self._callFUT(_Factory, IFoo, 'testing')
self.assertTrue(protected.factory is _Factory)
foo = protected()
self.assertEqual(getTestProxyItems(foo), [('bar', 'testing')])
-
+@skipIfNoSecurity
class Test_securityAdapterFactory(unittest.TestCase):
def _callFUT(self, *args, **kw):
@@ -237,13 +237,3 @@ class Test_securityAdapterFactory(unittest.TestCase):
pass
proxy = self._callFUT(_Factory, 'testing', True, True)
self.assertTrue(isinstance(proxy, LocatingTrustedAdapterFactory))
-
-
-def test_suite():
- return unittest.TestSuite((
- unittest.makeSuite(PermissionProxyTests),
- unittest.makeSuite(Test__checker),
- unittest.makeSuite(Test_proxify),
- unittest.makeSuite(Test_protectedFactory),
- unittest.makeSuite(Test_securityAdapterFactory),
- ))