Changeset 4093


Ignore:
Timestamp:
26 Apr 2009, 13:08:49 (16 years ago)
Author:
uli
Message:

Update tests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • waeup/branches/ulif-rewrite/src/waeup/authentication.txt

    r4092 r4093  
    2828
    2929Before we can login, we have to provide a user (``principal`` in Zope
    30 terms). On the API level we can so by looking up a
    31 UserAuthenticationUtility named ``users``:
     30terms) with a password (and optional a title or description):
    3231
    33   >>> from zope.component import getUtility
    34   >>> from zope.app.authentication.interfaces import IAuthenticatorPlugin
    35   >>> authenticator = getUtility(IAuthenticatorPlugin, name=u'users')
    36 
    37 This plugin also enables us to add new users. At least a username and
    38 a password is required:
    39 
    40   >>> authenticator.addUser('bob', 'bobssecret')
     32  >>> root['app'].users.addUser('bob', 'bobsecret',
     33  ...                           title='Bob', description='A sample user')
    4134
    4235We can also add complete `Account` objects. An `Account` stores the
     
    4538  >>> from waeup.authentication import Account
    4639  >>> alice = Account('alice', 'alicesecret')
    47   >>> authenticator.addAccount(alice)
     40  >>> root['app'].users.addAccount(alice)
     41
     42See ``users.txt`` for details about the UserContainer we use here.
    4843
    4944
     
    6257  True
    6358
     59  >>> 'form.logout' in browser.contents
     60  False
     61
    6462We use this form:
    6563
    66   >>> browser.getControl(name='form.login').value = 'grok'
    67   >>> browser.getControl(name='form.password').value = 'grok'
     64  >>> browser.getControl(name='form.login').value = 'bob'
     65  >>> browser.getControl(name='form.password').value = 'bobsecret'
    6866  >>> browser.getControl('Login').click()
    6967
     68Now the login form is gone. Instead we have the opportunity to logout:
     69
     70  >>> 'form.login' in browser.contents
     71  False
     72
     73  >>> 'form.logout' in browser.contents
     74  True
     75
     76The user name is also displayed in the sidebar:
     77
     78  >>> 'bob' in browser.contents
     79
     80  >>> print browser.contents
Note: See TracChangeset for help on using the changeset viewer.