changeset 5782:c162353f99ed

add a test about saving with ACL change (must raise NoAdmin exception if user has no admin rights)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Wed, 20 Apr 2011 00:27:45 +0200
parents c12c28282eab
children 286215aa1c20
files MoinMoin/_tests/test_PageEditor.py
diffstat 1 files changed, 39 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/_tests/test_PageEditor.py	Sun Apr 17 19:47:04 2011 +0200
+++ b/MoinMoin/_tests/test_PageEditor.py	Wed Apr 20 00:27:45 2011 +0200
@@ -12,6 +12,7 @@
 from MoinMoin import wikiutil
 from MoinMoin.Page import Page
 from MoinMoin.PageEditor import PageEditor
+from MoinMoin.security import parseACL
 
 # TODO: check if and where we can use the helpers:
 from MoinMoin._tests import become_trusted, create_page, nuke_page
@@ -195,6 +196,44 @@
         assert page.body != testtext
 
 
+class TestSaveACLChange(object):
+    from MoinMoin._tests import wikiconfig
+    class Config(wikiconfig.Config):
+        acl_rights_before = 'Trusted:read,write,delete,revert'
+        acl_rights_default = 'All:read,write'
+
+    pagename = u'PageACLTest'
+    oldtext = u'''\
+## foo
+#lang en
+
+foo
+'''
+    newtext = u'''\
+## foo
+#acl -All:write Default
+#lang en
+
+foo
+'''
+
+    def setup_method(self, method):
+        p = PageEditor(self.request, self.pagename)
+        p.saveText(self.oldtext, 0)
+
+    def teardown_method(self, method):
+        become_trusted(self.request)
+        nuke_page(self.request, self.pagename)
+
+    def test_acls(self):
+        p = PageEditor(self.request, self.pagename)
+        oldacl = p.getACL(self.request).acl
+        assert not self.request.user.may.admin(p.page_name)
+        newacl = parseACL(self.request, self.newtext).acl
+        assert newacl != oldacl
+        py.test.raises(PageEditor.NoAdmin, p.saveText, self.newtext, 0)
+
+
 class TestDictPageDeletion(object):
 
     def testCreateDictAndDeleteDictPage(self):