[server/test] fix random error in unittest_security
authorJulien Cristau <julien.cristau@logilab.fr>
Mon, 29 Jun 2015 16:58:43 +0200
changeset 10463 9add9b7f9df7
parent 10462 bd2a14d3de15
child 10464 5ad491852062
[server/test] fix random error in unittest_security When entering a new Connection, we cache the user and its 'login' attribute (with no permissions checking). This test makes 'CWUser.login' unreadable by guests, and then proceeds to make sure the 'anon' user can actually not read any 'login' attribute. However, due to the above cnx initialization, anon's login is actually cached, hence readable. This happens to make the test fail sometimes depending on the order in which CWUser entities are returned, because one of them has .complete() called, which as a side effect sets the attribute cache to None for unreadable attributes. Call .complete() on both entities to reset the login cache. While this is still highly debatable, at least it's consistent.
server/test/unittest_security.py
--- a/server/test/unittest_security.py	Mon Jun 29 16:41:36 2015 +0200
+++ b/server/test/unittest_security.py	Mon Jun 29 16:58:43 2015 +0200
@@ -500,6 +500,7 @@
                 rset = cnx.execute('CWUser X')
                 self.assertTrue(rset)
                 x = rset.get_entity(0, 0)
+                x.complete()
                 self.assertEqual(x.login, None)
                 self.assertTrue(x.creation_date)
                 x = rset.get_entity(1, 0)