server/test/unittest_security.py
changeset 9990 c84ad981fc4a
parent 9954 79d34ba48612
parent 9984 793377697c81
child 10136 c33dcd18e0bb
equal deleted inserted replaced
9974:b240b33c7125 9990:c84ad981fc4a
   421             self.assertRaises(Unauthorized, cnx.commit)
   421             self.assertRaises(Unauthorized, cnx.commit)
   422             cnx.execute('SET X test TRUE WHERE X eid %(x)s', {'x': eid})
   422             cnx.execute('SET X test TRUE WHERE X eid %(x)s', {'x': eid})
   423             self.assertRaises(Unauthorized, cnx.commit)
   423             self.assertRaises(Unauthorized, cnx.commit)
   424             cnx.execute('SET X web "http://www.logilab.org" WHERE X eid %(x)s', {'x': eid})
   424             cnx.execute('SET X web "http://www.logilab.org" WHERE X eid %(x)s', {'x': eid})
   425             cnx.commit()
   425             cnx.commit()
       
   426         with self.new_access('iaminusersgrouponly').repo_cnx() as cnx:
       
   427             cnx.execute('INSERT Frozable F: F name "Foo"')
       
   428             cnx.commit()
       
   429             cnx.execute('SET F name "Bar" WHERE F is Frozable')
       
   430             cnx.commit()
       
   431             cnx.execute('SET F name "BaBar" WHERE F is Frozable')
       
   432             cnx.execute('SET F frozen True WHERE F is Frozable')
       
   433             with self.assertRaises(Unauthorized):
       
   434                 cnx.commit()
       
   435             cnx.rollback()
       
   436             cnx.execute('SET F frozen True WHERE F is Frozable')
       
   437             cnx.commit()
       
   438             cnx.execute('SET F name "Bar" WHERE F is Frozable')
       
   439             with self.assertRaises(Unauthorized):
       
   440                 cnx.commit()
   426 
   441 
   427     def test_attribute_security_rqlexpr(self):
   442     def test_attribute_security_rqlexpr(self):
   428         with self.admin_access.repo_cnx() as cnx:
   443         with self.admin_access.repo_cnx() as cnx:
   429             # Note.para attribute editable by managers or if the note is in "todo" state
   444             # Note.para attribute editable by managers or if the note is in "todo" state
   430             note = cnx.execute("INSERT Note X: X para 'bidule'").get_entity(0, 0)
   445             note = cnx.execute("INSERT Note X: X para 'bidule'").get_entity(0, 0)