annotate MoinMoin/config/_tests/test_multiconfig.py @ 3323:fb625b97ca02

remove crack password checker test now that password checker was removed...
author Johannes Berg <johannes AT sipsolutions DOT net>
date Wed, 19 Mar 2008 03:50:30 +0100
parents 5e7b45489430
children 6049339db18f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2442
bd145a2629aa add tests for password_checker
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
bd145a2629aa add tests for password_checker
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
2 """
bd145a2629aa add tests for password_checker
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
3 MoinMoin - MoinMoin.config.multiconfig Tests
bd145a2629aa add tests for password_checker
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
4
bd145a2629aa add tests for password_checker
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
5 @copyright: 2007 by MoinMoin:ThomasWaldmann
bd145a2629aa add tests for password_checker
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
6 @license: GNU GPL, see COPYING for details.
bd145a2629aa add tests for password_checker
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
7 """
bd145a2629aa add tests for password_checker
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
8
bd145a2629aa add tests for password_checker
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
9 import py
2595
5e7b45489430 moved python2.3/2.4 compatibility code to MoinMoin.support.python_compatibility (thanks to Heinrich Wendel)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2448
diff changeset
10 from MoinMoin.support.python_compatibility import set
2442
bd145a2629aa add tests for password_checker
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
11
bd145a2629aa add tests for password_checker
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
12
bd145a2629aa add tests for password_checker
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
13 class TestPasswordChecker:
bd145a2629aa add tests for password_checker
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
14 username = u"SomeUser"
bd145a2629aa add tests for password_checker
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
15 tests_builtin = [
2443
b4c44e5be9e8 password_checker: more builtin checks, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2442
diff changeset
16 (u'', False), # empty
b4c44e5be9e8 password_checker: more builtin checks, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2442
diff changeset
17 (u'1966', False), # too short
b4c44e5be9e8 password_checker: more builtin checks, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2442
diff changeset
18 (u'asdfghjk', False), # keyboard sequence
b4c44e5be9e8 password_checker: more builtin checks, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2442
diff changeset
19 (u'QwertZuiop', False), # german keyboard sequence, with uppercase
b4c44e5be9e8 password_checker: more builtin checks, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2442
diff changeset
20 (u'mnbvcx', False), # reverse keyboard sequence
b4c44e5be9e8 password_checker: more builtin checks, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2442
diff changeset
21 (u'12345678', False), # keyboard sequence, too easy
b4c44e5be9e8 password_checker: more builtin checks, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2442
diff changeset
22 (u'aaaaaaaa', False), # not enough different chars
b4c44e5be9e8 password_checker: more builtin checks, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2442
diff changeset
23 (u'BBBaaaddd', False), # not enough different chars
b4c44e5be9e8 password_checker: more builtin checks, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2442
diff changeset
24 (username, False), # username == password
b4c44e5be9e8 password_checker: more builtin checks, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2442
diff changeset
25 (username[1:-1], False), # password in username
b4c44e5be9e8 password_checker: more builtin checks, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2442
diff changeset
26 (u"XXX%sXXX" % username, False), # username in password
b4c44e5be9e8 password_checker: more builtin checks, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2442
diff changeset
27 (u'Moin-2007', True), # this should be OK
2442
bd145a2629aa add tests for password_checker
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
28 ]
bd145a2629aa add tests for password_checker
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
29 tests_crack = tests_builtin + [
2443
b4c44e5be9e8 password_checker: more builtin checks, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2442
diff changeset
30 (u'secret', False), # word from dictionary
b4c44e5be9e8 password_checker: more builtin checks, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2442
diff changeset
31 (u'password', False), # word from dictionary
2442
bd145a2629aa add tests for password_checker
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
32 ]
bd145a2629aa add tests for password_checker
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
33 def testBuiltinPasswordChecker(self):
bd145a2629aa add tests for password_checker
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
34 pw_checker = self.request.cfg.password_checker
bd145a2629aa add tests for password_checker
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
35 if not pw_checker:
bd145a2629aa add tests for password_checker
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
36 py.test.skip("password_checker is disabled in the configuration, not testing it")
bd145a2629aa add tests for password_checker
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
37 else:
bd145a2629aa add tests for password_checker
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
38 for pw, result in self.tests_builtin:
bd145a2629aa add tests for password_checker
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
39 pw_error = pw_checker(self.username, pw)
bd145a2629aa add tests for password_checker
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
40 print "%r: %s" % (pw, pw_error)
bd145a2629aa add tests for password_checker
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
41 assert result == (pw_error is None)
bd145a2629aa add tests for password_checker
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
42
2448
c9949c55ff5e add coverage_modules attribute for coverage testing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2444
diff changeset
43 coverage_modules = ['MoinMoin.config.multiconfig']
2442
bd145a2629aa add tests for password_checker
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
44