blob: bc5fb03e94c61e417016d66a414724804e5b0504 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
##############################################################################
#
# Copyright (c) 2003 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Test location support
"""
import unittest
from zope.location.location import LocationProxy
from zope.security.tests import QuietWatchingChecker
class LocationSecurityProxyTests(QuietWatchingChecker,
unittest.TestCase):
def test_locationproxy_security(self):
from zope.security.checker import defineChecker
from zope.security.checker import NamesChecker
from zope.security.proxy import ProxyFactory
class Unlocated(object):
a = 'a'
unlocated = Unlocated()
located = LocationProxy(unlocated)
# define a checker for the unlocated object, which will also be
# used by the security proxy as the LocationProxy defines
# __Security_checker__:
unlocatedChecker = NamesChecker(['a'])
defineChecker(Unlocated, unlocatedChecker)
secure_located = ProxyFactory(located)
self.assertEqual(secure_located.a, 'a')
def test_suite():
return unittest.defaultTestLoader.loadTestsFromName(__name__)
|