Code

fixed nasty sorting bug that was lowercasing properties
[roundup.git] / test / test_security.py
index dce68fdb0d8ea0459f2cbc7ae44baa8471095eab..97e759f7a58e3da873a4395062c9c6fb0ae97fc5 100644 (file)
@@ -18,7 +18,7 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 # SOFTWARE.
 
-# $Id: test_security.py,v 1.2 2002-07-26 08:27:00 richard Exp $
+# $Id: test_security.py,v 1.5 2002-09-20 05:08:00 richard Exp $
 
 import os, unittest, shutil
 
@@ -32,7 +32,7 @@ class PermissionTest(MyTestCase):
         if os.path.exists(config.DATABASE):
             shutil.rmtree(config.DATABASE)
         os.makedirs(config.DATABASE + '/files')
-        self.db = anydbm.Database(config, 'test')
+        self.db = anydbm.Database(config, 'admin')
         setupSchema(self.db, 1, anydbm)
 
     def testInterfaceSecurity(self):
@@ -66,12 +66,13 @@ class PermissionTest(MyTestCase):
         self.db.security.getPermission('View', 'issue')
 
     def testDBinit(self):
-        self.db.user.create(username="admin", roles='Admin')
         self.db.user.create(username="anonymous", roles='User')
 
     def testAccessControls(self):
         self.testDBinit()
-        self.testInitialiseSecurity()
+        ei = self.db.security.addPermission(name="Edit", klass="issue",
+                        description="User is allowed to edit issues")
+        self.db.security.addPermissionToRole('User', ei)
 
         # test class-level access
         userid = self.db.user.lookup('admin')
@@ -84,6 +85,8 @@ class PermissionTest(MyTestCase):
             'issue'), 1)
         self.assertEquals(self.db.security.hasPermission('Edit', userid,
             'user'), 0)
+        self.assertEquals(self.db.security.hasPermission('View', userid,
+            'issue'), 0)
 
         # test node-level access
         issueid = self.db.issue.create(title='foo', assignedto='admin')
@@ -100,19 +103,4 @@ def suite():
     return unittest.makeSuite(PermissionTest)
 
 
-#
-# $Log: not supported by cvs2svn $
-# Revision 1.1  2002/07/25 07:14:06  richard
-# Bugger it. Here's the current shape of the new security implementation.
-# Still to do:
-#  . call the security funcs from cgi and mailgw
-#  . change shipped templates to include correct initialisation and remove
-#    the old config vars
-# ... that seems like a lot. The bulk of the work has been done though. Honest :)
-#
-# Revision 1.1  2002/07/10 06:40:01  richard
-# ehem, forgot to add
-#
-#
-#
 # vim: set filetype=python ts=4 sw=4 et si