annotate MoinMoin/auth/_tests/test_ldap_login.py @ 4027:0d6724b87856

Refactored TestConfig creation for py.test based unit tests. The method used before had multiple problems: config creation did not use inheritance (as it does when used the wiki in production). It also didn't do the post processing done in __init__ of Config class. Also, it first created the request with some default config, then created the TestConfig (but some stuff in request was not initialized correctly)... The new method now uses config inheritance in the same way as a production wiki does. The TestConfig instance is created in RequestBase __init__, it does not use sys.path any more to import the test wikiconfig, but does an absolute import from MoinMoin._tests.wikiconfig. TODO: * fix the failing test_pysupport.TestImportExisting.testExisting * auth tests are currently skipped because they need more work * find a better way than staticmethod(TestConfig)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 24 Aug 2008 02:01:34 +0200
parents 2d5a325ae247
children 3d5c4ebe8f34
rev   line source
3650
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
2 """
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
3 MoinMoin - MoinMoin.auth.ldap Tests
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
4
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
5 @copyright: 2008 MoinMoin:ThomasWaldmann
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
6 @license: GNU GPL, see COPYING for details.
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
7 """
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
8
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
9 import py.test
4027
0d6724b87856 Refactored TestConfig creation for py.test based unit tests.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3661
diff changeset
10 py.test.skip("Broken due to TestConfig refactoring")
3650
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
11
3661
2d5a325ae247 ldap tests: rename base class so py.test doesn't find it, skip tests if slapd is not started
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3660
diff changeset
12 from MoinMoin._tests.ldap_testbase import LDAPTstBase, LdapEnvironment, check_environ, SLAPD_EXECUTABLE
3650
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
13 from MoinMoin._tests.ldap_testdata import *
4027
0d6724b87856 Refactored TestConfig creation for py.test based unit tests.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3661
diff changeset
14 from MoinMoin._tests import nuke_user, wikiconfig
3650
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
15
3651
df024fd0a129 LDAP tests: add checks for the environment needed to run the tests. skip test with reason if environment is unsuitable.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3650
diff changeset
16 # first check if we have python 2.4, python-ldap and slapd:
df024fd0a129 LDAP tests: add checks for the environment needed to run the tests. skip test with reason if environment is unsuitable.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3650
diff changeset
17 msg = check_environ()
df024fd0a129 LDAP tests: add checks for the environment needed to run the tests. skip test with reason if environment is unsuitable.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3650
diff changeset
18 if msg:
df024fd0a129 LDAP tests: add checks for the environment needed to run the tests. skip test with reason if environment is unsuitable.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3650
diff changeset
19 py.test.skip(msg)
df024fd0a129 LDAP tests: add checks for the environment needed to run the tests. skip test with reason if environment is unsuitable.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3650
diff changeset
20 del msg
df024fd0a129 LDAP tests: add checks for the environment needed to run the tests. skip test with reason if environment is unsuitable.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3650
diff changeset
21
df024fd0a129 LDAP tests: add checks for the environment needed to run the tests. skip test with reason if environment is unsuitable.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3650
diff changeset
22 import ldap
df024fd0a129 LDAP tests: add checks for the environment needed to run the tests. skip test with reason if environment is unsuitable.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3650
diff changeset
23
4027
0d6724b87856 Refactored TestConfig creation for py.test based unit tests.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3661
diff changeset
24 class TestLDAPServer(LDAPTstBase):
3650
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
25 basedn = BASEDN
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
26 rootdn = ROOTDN
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
27 rootpw = ROOTPW
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
28 slapd_config = SLAPD_CONFIG
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
29 ldif_content = LDIF_CONTENT
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
30
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
31 def testLDAP(self):
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
32 """ Just try accessing the LDAP server and see if usera and userb are in LDAP. """
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
33 server_uri = self.ldap_env.slapd.url
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
34 base_dn = self.ldap_env.basedn
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
35 lo = ldap.initialize(server_uri)
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
36 ldap.set_option(ldap.OPT_PROTOCOL_VERSION, ldap.VERSION3) # ldap v2 is outdated
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
37 lo.simple_bind_s('', '')
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
38 lusers = lo.search_st(base_dn, ldap.SCOPE_SUBTREE, '(uid=*)')
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
39 uids = [ldap_dict['uid'][0] for dn, ldap_dict in lusers]
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
40 assert 'usera' in uids
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
41 assert 'userb' in uids
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
42
4027
0d6724b87856 Refactored TestConfig creation for py.test based unit tests.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3661
diff changeset
43 class TestMoinLDAPLogin(LDAPTstBase):
0d6724b87856 Refactored TestConfig creation for py.test based unit tests.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3661
diff changeset
44 basedn = BASEDN
0d6724b87856 Refactored TestConfig creation for py.test based unit tests.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3661
diff changeset
45 rootdn = ROOTDN
0d6724b87856 Refactored TestConfig creation for py.test based unit tests.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3661
diff changeset
46 rootpw = ROOTPW
0d6724b87856 Refactored TestConfig creation for py.test based unit tests.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3661
diff changeset
47 slapd_config = SLAPD_CONFIG
0d6724b87856 Refactored TestConfig creation for py.test based unit tests.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3661
diff changeset
48 ldif_content = LDIF_CONTENT
0d6724b87856 Refactored TestConfig creation for py.test based unit tests.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3661
diff changeset
49
0d6724b87856 Refactored TestConfig creation for py.test based unit tests.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3661
diff changeset
50 class TestConfig(wikiconfig.Config):
0d6724b87856 Refactored TestConfig creation for py.test based unit tests.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3661
diff changeset
51 from MoinMoin.auth.ldap_login import LDAPAuth
0d6724b87856 Refactored TestConfig creation for py.test based unit tests.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3661
diff changeset
52 server_uri = self.ldap_env.slapd.url # XXX no self
0d6724b87856 Refactored TestConfig creation for py.test based unit tests.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3661
diff changeset
53 base_dn = self.ldap_env.basedn
0d6724b87856 Refactored TestConfig creation for py.test based unit tests.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3661
diff changeset
54 ldap_auth1 = LDAPAuth(server_uri=server_uri, base_dn=base_dn)
0d6724b87856 Refactored TestConfig creation for py.test based unit tests.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3661
diff changeset
55 auth = [ldap_auth1, ]
0d6724b87856 Refactored TestConfig creation for py.test based unit tests.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3661
diff changeset
56 user_autocreate = True
0d6724b87856 Refactored TestConfig creation for py.test based unit tests.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3661
diff changeset
57
3650
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
58 def testMoinLDAPLogin(self):
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
59 """ Just try accessing the LDAP server and see if usera and userb are in LDAP. """
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
60
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
61 handle_auth = self.request.handle_auth
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
62
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
63 # tests that must not authenticate:
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
64 u = handle_auth(None, username='', password='', login=True)
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
65 assert u is None
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
66 u = handle_auth(None, username='usera', password='', login=True)
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
67 assert u is None
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
68 u = handle_auth(None, username='usera', password='userawrong', login=True)
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
69 assert u is None
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
70 u = handle_auth(None, username='userawrong', password='usera', login=True)
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
71 assert u is None
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
72
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
73 # tests that must authenticate:
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
74 u1 = handle_auth(None, username='usera', password='usera', login=True)
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
75 assert u1 is not None
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
76 assert u1.valid
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
77
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
78 u2 = handle_auth(None, username='userb', password='userb', login=True)
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
79 assert u2 is not None
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
80 assert u2.valid
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
81
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
82 # check if usera and userb have different ids:
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
83 assert u1.id != u2.id
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
84
3660
b3354cf420ff ldap auth tests: fix failures due to order of test execution
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3657
diff changeset
85
3661
2d5a325ae247 ldap tests: rename base class so py.test doesn't find it, skip tests if slapd is not started
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3660
diff changeset
86 class TestBugDefaultPasswd(LDAPTstBase):
3657
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
87 basedn = BASEDN
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
88 rootdn = ROOTDN
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
89 rootpw = ROOTPW
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
90 slapd_config = SLAPD_CONFIG
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
91 ldif_content = LDIF_CONTENT
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
92
4027
0d6724b87856 Refactored TestConfig creation for py.test based unit tests.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3661
diff changeset
93 class TestConfig(wikiconfig.Config):
0d6724b87856 Refactored TestConfig creation for py.test based unit tests.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3661
diff changeset
94 from MoinMoin.auth.ldap_login import LDAPAuth
0d6724b87856 Refactored TestConfig creation for py.test based unit tests.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3661
diff changeset
95 from MoinMoin.auth import MoinAuth
0d6724b87856 Refactored TestConfig creation for py.test based unit tests.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3661
diff changeset
96 server_uri = self.ldap_env.slapd.url # XXX no self
0d6724b87856 Refactored TestConfig creation for py.test based unit tests.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3661
diff changeset
97 base_dn = self.ldap_env.basedn
0d6724b87856 Refactored TestConfig creation for py.test based unit tests.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3661
diff changeset
98 ldap_auth = LDAPAuth(server_uri=server_uri, base_dn=base_dn)
0d6724b87856 Refactored TestConfig creation for py.test based unit tests.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3661
diff changeset
99 moin_auth = MoinAuth()
0d6724b87856 Refactored TestConfig creation for py.test based unit tests.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3661
diff changeset
100 auth = [ldap_auth, moin_auth]
0d6724b87856 Refactored TestConfig creation for py.test based unit tests.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3661
diff changeset
101 user_autocreate = True
0d6724b87856 Refactored TestConfig creation for py.test based unit tests.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3661
diff changeset
102
3657
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
103 def teardown_class(self):
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
104 """ Stop slapd, remove LDAP server environment """
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
105 #self.ldap_env.stop_slapd() # it is already stopped
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
106 self.ldap_env.destroy_env()
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
107
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
108 def testBugDefaultPasswd(self):
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
109 """ Login via LDAP (this creates user profile and up to 1.7.0rc1 it put
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
110 a default password there), then try logging in via moin login using
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
111 that default password or an empty password.
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
112 """
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
113
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
114 nuke_user(self.request, u'usera')
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
115
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
116 handle_auth = self.request.handle_auth
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
117
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
118 # do a LDAPAuth login (as a side effect, this autocreates the user profile):
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
119 u1 = handle_auth(None, username='usera', password='usera', login=True)
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
120 assert u1 is not None
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
121 assert u1.valid
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
122
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
123 # now we kill the LDAP server:
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
124 self.ldap_env.slapd.stop()
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
125
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
126 # now try a MoinAuth login:
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
127 # try the default password that worked in 1.7 up to rc1:
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
128 u2 = handle_auth(None, username='usera', password='{SHA}NotStored', login=True)
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
129 assert u2 is None
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
130
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
131 # try using no password:
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
132 u2 = handle_auth(None, username='usera', password='', login=True)
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
133 assert u2 is None
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
134
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
135 # try using wrong password:
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
136 u2 = handle_auth(None, username='usera', password='wrong', login=True)
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
137 assert u2 is None
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
138
2ef181f42a41 fix MoinMoinBugs/DummyPasswordInAutoCreatedLdapUserProfiles and add a test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3654
diff changeset
139
3660
b3354cf420ff ldap auth tests: fix failures due to order of test execution
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3657
diff changeset
140 class TestTwoLdapServers:
b3354cf420ff ldap auth tests: fix failures due to order of test execution
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3657
diff changeset
141 basedn = BASEDN
b3354cf420ff ldap auth tests: fix failures due to order of test execution
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3657
diff changeset
142 rootdn = ROOTDN
b3354cf420ff ldap auth tests: fix failures due to order of test execution
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3657
diff changeset
143 rootpw = ROOTPW
b3354cf420ff ldap auth tests: fix failures due to order of test execution
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3657
diff changeset
144 slapd_config = SLAPD_CONFIG
b3354cf420ff ldap auth tests: fix failures due to order of test execution
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3657
diff changeset
145 ldif_content = LDIF_CONTENT
b3354cf420ff ldap auth tests: fix failures due to order of test execution
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3657
diff changeset
146
b3354cf420ff ldap auth tests: fix failures due to order of test execution
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3657
diff changeset
147 def setup_class(self):
b3354cf420ff ldap auth tests: fix failures due to order of test execution
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3657
diff changeset
148 """ Create LDAP servers environment, start slapds """
b3354cf420ff ldap auth tests: fix failures due to order of test execution
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3657
diff changeset
149 self.ldap_envs = []
b3354cf420ff ldap auth tests: fix failures due to order of test execution
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3657
diff changeset
150 for instance in range(2):
b3354cf420ff ldap auth tests: fix failures due to order of test execution
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3657
diff changeset
151 ldap_env = LdapEnvironment(self.basedn, self.rootdn, self.rootpw, instance=instance)
b3354cf420ff ldap auth tests: fix failures due to order of test execution
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3657
diff changeset
152 ldap_env.create_env(slapd_config=self.slapd_config)
3661
2d5a325ae247 ldap tests: rename base class so py.test doesn't find it, skip tests if slapd is not started
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3660
diff changeset
153 started = ldap_env.start_slapd()
2d5a325ae247 ldap tests: rename base class so py.test doesn't find it, skip tests if slapd is not started
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3660
diff changeset
154 if not started:
2d5a325ae247 ldap tests: rename base class so py.test doesn't find it, skip tests if slapd is not started
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3660
diff changeset
155 py.test.skip("Failed to start %s process, please see your syslog / log files"
2d5a325ae247 ldap tests: rename base class so py.test doesn't find it, skip tests if slapd is not started
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3660
diff changeset
156 " (and check if stopping apparmor helps, in case you use it)." % SLAPD_EXECUTABLE)
3660
b3354cf420ff ldap auth tests: fix failures due to order of test execution
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3657
diff changeset
157 ldap_env.load_directory(ldif_content=self.ldif_content)
b3354cf420ff ldap auth tests: fix failures due to order of test execution
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3657
diff changeset
158 self.ldap_envs.append(ldap_env)
b3354cf420ff ldap auth tests: fix failures due to order of test execution
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3657
diff changeset
159
b3354cf420ff ldap auth tests: fix failures due to order of test execution
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3657
diff changeset
160 def teardown_class(self):
b3354cf420ff ldap auth tests: fix failures due to order of test execution
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3657
diff changeset
161 """ Stop slapd, remove LDAP server environment """
b3354cf420ff ldap auth tests: fix failures due to order of test execution
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3657
diff changeset
162 for ldap_env in self.ldap_envs:
b3354cf420ff ldap auth tests: fix failures due to order of test execution
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3657
diff changeset
163 ldap_env.stop_slapd()
b3354cf420ff ldap auth tests: fix failures due to order of test execution
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3657
diff changeset
164 ldap_env.destroy_env()
b3354cf420ff ldap auth tests: fix failures due to order of test execution
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3657
diff changeset
165
b3354cf420ff ldap auth tests: fix failures due to order of test execution
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3657
diff changeset
166 def testLDAP(self):
b3354cf420ff ldap auth tests: fix failures due to order of test execution
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3657
diff changeset
167 """ Just try accessing the LDAP servers and see if usera and userb are in LDAP. """
b3354cf420ff ldap auth tests: fix failures due to order of test execution
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3657
diff changeset
168 for ldap_env in self.ldap_envs:
b3354cf420ff ldap auth tests: fix failures due to order of test execution
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3657
diff changeset
169 server_uri = ldap_env.slapd.url
b3354cf420ff ldap auth tests: fix failures due to order of test execution
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3657
diff changeset
170 base_dn = ldap_env.basedn
b3354cf420ff ldap auth tests: fix failures due to order of test execution
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3657
diff changeset
171 lo = ldap.initialize(server_uri)
b3354cf420ff ldap auth tests: fix failures due to order of test execution
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3657
diff changeset
172 ldap.set_option(ldap.OPT_PROTOCOL_VERSION, ldap.VERSION3) # ldap v2 is outdated
b3354cf420ff ldap auth tests: fix failures due to order of test execution
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3657
diff changeset
173 lo.simple_bind_s('', '')
b3354cf420ff ldap auth tests: fix failures due to order of test execution
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3657
diff changeset
174 lusers = lo.search_st(base_dn, ldap.SCOPE_SUBTREE, '(uid=*)')
b3354cf420ff ldap auth tests: fix failures due to order of test execution
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3657
diff changeset
175 uids = [ldap_dict['uid'][0] for dn, ldap_dict in lusers]
b3354cf420ff ldap auth tests: fix failures due to order of test execution
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3657
diff changeset
176 assert 'usera' in uids
b3354cf420ff ldap auth tests: fix failures due to order of test execution
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3657
diff changeset
177 assert 'userb' in uids
b3354cf420ff ldap auth tests: fix failures due to order of test execution
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3657
diff changeset
178
b3354cf420ff ldap auth tests: fix failures due to order of test execution
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3657
diff changeset
179
b3354cf420ff ldap auth tests: fix failures due to order of test execution
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3657
diff changeset
180 class TestLdapFailover:
3650
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
181 basedn = BASEDN
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
182 rootdn = ROOTDN
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
183 rootpw = ROOTPW
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
184 slapd_config = SLAPD_CONFIG
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
185 ldif_content = LDIF_CONTENT
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
186
4027
0d6724b87856 Refactored TestConfig creation for py.test based unit tests.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3661
diff changeset
187 class TestConfig(wikiconfig.Config):
0d6724b87856 Refactored TestConfig creation for py.test based unit tests.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3661
diff changeset
188 from MoinMoin.auth.ldap_login import LDAPAuth
0d6724b87856 Refactored TestConfig creation for py.test based unit tests.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3661
diff changeset
189 authlist = []
0d6724b87856 Refactored TestConfig creation for py.test based unit tests.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3661
diff changeset
190 for ldap_env in self.ldap_envs: # XXX no self
0d6724b87856 Refactored TestConfig creation for py.test based unit tests.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3661
diff changeset
191 server_uri = ldap_env.slapd.url
0d6724b87856 Refactored TestConfig creation for py.test based unit tests.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3661
diff changeset
192 base_dn = ldap_env.basedn
0d6724b87856 Refactored TestConfig creation for py.test based unit tests.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3661
diff changeset
193 ldap_auth = LDAPAuth(server_uri=server_uri, base_dn=base_dn,
0d6724b87856 Refactored TestConfig creation for py.test based unit tests.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3661
diff changeset
194 timeout=1) # short timeout, faster testing
0d6724b87856 Refactored TestConfig creation for py.test based unit tests.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3661
diff changeset
195 authlist.append(ldap_auth)
0d6724b87856 Refactored TestConfig creation for py.test based unit tests.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3661
diff changeset
196 auth = authlist
0d6724b87856 Refactored TestConfig creation for py.test based unit tests.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3661
diff changeset
197 user_autocreate = True
0d6724b87856 Refactored TestConfig creation for py.test based unit tests.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3661
diff changeset
198
3650
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
199 def setup_class(self):
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
200 """ Create LDAP servers environment, start slapds """
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
201 self.ldap_envs = []
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
202 for instance in range(2):
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
203 ldap_env = LdapEnvironment(self.basedn, self.rootdn, self.rootpw, instance=instance)
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
204 ldap_env.create_env(slapd_config=self.slapd_config)
3661
2d5a325ae247 ldap tests: rename base class so py.test doesn't find it, skip tests if slapd is not started
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3660
diff changeset
205 started = ldap_env.start_slapd()
2d5a325ae247 ldap tests: rename base class so py.test doesn't find it, skip tests if slapd is not started
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3660
diff changeset
206 if not started:
2d5a325ae247 ldap tests: rename base class so py.test doesn't find it, skip tests if slapd is not started
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3660
diff changeset
207 py.test.skip("Failed to start %s process, please see your syslog / log files"
2d5a325ae247 ldap tests: rename base class so py.test doesn't find it, skip tests if slapd is not started
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3660
diff changeset
208 " (and check if stopping apparmor helps, in case you use it)." % SLAPD_EXECUTABLE)
3650
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
209 ldap_env.load_directory(ldif_content=self.ldif_content)
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
210 self.ldap_envs.append(ldap_env)
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
211
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
212 def teardown_class(self):
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
213 """ Stop slapd, remove LDAP server environment """
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
214 for ldap_env in self.ldap_envs:
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
215 try:
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
216 ldap_env.stop_slapd()
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
217 except:
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
218 pass # one will fail, because it is already stopped
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
219 ldap_env.destroy_env()
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
220
3660
b3354cf420ff ldap auth tests: fix failures due to order of test execution
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3657
diff changeset
221 def testMoinLDAPFailOver(self):
b3354cf420ff ldap auth tests: fix failures due to order of test execution
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3657
diff changeset
222 """ Try if it does a failover to a secondary LDAP, if the primary fails. """
3650
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
223 handle_auth = self.request.handle_auth
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
224
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
225 # authenticate user (with primary slapd):
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
226 u1 = handle_auth(None, username='usera', password='usera', login=True)
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
227 assert u1 is not None
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
228 assert u1.valid
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
229
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
230 # now we kill our primary LDAP server:
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
231 self.ldap_envs[0].slapd.stop()
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
232
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
233 # try if we can still authenticate (with the second slapd):
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
234 u2 = handle_auth(None, username='usera', password='usera', login=True)
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
235 assert u2 is not None
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
236 assert u2.valid
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
237
23851c20e53f add ldap testing framework, add ldap_login tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
238
3660
b3354cf420ff ldap auth tests: fix failures due to order of test execution
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3657
diff changeset
239