[Zope-CVS] CVS: Products/AdaptableStorage/tests - testParams.py:1.1 Zope2TestBase.py:1.9 testAll.py:1.6
Shane Hathaway
shane@zope.com
Sat, 1 Mar 2003 15:43:07 -0500
Update of /cvs-repository/Products/AdaptableStorage/tests
In directory cvs.zope.org:/tmp/cvs-serv29278/tests
Modified Files:
Zope2TestBase.py testAll.py
Added Files:
testParams.py
Log Message:
- Added SecurityAttributes, FSSecurityAttributes, and
SQLSecurityAttributes. These classes store Zope 2 role names, local
roles, executable ownership, permission mappings, and proxy roles.
(Until now, all of this ended up in the remainder pickle.)
- Added a second abstract object mapper to Zope2Mapper. The "base"
mapper has no properties aspect, while the "base_p" mapper does. This
made Zope2FS and Zope2SQL a little cleaner, since they don't have to
remove the properties aspect.
- Added corresponding unit tests.
=== Added File Products/AdaptableStorage/tests/testParams.py ===
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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.
#
##############################################################################
"""Tests of gateway_fs.params
$Id: testParams.py,v 1.1 2003/03/01 20:43:03 shane Exp $
"""
import unittest
from Products.AdaptableStorage.gateway_fs.params \
import stringToParams, paramsToString
class ParamsTests(unittest.TestCase):
def testStringToParams(self):
s = 'abc def="123 456\\n \\"done\\" " ghi=4 j567 \n'
params = stringToParams(s)
self.assertEqual(tuple(params), (
('abc', ''),
('def', '123 456\n "done" '),
('ghi', '4'),
('j567', ''),
))
def testParamsToString(self):
params = (
('abc', ''),
('def', '123 456\n "done" '),
('ghi', '4'),
('j567', ''),
)
s = paramsToString(params)
self.assertEqual(s, 'abc def="123 456\\n \\"done\\" " ghi="4" j567')
def testInvalidKeys(self):
paramsToString((('abc_-09ABC', ''),))
self.assertRaises(ValueError, paramsToString, (('a bc', ''),))
self.assertRaises(ValueError, paramsToString, (('a\nbc', ''),))
self.assertRaises(ValueError, paramsToString, (('', ''),))
self.assertRaises(ValueError, paramsToString, ((' abc', ''),))
self.assertRaises(ValueError, paramsToString, (('abc ', ''),))
self.assertRaises(ValueError, paramsToString, (('a\tbc', ''),))
self.assertRaises(ValueError, paramsToString, (('a\rbc', ''),))
self.assertRaises(ValueError, paramsToString, (('a"bc', ''),))
self.assertRaises(ValueError, paramsToString, (('0abc', ''),))
if __name__ == '__main__':
unittest.main()
=== Products/AdaptableStorage/tests/Zope2TestBase.py 1.8 => 1.9 ===
--- Products/AdaptableStorage/tests/Zope2TestBase.py:1.8 Thu Feb 6 13:39:22 2003
+++ Products/AdaptableStorage/tests/Zope2TestBase.py Sat Mar 1 15:43:03 2003
@@ -466,3 +466,49 @@
conn.close()
+ def testSecurityAttributes(self):
+ conn = self.db.open()
+ try:
+ app = conn.root()['Application']
+ f = Folder()
+ f.id = 'Holidays'
+ app._setObject(f.id, f, set_owner=0)
+ f = app.Holidays
+ u = UserFolder()
+ u.id = 'acl_users'
+ f._setObject(u.id, u, set_owner=0)
+ u._doAddUser('shane', 'abcdefg', ('Elder',), ())
+
+ f._owner = (['Holidays', 'acl_users'], 'shane')
+ f.__ac_roles__ = ['Elder', 'Missionary']
+ f.__ac_local_roles__ = {'shane': ['Missionary']}
+ f._proxy_roles = ['Manager']
+ f._View_Permission = ['Owner', 'Elder']
+
+ get_transaction().commit()
+
+ conn2 = self.db.open()
+ try:
+ app = conn2.root()['Application']
+ f = app.Holidays
+ user = f.getOwner()
+ self.assertEqual(user.getUserName(), 'shane')
+ self.assert_('Elder' in user.getRoles())
+
+ roles = {}
+ for role in list(user.getRolesInContext(f)):
+ if role != 'Authenticated' and role != 'Anonymous':
+ roles[role] = 1
+ self.assertEqual(roles, {'Elder':1, 'Missionary':1})
+ self.assertEqual(tuple(f._proxy_roles), ('Manager',))
+
+ roles = {}
+ for role in list(f._View_Permission):
+ roles[role] = 1
+ self.assertEqual(roles, {'Elder':1, 'Owner':1})
+ finally:
+ conn2.close()
+
+ finally:
+ conn.close()
+
=== Products/AdaptableStorage/tests/testAll.py 1.5 => 1.6 ===
--- Products/AdaptableStorage/tests/testAll.py:1.5 Mon Feb 3 13:31:59 2003
+++ Products/AdaptableStorage/tests/testAll.py Sat Mar 1 15:43:03 2003
@@ -27,6 +27,7 @@
from testInterfaceImpl import InterfaceImplTests
from testASStorage import ASStorageTests
from testZope2FS import Zope2FSTests, Zope2FSUnderscoreTests
+from testParams import ParamsTests
try:
import psycopg