[PATCH 2 of 3 saem] [test/security] More complete test case about profile permissions

Sylvain Thenault sylvain.thenault at logilab.fr
Wed May 10 10:13:54 CEST 2017


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1493295070 -7200
#      Thu Apr 27 14:11:10 2017 +0200
# Node ID 4e0c6cd1ebe5967795e210573c1058fa29f559c1
# Parent  c11daf9bac09272fb0195e424a20735ccbb9a9c3
# Available At http://hg.logilab.org/review/cubes/saem_ref
#              hg pull http://hg.logilab.org/review/cubes/saem_ref -r 4e0c6cd1ebe5
[test/security] More complete test case about profile permissions

This is also indirectly tested in the seda cube, but it seems that also checking
full security specification from the saem_ref cube may avoid later regression
due to change in underlying cube.

Related to extranet #19216837

diff --git a/test/test_security.py b/test/test_security.py
--- a/test/test_security.py
+++ b/test/test_security.py
@@ -90,10 +90,11 @@ class NonManagerUserTC(CubicWebTC):
         with self.new_access(self.login).cnx() as cnx:
             profile = testutils.setup_profile(cnx)
             cnx.commit()
             profile.cw_set(user_annotation=u'meh')
             cnx.commit()
+
             profile.cw_adapt_to('IWorkflowable').fire_transition('publish')
             cnx.commit()
             testutils.setup_profile(cnx, title=u'Clone', new_version_of=profile)
             cnx.commit()
 
@@ -411,13 +412,21 @@ class ManagerUserTC(CubicWebTC):
             profile = testutils.setup_profile(cnx, title=u'pp')
             cnx.commit()
             # Profile in draft, modifications are allowed.
             profile.cw_set(title=u'ugh')
             cnx.commit()
+            comment = cnx.create_entity('SEDAComment', seda_comment=profile)
+            cnx.commit()
             # Profile published, no modification allowed.
             profile.cw_adapt_to('IWorkflowable').fire_transition('publish')
             cnx.commit()
+            with self.assertUnauthorized(cnx):
+                profile.cw_set(title=u'huugh')
+            with self.assertUnauthorized(cnx):
+                comment.cw_delete()
+            with self.assertUnauthorized(cnx):
+                cnx.create_entity('SEDAArchivalAgreement', seda_archival_agreement=profile)
 
     def test_conceptscheme_wf_permissions(self):
         with self.admin_access.cnx() as cnx:
             scheme = cnx.create_entity('ConceptScheme', ark_naa=testutils.naa(cnx))
             cnx.commit()


More information about the saem-devel mailing list