Zope unit testing - users?
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Is there any way to change the current user in Zope unit tests? I've managed to trace the current user down to SecurityManager._context.user, but reassigning that doesn't seem to make the change. Any hints? I've poked through the Zope source and Products to see if there's any hints - but it doesn't look like anyone unit-tests security restrictions?!? Richard -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (Darwin) iD8DBQE++9RtrGisBEHG6TARAn9aAJ4svSFUua1TNZJBb2dEYG+bG1/fOgCeM+dQ a8pjMvr6jyP/x2EKvVGzh/c= =Psbv -----END PGP SIGNATURE-----
On Fri, Jun 27, 2003 at 03:21:48PM +1000, Richard Jones wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Is there any way to change the current user in Zope unit tests? I've managed to trace the current user down to SecurityManager._context.user, but reassigning that doesn't seem to make the change. Any hints?
I haven't tried it in unit tests, but the technique i use in debugging sessions should work: http://www.zopelabs.com/cookbook/1046449715 -- Paul Winkler http://www.slinkp.com Look! Up in the sky! It's OCTO FLASH STRANGE! (random hero from isometric.spaceninja.com)
Richard Jones wrote at 2003-6-27 15:21 +1000:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Is there any way to change the current user in Zope unit tests? I've managed to trace the current user down to SecurityManager._context.user, but reassigning that doesn't seem to make the change. Any hints?
Yes: from AccessControl.SecurityManagement import newSecurityManager newSecurityManager(None,user) "user" must be a wrapped (in its "acl_users" context) user object. Dieter
You may want to have a look at ZopeTestCase. With it, changing the active user amounts to a call to self.login('someuser') Stefan On Freitag, Jun 27, 2003, at 07:21 Europe/Vienna, Richard Jones wrote:
Is there any way to change the current user in Zope unit tests? I've managed to trace the current user down to SecurityManager._context.user, but reassigning that doesn't seem to make the change. Any hints?
I've poked through the Zope source and Products to see if there's any hints - but it doesn't look like anyone unit-tests security restrictions?!?
-- The time has come to start talking about whether the emperor is as well dressed as we are supposed to think he is. /Pete McBreen/
participants (4)
-
Dieter Maurer -
Paul Winkler -
Richard Jones -
Stefan H. Holek