source: main/waeup.sirp/trunk/src/waeup/sirp/users.txt @ 6064

Last change on this file since 6064 was 5140, checked in by uli, 15 years ago

Update all unit tests that use the ZCA to run inside the new unit test layer.

File size: 1.5 KB
RevLine 
[4090]1User for the WAeUP portal
2*************************
3
[5140]4.. :doctest:
5.. :layer: waeup.sirp.testing.WAeUPSIRPUnitTestLayer
[4090]6
7Before we can start, we need some password managers available:
8
9    >>> from zope.app.authentication.placelesssetup import (
10    ...   PlacelessSetup)
11    >>> PlacelessSetup().setUp()
12
13User Containers
14===============
15
16We can create a user container which will hold the useraccounts for
17us:
18
[4920]19    >>> from waeup.sirp.users import UserContainer
[4090]20    >>> myusers = UserContainer()
21
22We can add users, just by passing a name, a password, and (optionally)
23a title and a description:
24
25    >>> myusers.addUser('bob', 'bobssecret')
26
27Now, Bob is in the container:
28
29    >>> list(myusers)
30    [u'bob']
31
32We can get Bob's account:
33
34    >>> bob = myusers['bob']
35    >>> bob
[4920]36    <waeup.sirp.authentication.Account object at 0x...>
[4090]37
38    >>> bob.name
39    'bob'
40
41    >>> bob.title
42    'bob'
43
44    >>> bob.description
45    'bob'
46
47As we did not give a title nor description, the name was taken instead
48for these values. The password, however, is stored encoded:
49
50    >>> bob.password
51    '...15aca8166'
52
53Remark: that we can tell the last chars of the 'encrypted' password,
54means, that the encryption is broken or at least waeker as it should
55be.
56
57XXX: We could provide a stronger (correct) SHA encryption.
58
59We can delete users:
60
61    >>> myusers.delUser('alice')
62
63The container won't complain, although there is no ``alice`` stored
64yet. But we can really delete users:
65
66    >>> myusers.delUser('bob')
67    >>> list(myusers)
68    []
Note: See TracBrowser for help on using the repository browser.