[Zope-PAS] Zope2 user id/username semantics

Mark Hammond mhammond at skippinet.com.au
Thu Oct 14 00:29:43 EDT 2004


Seeing as code is worth 1000 words, and to celebrate the fact I worked out
how to run Zope tests on Windows <wink>, I added this test function to
test_PluggableAuthService:

    def test_getUser_id_and_name( self ):
        from Products.PluggableAuthService.interfaces.plugins \
             import IUserEnumerationPlugin

        plugins = self._makePlugins()
        zcuf = self._makeOne( plugins )

        bar = self._makeUserEnumerator( 'bar', 'bar at example.com' )
        zcuf._setObject( 'bar', bar )

        # Check an invalid ID does return None
        self.assertEqual(zcuf.getUserById('xxx__xxx'), None)

        user = zcuf.getUserById('bar__bar')
        self.assertEqual( user.getUserName(), 'bar at example.com' )

All but the last 3 lines (4 including the comment) are copied from other
tests.  When I run this, I see:

> AssertionError: 'bar__bar' != 'bar at example.com'

What it does is:
* Creates a user with an explicit 'id' and 'username'
* For the sake of demonstration, checks that asking for an unknown user ID
returns None
* Asks for the known user we previously created.
* Checks the username is as specified when we created it.

Can someone please confirm this test is valid and that it demonstrates a
bug?  It will not be trivial to fix, so I only want to spend the time if it
wont be wasted.

Thanks,

Mark.



More information about the Zope-PAS mailing list