Mercurial > moin > 1.9
annotate MoinMoin/_tests/test_user.py @ 6028:1893da1d5213
userid lookup caches: use 1 on-disk cache file, update cache rather than rebuild
Before this, we maintained one cache file per attribute (e.g. name2id, openid2id,
...) - the related code did multiple passes over all user profiles to rebuild these
cache files.
Now doing a one-pass rebuild, writing all attribute -> userid mappings into
one on-disk cache file called "lookup".
Additionally to "name" and "openids", support fast lookup for "email" and "jid" also.
On profile save, we use to just kill the cache and let it rebuild. Now the cache
is read, updated and written back (which is much less expensive for wikis with more
than a few users).
Did some refactoring also, reducing duplication, breaking down the code into smaller
functions / methods.
author | Thomas Waldmann <tw AT waldmann-edv DOT de> |
---|---|
date | Wed, 12 Feb 2014 18:22:10 +0100 |
parents | 05a6897ee496 |
children |
rev | line source |
---|---|
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
1 # -*- coding: utf-8 -*- |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
2 """ |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
3 MoinMoin - MoinMoin.user Tests |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
4 |
1918
bb2e053067fb
fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1801
diff
changeset
|
5 @copyright: 2003-2004 by Juergen Hermann <jh@web.de> |
4656
052b6926c82d
test_user: added two tests for the difference of retrieving an user object by uid or name
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
4027
diff
changeset
|
6 2009 by ReimarBauer |
5918
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
7 2013 by MoinMoin:ThomasWaldmann |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
8 @license: GNU GPL, see COPYING for details. |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
9 """ |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
10 |
2818
7fceb3588211
tests: convert user tests to py.test, fix tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2448
diff
changeset
|
11 import os |
2006
1339d6fdc4ff
Changed tests to use py.test. Also changed the semantics a bit - the test wiki directory is only created freshly if it does not exist.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
1918
diff
changeset
|
12 import py |
1339d6fdc4ff
Changed tests to use py.test. Also changed the semantics a bit - the test wiki directory is only created freshly if it does not exist.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
1918
diff
changeset
|
13 |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
14 from MoinMoin import user, caching |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
15 |
2006
1339d6fdc4ff
Changed tests to use py.test. Also changed the semantics a bit - the test wiki directory is only created freshly if it does not exist.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
1918
diff
changeset
|
16 |
2818
7fceb3588211
tests: convert user tests to py.test, fix tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2448
diff
changeset
|
17 class TestEncodePassword(object): |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
18 """user: encode passwords tests""" |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
19 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
20 def testAscii(self): |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
21 """user: encode ascii password""" |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
22 # u'MoinMoin' and 'MoinMoin' should be encoded to same result |
5922
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
23 cfg = self.request.cfg |
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
24 tests = [ |
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
25 ('{PASSLIB}', '12345', "{PASSLIB}$6$rounds=1001$12345$jrPUCzPJt1yiixDbzIgSBoKED0/DlNDTHZN3lVarCtN6IM/.LoAw5pgUQH112CErU6wS8HXTZNpqb7wVjHLs/0"), |
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
26 ('{SSHA}', '12345', "{SSHA}xkDIIx1I7A4gC98Vt/+UelIkTDYxMjM0NQ=="), |
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
27 ] |
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
28 for scheme, salt, expected in tests: |
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
29 result = user.encodePassword(cfg, "MoinMoin", salt=salt, scheme=scheme) |
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
30 assert result == expected |
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
31 result = user.encodePassword(cfg, u"MoinMoin", salt=salt, scheme=scheme) |
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
32 assert result == expected |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
33 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
34 def testUnicode(self): |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
35 """ user: encode unicode password """ |
5922
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
36 cfg = self.request.cfg |
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
37 tests = [ |
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
38 ('{PASSLIB}', '12345', "{PASSLIB}$6$rounds=1001$12345$5srFB66ZCu2JgGwPgdfb1lHRmqkjnKC/RxdsFlWn2WzoQh3btIjH6Ai1LJV9iYLDa9kLP/VQYa4DHLkRnaBw8."), |
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
39 ('{SSHA}', '12345', "{SSHA}YiwfeVWdVW9luqyVn8t2JivlzmUxMjM0NQ=="), |
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
40 ] |
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
41 for scheme, salt, expected in tests: |
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
42 result = user.encodePassword(cfg, u'סיסמה סודית בהחלט', salt=salt, scheme=scheme) # Hebrew |
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
43 assert result == expected |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
44 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
45 |
2818
7fceb3588211
tests: convert user tests to py.test, fix tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2448
diff
changeset
|
46 class TestLoginWithPassword(object): |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
47 """user: login tests""" |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
48 |
2818
7fceb3588211
tests: convert user tests to py.test, fix tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2448
diff
changeset
|
49 def setup_method(self, method): |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
50 # Save original user and cookie |
4212
1ca179133f01
Fix tests: small fixes after merge
Florian Krupicka <florian.krupicka@googlemail.com>
parents:
3820
diff
changeset
|
51 self.saved_cookie = self.request.cookies |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
52 self.saved_user = self.request.user |
892
9931a09387b0
some whitespace cleanup in the tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
682
diff
changeset
|
53 |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
54 # Create anon user for the tests |
4212
1ca179133f01
Fix tests: small fixes after merge
Florian Krupicka <florian.krupicka@googlemail.com>
parents:
3820
diff
changeset
|
55 self.request.cookies = {} |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
56 self.request.user = user.User(self.request) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
57 |
2165
eed1c7da25eb
test_user: fix wrong subscription tests and a few other problems
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2140
diff
changeset
|
58 self.user = None |
5922
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
59 self.passlib_support = self.request.cfg.passlib_support |
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
60 self.password_scheme = self.request.cfg.password_scheme |
892
9931a09387b0
some whitespace cleanup in the tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
682
diff
changeset
|
61 |
2818
7fceb3588211
tests: convert user tests to py.test, fix tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2448
diff
changeset
|
62 def teardown_method(self, method): |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
63 """ Run after each test |
2286
01f05e74aa9c
Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2165
diff
changeset
|
64 |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
65 Remove user and reset user listing cache. |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
66 """ |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
67 # Remove user file and user |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
68 if self.user is not None: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
69 try: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
70 path = self.user._User__filename() |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
71 os.remove(path) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
72 except OSError: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
73 pass |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
74 del self.user |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
75 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
76 # Restore original user |
4212
1ca179133f01
Fix tests: small fixes after merge
Florian Krupicka <florian.krupicka@googlemail.com>
parents:
3820
diff
changeset
|
77 self.request.cookies = self.saved_cookie |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
78 self.request.user = self.saved_user |
892
9931a09387b0
some whitespace cleanup in the tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
682
diff
changeset
|
79 |
6025
05a6897ee496
"userdir" caching scope: use it for userid lookup caches, reduce code duplication
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5922
diff
changeset
|
80 # Remove user lookup caches, or next test will fail |
6028
1893da1d5213
userid lookup caches: use 1 on-disk cache file, update cache rather than rebuild
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
6025
diff
changeset
|
81 user.clearLookupCaches(self.request) |
892
9931a09387b0
some whitespace cleanup in the tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
682
diff
changeset
|
82 |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
83 def testAsciiPassword(self): |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
84 """ user: login with ascii password """ |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
85 # Create test user |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
86 name = u'__Non Existent User Name__' |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
87 password = name |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
88 self.createUser(name, password) |
892
9931a09387b0
some whitespace cleanup in the tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
682
diff
changeset
|
89 |
2286
01f05e74aa9c
Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2165
diff
changeset
|
90 # Try to "login" |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
91 theUser = user.User(self.request, name=name, password=password) |
2818
7fceb3588211
tests: convert user tests to py.test, fix tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2448
diff
changeset
|
92 assert theUser.valid |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
93 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
94 def testUnicodePassword(self): |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
95 """ user: login with non-ascii password """ |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
96 # Create test user |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
97 name = u'__שם משתמש לא קיים__' # Hebrew |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
98 password = name |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
99 self.createUser(name, password) |
892
9931a09387b0
some whitespace cleanup in the tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
682
diff
changeset
|
100 |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
101 # Try to "login" |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
102 theUser = user.User(self.request, name=name, password=password) |
2818
7fceb3588211
tests: convert user tests to py.test, fix tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2448
diff
changeset
|
103 assert theUser.valid |
5740
51240cc99af5
Add new tests for user auth with migrated passwords (ARP1, MD5, DES)
pavel_vinogradov
parents:
5739
diff
changeset
|
104 |
51240cc99af5
Add new tests for user auth with migrated passwords (ARP1, MD5, DES)
pavel_vinogradov
parents:
5739
diff
changeset
|
105 def test_auth_with_apr1_stored_password(self): |
51240cc99af5
Add new tests for user auth with migrated passwords (ARP1, MD5, DES)
pavel_vinogradov
parents:
5739
diff
changeset
|
106 """ |
51240cc99af5
Add new tests for user auth with migrated passwords (ARP1, MD5, DES)
pavel_vinogradov
parents:
5739
diff
changeset
|
107 Create user with {APR1} password and check that user can login. |
5918
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
108 Also check if auto-upgrade happens and is saved to disk. |
5740
51240cc99af5
Add new tests for user auth with migrated passwords (ARP1, MD5, DES)
pavel_vinogradov
parents:
5739
diff
changeset
|
109 """ |
51240cc99af5
Add new tests for user auth with migrated passwords (ARP1, MD5, DES)
pavel_vinogradov
parents:
5739
diff
changeset
|
110 # Create test user |
51240cc99af5
Add new tests for user auth with migrated passwords (ARP1, MD5, DES)
pavel_vinogradov
parents:
5739
diff
changeset
|
111 name = u'Test User' |
5918
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
112 password = '12345' |
5746
ff282aaf7912
Replace test password hashes (for APR1 and DES) with htpasswd generated
pavel_vinogradov
parents:
5745
diff
changeset
|
113 # generated with "htpasswd -nbm blaze 12345" |
5918
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
114 pw_hash = '{APR1}$apr1$NG3VoiU5$PSpHT6tV0ZMKkSZ71E3qg.' |
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
115 self.createUser(name, pw_hash, True) |
5786
8cb5ab136b87
fix trailing blanks
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5747
diff
changeset
|
116 |
5740
51240cc99af5
Add new tests for user auth with migrated passwords (ARP1, MD5, DES)
pavel_vinogradov
parents:
5739
diff
changeset
|
117 # Try to "login" |
5918
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
118 theuser = user.User(self.request, name=name, password=password) |
5740
51240cc99af5
Add new tests for user auth with migrated passwords (ARP1, MD5, DES)
pavel_vinogradov
parents:
5739
diff
changeset
|
119 assert theuser.valid |
5918
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
120 # Check if the stored password was auto-upgraded on login and saved |
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
121 theuser = user.User(self.request, name=name, password=password) |
5922
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
122 assert theuser.enc_password.startswith(self.password_scheme) |
5740
51240cc99af5
Add new tests for user auth with migrated passwords (ARP1, MD5, DES)
pavel_vinogradov
parents:
5739
diff
changeset
|
123 |
51240cc99af5
Add new tests for user auth with migrated passwords (ARP1, MD5, DES)
pavel_vinogradov
parents:
5739
diff
changeset
|
124 def test_auth_with_md5_stored_password(self): |
51240cc99af5
Add new tests for user auth with migrated passwords (ARP1, MD5, DES)
pavel_vinogradov
parents:
5739
diff
changeset
|
125 """ |
51240cc99af5
Add new tests for user auth with migrated passwords (ARP1, MD5, DES)
pavel_vinogradov
parents:
5739
diff
changeset
|
126 Create user with {MD5} password and check that user can login. |
5918
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
127 Also check if auto-upgrade happens and is saved to disk. |
5740
51240cc99af5
Add new tests for user auth with migrated passwords (ARP1, MD5, DES)
pavel_vinogradov
parents:
5739
diff
changeset
|
128 """ |
51240cc99af5
Add new tests for user auth with migrated passwords (ARP1, MD5, DES)
pavel_vinogradov
parents:
5739
diff
changeset
|
129 # Create test user |
51240cc99af5
Add new tests for user auth with migrated passwords (ARP1, MD5, DES)
pavel_vinogradov
parents:
5739
diff
changeset
|
130 name = u'Test User' |
5918
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
131 password = '12345' |
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
132 pw_hash = '{MD5}$1$salt$etVYf53ma13QCiRbQOuRk/' |
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
133 self.createUser(name, pw_hash, True) |
5786
8cb5ab136b87
fix trailing blanks
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5747
diff
changeset
|
134 |
5740
51240cc99af5
Add new tests for user auth with migrated passwords (ARP1, MD5, DES)
pavel_vinogradov
parents:
5739
diff
changeset
|
135 # Try to "login" |
5918
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
136 theuser = user.User(self.request, name=name, password=password) |
5740
51240cc99af5
Add new tests for user auth with migrated passwords (ARP1, MD5, DES)
pavel_vinogradov
parents:
5739
diff
changeset
|
137 assert theuser.valid |
5918
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
138 # Check if the stored password was auto-upgraded on login and saved |
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
139 theuser = user.User(self.request, name=name, password=password) |
5922
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
140 assert theuser.enc_password.startswith(self.password_scheme) |
5740
51240cc99af5
Add new tests for user auth with migrated passwords (ARP1, MD5, DES)
pavel_vinogradov
parents:
5739
diff
changeset
|
141 |
51240cc99af5
Add new tests for user auth with migrated passwords (ARP1, MD5, DES)
pavel_vinogradov
parents:
5739
diff
changeset
|
142 def test_auth_with_des_stored_password(self): |
51240cc99af5
Add new tests for user auth with migrated passwords (ARP1, MD5, DES)
pavel_vinogradov
parents:
5739
diff
changeset
|
143 """ |
51240cc99af5
Add new tests for user auth with migrated passwords (ARP1, MD5, DES)
pavel_vinogradov
parents:
5739
diff
changeset
|
144 Create user with {DES} password and check that user can login. |
5918
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
145 Also check if auto-upgrade happens and is saved to disk. |
5740
51240cc99af5
Add new tests for user auth with migrated passwords (ARP1, MD5, DES)
pavel_vinogradov
parents:
5739
diff
changeset
|
146 """ |
51240cc99af5
Add new tests for user auth with migrated passwords (ARP1, MD5, DES)
pavel_vinogradov
parents:
5739
diff
changeset
|
147 # Create test user |
51240cc99af5
Add new tests for user auth with migrated passwords (ARP1, MD5, DES)
pavel_vinogradov
parents:
5739
diff
changeset
|
148 name = u'Test User' |
5918
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
149 password = '12345' |
5746
ff282aaf7912
Replace test password hashes (for APR1 and DES) with htpasswd generated
pavel_vinogradov
parents:
5745
diff
changeset
|
150 # generated with "htpasswd -nbd blaze 12345" |
5918
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
151 pw_hash = '{DES}gArsfn7O5Yqfo' |
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
152 self.createUser(name, pw_hash, True) |
5786
8cb5ab136b87
fix trailing blanks
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5747
diff
changeset
|
153 |
5740
51240cc99af5
Add new tests for user auth with migrated passwords (ARP1, MD5, DES)
pavel_vinogradov
parents:
5739
diff
changeset
|
154 try: |
51240cc99af5
Add new tests for user auth with migrated passwords (ARP1, MD5, DES)
pavel_vinogradov
parents:
5739
diff
changeset
|
155 import crypt |
51240cc99af5
Add new tests for user auth with migrated passwords (ARP1, MD5, DES)
pavel_vinogradov
parents:
5739
diff
changeset
|
156 # Try to "login" |
5918
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
157 theuser = user.User(self.request, name=name, password=password) |
5740
51240cc99af5
Add new tests for user auth with migrated passwords (ARP1, MD5, DES)
pavel_vinogradov
parents:
5739
diff
changeset
|
158 assert theuser.valid |
5918
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
159 # Check if the stored password was auto-upgraded on login and saved |
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
160 theuser = user.User(self.request, name=name, password=password) |
5922
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
161 assert theuser.enc_password.startswith(self.password_scheme) |
5740
51240cc99af5
Add new tests for user auth with migrated passwords (ARP1, MD5, DES)
pavel_vinogradov
parents:
5739
diff
changeset
|
162 except ImportError: |
5744
50b3926c8880
Fix py.test.skip message in test_auth_with_des_stored_password test.
pavel_vinogradov
parents:
5743
diff
changeset
|
163 py.test.skip("Platform does not provide crypt module!") |
5786
8cb5ab136b87
fix trailing blanks
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5747
diff
changeset
|
164 |
5918
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
165 def test_auth_with_sha_stored_password(self): |
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
166 """ |
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
167 Create user with {SHA} password and check that user can login. |
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
168 Also check if auto-upgrade happens and is saved to disk. |
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
169 """ |
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
170 # Create test user |
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
171 name = u'Test User' |
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
172 password = '12345' |
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
173 pw_hash = '{SHA}jLIjfQZ5yojbZGTqxg2pY0VROWQ=' |
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
174 self.createUser(name, pw_hash, True) |
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
175 |
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
176 # Try to "login" |
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
177 theuser = user.User(self.request, name=name, password=password) |
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
178 assert theuser.valid |
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
179 # Check if the stored password was auto-upgraded on login and saved |
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
180 theuser = user.User(self.request, name=name, password=password) |
5922
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
181 assert theuser.enc_password.startswith(self.password_scheme) |
5918
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
182 |
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
183 def test_auth_with_ssha_stored_password(self): |
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
184 """ |
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
185 Create user with {SSHA} password and check that user can login. |
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
186 Also check if auto-upgrade happens and is saved to disk. |
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
187 """ |
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
188 # Create test user |
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
189 name = u'Test User' |
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
190 password = '12345' |
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
191 pw_hash = '{SSHA}dbeFtH5EGkOI1jgPADlGZgHWq072TIsKqWfHX7zZbUQa85Ze8774Rg==' |
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
192 self.createUser(name, pw_hash, True) |
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
193 |
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
194 # Try to "login" |
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
195 theuser = user.User(self.request, name=name, password=password) |
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
196 assert theuser.valid |
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
197 # Check if the stored password was auto-upgraded on login and saved |
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
198 theuser = user.User(self.request, name=name, password=password) |
5922
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
199 assert theuser.enc_password.startswith(self.password_scheme) |
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
200 |
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
201 def test_auth_with_passlib_stored_password(self): |
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
202 """ |
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
203 Create user with {PASSLIB} password and check that user can login. |
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
204 """ |
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
205 if not self.passlib_support: |
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
206 py.test.skip("test requires passlib, but passlib_support is False") |
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
207 # Create test user |
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
208 name = u'Test User' |
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
209 password = '12345' |
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
210 pw_hash = '{PASSLIB}$6$rounds=1001$/AVWSh/RUWpcppfl$8DCRGLaBD3KoV4Ag67sUv6b2QdrUFXk1yWCxqWnBLJ.iHSe4Piv6nqzSQgELeLPIvwTC9APaWv1XCTOHjkLOj/' |
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
211 self.createUser(name, pw_hash, True) |
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
212 |
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
213 # Try to "login" |
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
214 theuser = user.User(self.request, name=name, password=password) |
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
215 assert theuser.valid |
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
216 # Check if the stored password was auto-upgraded on login and saved |
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
217 theuser = user.User(self.request, name=name, password=password) |
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
218 assert theuser.enc_password.startswith(self.password_scheme) |
5918
5126fadbf24f
password related code and tests - clean up and refactor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5786
diff
changeset
|
219 |
2038
bd83616af43a
test_user: tests for subscription of pages and subpages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
2006
diff
changeset
|
220 def testSubscriptionSubscribedPage(self): |
bd83616af43a
test_user: tests for subscription of pages and subpages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
2006
diff
changeset
|
221 """ user: tests isSubscribedTo """ |
bd83616af43a
test_user: tests for subscription of pages and subpages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
2006
diff
changeset
|
222 pagename = u'HelpMiscellaneous' |
bd83616af43a
test_user: tests for subscription of pages and subpages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
2006
diff
changeset
|
223 name = u'__Jürgen Herman__' |
bd83616af43a
test_user: tests for subscription of pages and subpages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
2006
diff
changeset
|
224 password = name |
3818
fe9305d5c7cf
user: adjust tests, add one for password upgrade and fix a bug found
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
3120
diff
changeset
|
225 self.createUser(name, password) |
2038
bd83616af43a
test_user: tests for subscription of pages and subpages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
2006
diff
changeset
|
226 # Login - this should replace the old password in the user file |
bd83616af43a
test_user: tests for subscription of pages and subpages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
2006
diff
changeset
|
227 theUser = user.User(self.request, name=name, password=password) |
bd83616af43a
test_user: tests for subscription of pages and subpages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
2006
diff
changeset
|
228 theUser.subscribe(pagename) |
2827
c61cd68592c2
test_user: fixed indenting
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
2818
diff
changeset
|
229 assert theUser.isSubscribedTo([pagename]) # list(!) of pages to check |
892
9931a09387b0
some whitespace cleanup in the tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
682
diff
changeset
|
230 |
2038
bd83616af43a
test_user: tests for subscription of pages and subpages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
2006
diff
changeset
|
231 def testSubscriptionSubPage(self): |
bd83616af43a
test_user: tests for subscription of pages and subpages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
2006
diff
changeset
|
232 """ user: tests isSubscribedTo on a subpage """ |
bd83616af43a
test_user: tests for subscription of pages and subpages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
2006
diff
changeset
|
233 pagename = u'HelpMiscellaneous' |
bd83616af43a
test_user: tests for subscription of pages and subpages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
2006
diff
changeset
|
234 testPagename = u'HelpMiscellaneous/FrequentlyAskedQuestions' |
bd83616af43a
test_user: tests for subscription of pages and subpages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
2006
diff
changeset
|
235 name = u'__Jürgen Herman__' |
bd83616af43a
test_user: tests for subscription of pages and subpages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
2006
diff
changeset
|
236 password = name |
3818
fe9305d5c7cf
user: adjust tests, add one for password upgrade and fix a bug found
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
3120
diff
changeset
|
237 self.createUser(name, password) |
2038
bd83616af43a
test_user: tests for subscription of pages and subpages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
2006
diff
changeset
|
238 # Login - this should replace the old password in the user file |
bd83616af43a
test_user: tests for subscription of pages and subpages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
2006
diff
changeset
|
239 theUser = user.User(self.request, name=name, password=password) |
bd83616af43a
test_user: tests for subscription of pages and subpages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
2006
diff
changeset
|
240 theUser.subscribe(pagename) |
2827
c61cd68592c2
test_user: fixed indenting
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
2818
diff
changeset
|
241 assert not theUser.isSubscribedTo([testPagename]) # list(!) of pages to check |
3120
a7c1680aeaa0
PEP8 fixes, mostly whitespace
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
3103
diff
changeset
|
242 |
3103
4ede355c6089
bugfix for renaming of users (/MoinMoinBugs/RenamingUserAllowsOldUsernameToLogin) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
2827
diff
changeset
|
243 def testRenameUser(self): |
6028
1893da1d5213
userid lookup caches: use 1 on-disk cache file, update cache rather than rebuild
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
6025
diff
changeset
|
244 """ create user and then rename user and check whether |
1893da1d5213
userid lookup caches: use 1 on-disk cache file, update cache rather than rebuild
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
6025
diff
changeset
|
245 the old username is removed (and the lookup cache behaves well) |
3103
4ede355c6089
bugfix for renaming of users (/MoinMoinBugs/RenamingUserAllowsOldUsernameToLogin) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
2827
diff
changeset
|
246 """ |
4ede355c6089
bugfix for renaming of users (/MoinMoinBugs/RenamingUserAllowsOldUsernameToLogin) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
2827
diff
changeset
|
247 # Create test user |
4ede355c6089
bugfix for renaming of users (/MoinMoinBugs/RenamingUserAllowsOldUsernameToLogin) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
2827
diff
changeset
|
248 name = u'__Some Name__' |
4ede355c6089
bugfix for renaming of users (/MoinMoinBugs/RenamingUserAllowsOldUsernameToLogin) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
2827
diff
changeset
|
249 password = name |
4ede355c6089
bugfix for renaming of users (/MoinMoinBugs/RenamingUserAllowsOldUsernameToLogin) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
2827
diff
changeset
|
250 self.createUser(name, password) |
4ede355c6089
bugfix for renaming of users (/MoinMoinBugs/RenamingUserAllowsOldUsernameToLogin) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
2827
diff
changeset
|
251 # Login - this should replace the old password in the user file |
4ede355c6089
bugfix for renaming of users (/MoinMoinBugs/RenamingUserAllowsOldUsernameToLogin) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
2827
diff
changeset
|
252 theUser = user.User(self.request, name=name) |
4ede355c6089
bugfix for renaming of users (/MoinMoinBugs/RenamingUserAllowsOldUsernameToLogin) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
2827
diff
changeset
|
253 # Rename user |
4ede355c6089
bugfix for renaming of users (/MoinMoinBugs/RenamingUserAllowsOldUsernameToLogin) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
2827
diff
changeset
|
254 theUser.name = u'__SomeName__' |
4ede355c6089
bugfix for renaming of users (/MoinMoinBugs/RenamingUserAllowsOldUsernameToLogin) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
2827
diff
changeset
|
255 theUser.save() |
4ede355c6089
bugfix for renaming of users (/MoinMoinBugs/RenamingUserAllowsOldUsernameToLogin) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
2827
diff
changeset
|
256 theUser = user.User(self.request, name=name, password=password) |
3120
a7c1680aeaa0
PEP8 fixes, mostly whitespace
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
3103
diff
changeset
|
257 |
3103
4ede355c6089
bugfix for renaming of users (/MoinMoinBugs/RenamingUserAllowsOldUsernameToLogin) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
2827
diff
changeset
|
258 assert not theUser.exists() |
2165
eed1c7da25eb
test_user: fix wrong subscription tests and a few other problems
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2140
diff
changeset
|
259 |
4656
052b6926c82d
test_user: added two tests for the difference of retrieving an user object by uid or name
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
4027
diff
changeset
|
260 def test_for_email_attribute_by_name(self): |
052b6926c82d
test_user: added two tests for the difference of retrieving an user object by uid or name
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
4027
diff
changeset
|
261 """ |
052b6926c82d
test_user: added two tests for the difference of retrieving an user object by uid or name
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
4027
diff
changeset
|
262 checks for no access to the email attribute by getting the user object from name |
052b6926c82d
test_user: added two tests for the difference of retrieving an user object by uid or name
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
4027
diff
changeset
|
263 """ |
052b6926c82d
test_user: added two tests for the difference of retrieving an user object by uid or name
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
4027
diff
changeset
|
264 name = u"__TestUser__" |
052b6926c82d
test_user: added two tests for the difference of retrieving an user object by uid or name
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
4027
diff
changeset
|
265 password = u"ekfdweurwerh" |
052b6926c82d
test_user: added two tests for the difference of retrieving an user object by uid or name
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
4027
diff
changeset
|
266 email = "__TestUser__@moinhost" |
4657
1da5c7d21660
test_user: fixed the wrong encoding of the password
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
4656
diff
changeset
|
267 self.createUser(name, password, email=email) |
4656
052b6926c82d
test_user: added two tests for the difference of retrieving an user object by uid or name
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
4027
diff
changeset
|
268 theuser = user.User(self.request, name=name) |
052b6926c82d
test_user: added two tests for the difference of retrieving an user object by uid or name
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
4027
diff
changeset
|
269 assert theuser.email == "" |
052b6926c82d
test_user: added two tests for the difference of retrieving an user object by uid or name
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
4027
diff
changeset
|
270 |
052b6926c82d
test_user: added two tests for the difference of retrieving an user object by uid or name
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
4027
diff
changeset
|
271 def test_for_email_attribut_by_uid(self): |
052b6926c82d
test_user: added two tests for the difference of retrieving an user object by uid or name
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
4027
diff
changeset
|
272 """ |
052b6926c82d
test_user: added two tests for the difference of retrieving an user object by uid or name
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
4027
diff
changeset
|
273 checks access to the email attribute by getting the user object from the uid |
052b6926c82d
test_user: added two tests for the difference of retrieving an user object by uid or name
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
4027
diff
changeset
|
274 """ |
052b6926c82d
test_user: added two tests for the difference of retrieving an user object by uid or name
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
4027
diff
changeset
|
275 name = u"__TestUser2__" |
052b6926c82d
test_user: added two tests for the difference of retrieving an user object by uid or name
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
4027
diff
changeset
|
276 password = u"ekERErwerwerh" |
052b6926c82d
test_user: added two tests for the difference of retrieving an user object by uid or name
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
4027
diff
changeset
|
277 email = "__TestUser2__@moinhost" |
4657
1da5c7d21660
test_user: fixed the wrong encoding of the password
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
4656
diff
changeset
|
278 self.createUser(name, password, email=email) |
4656
052b6926c82d
test_user: added two tests for the difference of retrieving an user object by uid or name
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
4027
diff
changeset
|
279 uid = user.getUserId(self.request, name) |
052b6926c82d
test_user: added two tests for the difference of retrieving an user object by uid or name
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
4027
diff
changeset
|
280 theuser = user.User(self.request, uid) |
052b6926c82d
test_user: added two tests for the difference of retrieving an user object by uid or name
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
4027
diff
changeset
|
281 assert theuser.email == email |
052b6926c82d
test_user: added two tests for the difference of retrieving an user object by uid or name
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
4027
diff
changeset
|
282 |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
283 # Helpers --------------------------------------------------------- |
892
9931a09387b0
some whitespace cleanup in the tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
682
diff
changeset
|
284 |
4656
052b6926c82d
test_user: added two tests for the difference of retrieving an user object by uid or name
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
4027
diff
changeset
|
285 def createUser(self, name, password, pwencoded=False, email=None): |
2286
01f05e74aa9c
Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2165
diff
changeset
|
286 """ helper to create test user |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
287 """ |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
288 # Create user |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
289 self.user = user.User(self.request) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
290 self.user.name = name |
4656
052b6926c82d
test_user: added two tests for the difference of retrieving an user object by uid or name
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
4027
diff
changeset
|
291 self.user.email = email |
3818
fe9305d5c7cf
user: adjust tests, add one for password upgrade and fix a bug found
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
3120
diff
changeset
|
292 if not pwencoded: |
5922
25900eaeb864
passlib integration - enhanced password hash security
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
5918
diff
changeset
|
293 password = user.encodePassword(self.request.cfg, password) |
3818
fe9305d5c7cf
user: adjust tests, add one for password upgrade and fix a bug found
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
3120
diff
changeset
|
294 self.user.enc_password = password |
892
9931a09387b0
some whitespace cleanup in the tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
682
diff
changeset
|
295 |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
296 # Validate that we are not modifying existing user data file! |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
297 if self.user.exists(): |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
298 self.user = None |
2006
1339d6fdc4ff
Changed tests to use py.test. Also changed the semantics a bit - the test wiki directory is only created freshly if it does not exist.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
1918
diff
changeset
|
299 py.test.skip("Test user exists, will not override existing user data file!") |
892
9931a09387b0
some whitespace cleanup in the tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
682
diff
changeset
|
300 |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
301 # Save test user |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
302 self.user.save() |
892
9931a09387b0
some whitespace cleanup in the tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
682
diff
changeset
|
303 |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
304 # Validate user creation |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
305 if not self.user.exists(): |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
306 self.user = None |
2006
1339d6fdc4ff
Changed tests to use py.test. Also changed the semantics a bit - the test wiki directory is only created freshly if it does not exist.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
1918
diff
changeset
|
307 py.test.skip("Can't create test user") |
892
9931a09387b0
some whitespace cleanup in the tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
682
diff
changeset
|
308 |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
309 |
2818
7fceb3588211
tests: convert user tests to py.test, fix tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2448
diff
changeset
|
310 class TestGroupName(object): |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
311 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
312 def testGroupNames(self): |
892
9931a09387b0
some whitespace cleanup in the tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
682
diff
changeset
|
313 """ user: isValidName: reject group names """ |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
314 test = u'AdminGroup' |
2818
7fceb3588211
tests: convert user tests to py.test, fix tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2448
diff
changeset
|
315 assert not user.isValidName(self.request, test) |
892
9931a09387b0
some whitespace cleanup in the tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
682
diff
changeset
|
316 |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
317 |
2818
7fceb3588211
tests: convert user tests to py.test, fix tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2448
diff
changeset
|
318 class TestIsValidName(object): |
892
9931a09387b0
some whitespace cleanup in the tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
682
diff
changeset
|
319 |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
320 def testNonAlnumCharacters(self): |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
321 """ user: isValidName: reject unicode non alpha numeric characters |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
322 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
323 : and , used in acl rules, we might add more characters to the syntax. |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
324 """ |
2818
7fceb3588211
tests: convert user tests to py.test, fix tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2448
diff
changeset
|
325 invalid = u'! # $ % ^ & * ( ) = + , : ; " | ~ / \\ \u0000 \u202a'.split() |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
326 base = u'User%sName' |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
327 for c in invalid: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
328 name = base % c |
2818
7fceb3588211
tests: convert user tests to py.test, fix tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2448
diff
changeset
|
329 assert not user.isValidName(self.request, name) |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
330 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
331 def testWhitespace(self): |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
332 """ user: isValidName: reject leading, trailing or multiple whitespace """ |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
333 cases = ( |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
334 u' User Name', |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
335 u'User Name ', |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
336 u'User Name', |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
337 ) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
338 for test in cases: |
2818
7fceb3588211
tests: convert user tests to py.test, fix tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2448
diff
changeset
|
339 assert not user.isValidName(self.request, test) |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
340 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
341 def testValid(self): |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
342 """ user: isValidName: accept names in any language, with spaces """ |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
343 cases = ( |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
344 u'Jürgen Hermann', # German |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
345 u'ניר סופר', # Hebrew |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
346 u'CamelCase', # Good old camel case |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
347 u'가각간갇갈 갉갊감 갬갯걀갼' # Hangul (gibberish) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
348 ) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
349 for test in cases: |
2818
7fceb3588211
tests: convert user tests to py.test, fix tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2448
diff
changeset
|
350 assert user.isValidName(self.request, test) |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
351 |
2448
c9949c55ff5e
add coverage_modules attribute for coverage testing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2286
diff
changeset
|
352 |
c9949c55ff5e
add coverage_modules attribute for coverage testing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2286
diff
changeset
|
353 coverage_modules = ['MoinMoin.user'] |
c9949c55ff5e
add coverage_modules attribute for coverage testing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2286
diff
changeset
|
354 |