server/test/unittest_security.py
changeset 9984 793377697c81
parent 9782 95e8fa2c8da8
parent 9981 7099bbd685aa
child 9990 c84ad981fc4a
child 10114 6f4b4567b77d
equal deleted inserted replaced
9979:9ccdb3751fbe 9984:793377697c81
   406             self.assertRaises(Unauthorized, cnx.commit)
   406             self.assertRaises(Unauthorized, cnx.commit)
   407             cnx.execute('SET X test TRUE WHERE X eid %(x)s', {'x': eid})
   407             cnx.execute('SET X test TRUE WHERE X eid %(x)s', {'x': eid})
   408             self.assertRaises(Unauthorized, cnx.commit)
   408             self.assertRaises(Unauthorized, cnx.commit)
   409             cnx.execute('SET X web "http://www.logilab.org" WHERE X eid %(x)s', {'x': eid})
   409             cnx.execute('SET X web "http://www.logilab.org" WHERE X eid %(x)s', {'x': eid})
   410             cnx.commit()
   410             cnx.commit()
       
   411         with self.new_access('iaminusersgrouponly').repo_cnx() as cnx:
       
   412             cnx.execute('INSERT Frozable F: F name "Foo"')
       
   413             cnx.commit()
       
   414             cnx.execute('SET F name "Bar" WHERE F is Frozable')
       
   415             cnx.commit()
       
   416             cnx.execute('SET F name "BaBar" WHERE F is Frozable')
       
   417             cnx.execute('SET F frozen True WHERE F is Frozable')
       
   418             with self.assertRaises(Unauthorized):
       
   419                 cnx.commit()
       
   420             cnx.rollback()
       
   421             cnx.execute('SET F frozen True WHERE F is Frozable')
       
   422             cnx.commit()
       
   423             cnx.execute('SET F name "Bar" WHERE F is Frozable')
       
   424             with self.assertRaises(Unauthorized):
       
   425                 cnx.commit()
   411 
   426 
   412     def test_attribute_security_rqlexpr(self):
   427     def test_attribute_security_rqlexpr(self):
   413         with self.admin_access.repo_cnx() as cnx:
   428         with self.admin_access.repo_cnx() as cnx:
   414             # Note.para attribute editable by managers or if the note is in "todo" state
   429             # Note.para attribute editable by managers or if the note is in "todo" state
   415             note = cnx.execute("INSERT Note X: X para 'bidule'").get_entity(0, 0)
   430             note = cnx.execute("INSERT Note X: X para 'bidule'").get_entity(0, 0)