Mercurial > moin > 1.9
changeset 5673:07595b99ffb8
auth._tests.test_ldap_login: refactored test to current environment
author | Reimar Bauer <rb.proj AT googlemail DOT com> |
---|---|
date | Sun, 30 May 2010 23:00:57 +0200 |
parents | 203afc609f8a |
children | 68ba3cc79513 |
files | MoinMoin/auth/_tests/test_ldap_login.py |
diffstat | 1 files changed, 28 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/MoinMoin/auth/_tests/test_ldap_login.py Mon May 24 10:43:08 2010 +0200 +++ b/MoinMoin/auth/_tests/test_ldap_login.py Sun May 30 23:00:57 2010 +0200 @@ -2,12 +2,14 @@ """ MoinMoin - MoinMoin.auth.ldap Tests - @copyright: 2008 MoinMoin:ThomasWaldmann + @copyright: 2008 MoinMoin:ThomasWaldmann, + 2010 MoinMoin:ReimarBauer + @license: GNU GPL, see COPYING for details. """ import py.test -py.test.skip("Broken due to test Config refactoring") + from MoinMoin._tests.ldap_testbase import LDAPTstBase, LdapEnvironment, check_environ, SLAPD_EXECUTABLE from MoinMoin._tests.ldap_testdata import * @@ -50,16 +52,16 @@ class Config(wikiconfig.Config): from MoinMoin.auth.ldap_login import LDAPAuth - server_uri = self.ldap_env.slapd.url # XXX no self - base_dn = self.ldap_env.basedn + #ToDo get these vars from the test environment + server_uri = 'ldap://127.0.0.1:3890' + base_dn = 'ou=testing,dc=example,dc=org' + ldap_auth1 = LDAPAuth(server_uri=server_uri, base_dn=base_dn, autocreate=True) auth = [ldap_auth1, ] def testMoinLDAPLogin(self): """ Just try accessing the LDAP server and see if usera and userb are in LDAP. """ - handle_auth = self.request.handle_auth - # tests that must not authenticate: u = handle_login(self.request, None, username='', password='') assert u is None @@ -93,15 +95,16 @@ class Config(wikiconfig.Config): from MoinMoin.auth.ldap_login import LDAPAuth from MoinMoin.auth import MoinAuth - server_uri = self.ldap_env.slapd.url # XXX no self - base_dn = self.ldap_env.basedn + #ToDo get these vars from the test environment + server_uri = 'ldap://127.0.0.1:3890' + base_dn = 'ou=testing,dc=example,dc=org' ldap_auth = LDAPAuth(server_uri=server_uri, base_dn=base_dn, autocreate=True) moin_auth = MoinAuth() auth = [ldap_auth, moin_auth] def teardown_class(self): """ Stop slapd, remove LDAP server environment """ - #self.ldap_env.stop_slapd() # it is already stopped + self.ldap_env.stop_slapd() self.ldap_env.destroy_env() def testBugDefaultPasswd(self): @@ -133,7 +136,6 @@ u2 = handle_login(self.request, None, username='usera', password='wrong') assert u2 is None - class TestTwoLdapServers: basedn = BASEDN rootdn = ROOTDN @@ -181,17 +183,6 @@ slapd_config = SLAPD_CONFIG ldif_content = LDIF_CONTENT - class Config(wikiconfig.Config): - from MoinMoin.auth.ldap_login import LDAPAuth - authlist = [] - for ldap_env in self.ldap_envs: # XXX no self - server_uri = ldap_env.slapd.url - base_dn = ldap_env.basedn - ldap_auth = LDAPAuth(server_uri=server_uri, base_dn=base_dn, - autocreate=True, - timeout=1) # short timeout, faster testing - authlist.append(ldap_auth) - auth = authlist def setup_class(self): """ Create LDAP servers environment, start slapds """ @@ -206,6 +197,22 @@ ldap_env.load_directory(ldif_content=self.ldif_content) self.ldap_envs.append(ldap_env) + class Config(wikiconfig.Config): + from MoinMoin.auth.ldap_login import LDAPAuth + #ToDo get these vars from the test environment + server_uri = 'ldap://127.0.0.1:3891' + base_dn = 'ou=testing,dc=example,dc=org' + ldap_auth1 = LDAPAuth(server_uri=server_uri, base_dn=base_dn, + name="ldap1", autocreate=True, + timeout=1) + # short timeout, faster testing + server_uri = 'ldap://127.0.0.1:3892' + ldap_auth2 = LDAPAuth(server_uri=server_uri, base_dn=base_dn, + name="ldap2", autocreate=True, + timeout=1) + + auth = [ldap_auth1, ldap_auth2] + def teardown_class(self): """ Stop slapd, remove LDAP server environment """ for ldap_env in self.ldap_envs: @@ -217,7 +224,6 @@ def testMoinLDAPFailOver(self): """ Try if it does a failover to a secondary LDAP, if the primary fails. """ - handle_auth = self.request.handle_auth # authenticate user (with primary slapd): u1 = handle_login(self.request, None, username='usera', password='usera') @@ -232,5 +238,3 @@ assert u2 is not None assert u2.valid - -