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