--- a/devtools/testlib.py Mon Oct 11 09:17:54 2010 +0200
+++ b/devtools/testlib.py Mon Oct 11 11:02:27 2010 +0200
@@ -231,7 +231,8 @@
config.global_set_option('default-dest-addrs', send_to)
config.global_set_option('sender-name', 'cubicweb-test')
config.global_set_option('sender-addr', 'cubicweb-test@logilab.fr')
-
+ # default_base_url on config class isn't enough for TestServerConfiguration
+ config.global_set_option('base-url', BASE_URL)
# web resources
try:
config.global_set_option('embed-allowed', re.compile('.*'))
--- a/server/test/unittest_ldapuser.py Mon Oct 11 09:17:54 2010 +0200
+++ b/server/test/unittest_ldapuser.py Mon Oct 11 11:02:27 2010 +0200
@@ -27,10 +27,28 @@
if '17.1' in socket.gethostbyname('ldap1'):
SYT = 'syt'
+ SYT_EMAIL = 'Sylvain Thenault'
ADIM = 'adim'
+ CONFIG = u'''host=ldap1
+user-base-dn=ou=People,dc=logilab,dc=fr
+user-scope=ONELEVEL
+user-classes=top,posixAccount
+user-login-attr=uid
+user-default-group=users
+user-attrs-map=gecos:email,uid:login
+'''
else:
SYT = 'sthenault'
+ SYT_EMAIL = 'sylvain.thenault@logilab.fr'
ADIM = 'adimascio'
+ CONFIG = u'''host=ldap1
+user-base-dn=ou=People,dc=logilab,dc=net
+user-scope=ONELEVEL
+user-classes=top,OpenLDAPperson
+user-login-attr=uid
+user-default-group=users
+user-attrs-map=mail:email,uid:login
+'''
def nopwd_authenticate(self, session, login, password):
@@ -65,22 +83,7 @@
def add_ldap_source(cnx):
cnx.request().create_entity('CWSource', name=u'ldapuser', type=u'ldapuser',
- config=u'''
-# ldap host
-host=ldap1
-# base DN to lookup for usres
-user-base-dn=ou=People,dc=logilab,dc=fr
-# user search scope
-user-scope=ONELEVEL
-# classes of user
-user-classes=top,posixAccount
-# attribute used as login on authentication
-user-login-attr=uid
-# name of a group in which ldap users will be by default
-user-default-group=users
-# map from ldap user attributes to cubicweb attributes
-user-attrs-map=gecos:email,uid:login
-''')
+ config=CONFIG)
cnx.commit()
# XXX: need this first query else we get 'database is locked' from
# sqlite since it doesn't support multiple connections on the same
@@ -124,7 +127,7 @@
self.assertEqual(e.in_group[0].name, 'users')
self.assertEqual(e.owned_by[0].login, SYT)
self.assertEqual(e.created_by, ())
- self.assertEqual(e.primary_email[0].address, 'Sylvain Thenault')
+ self.assertEqual(e.primary_email[0].address, SYT_EMAIL)
# email content should be indexed on the user
rset = self.sexecute('CWUser X WHERE X has_text "thenault"')
self.assertEqual(rset.rows, [[e.eid]])
@@ -412,6 +415,8 @@
self.pool = repo._get_pool()
session = mock_object(pool=self.pool)
self.o = RQL2LDAPFilter(ldapsource, session)
+ self.ldapclasses = ''.join('(objectClass=%s)' % ldapcls
+ for ldapcls in ldapsource.user_classes)
def tearDown(self):
repo._free_pool(self.pool)
@@ -420,13 +425,13 @@
def test_base(self):
rqlst = self._prepare('CWUser X WHERE X login "toto"').children[0]
self.assertEqual(self.o.generate(rqlst, 'X')[1],
- '(&(objectClass=top)(objectClass=posixAccount)(uid=toto))')
+ '(&%s(uid=toto))' % self.ldapclasses)
def test_kwargs(self):
rqlst = self._prepare('CWUser X WHERE X login %(x)s').children[0]
self.o._args = {'x': "toto"}
self.assertEqual(self.o.generate(rqlst, 'X')[1],
- '(&(objectClass=top)(objectClass=posixAccount)(uid=toto))')
+ '(&%s(uid=toto))' % self.ldapclasses)
def test_get_attr(self):
rqlst = self._prepare('Any X WHERE E firstname X, E eid 12').children[0]
--- a/web/test/unittest_facet.py Mon Oct 11 09:17:54 2010 +0200
+++ b/web/test/unittest_facet.py Mon Oct 11 11:02:27 2010 +0200
@@ -148,3 +148,8 @@
# is not in real life)
self.assertEqual(f.rqlst.as_string(),
"DISTINCT Any WHERE X is CWUser, X login 'admin'")
+
+
+if __name__ == '__main__':
+ from logilab.common.testlib import unittest_main
+ unittest_main()
--- a/web/test/unittest_reledit.py Mon Oct 11 09:17:54 2010 +0200
+++ b/web/test/unittest_reledit.py Mon Oct 11 11:02:27 2010 +0200
@@ -218,3 +218,8 @@
rtype)
reledit_ctrl.clear()
reledit_ctrl._tagdefs.update(old_rctl)
+
+
+if __name__ == '__main__':
+ from logilab.common.testlib import unittest_main
+ unittest_main()
--- a/web/views/authentication.py Mon Oct 11 09:17:54 2010 +0200
+++ b/web/views/authentication.py Mon Oct 11 11:02:27 2010 +0200
@@ -60,8 +60,8 @@
raise NotImplementedError()
def revalidate_login(self, req):
- """returns a login string or None, for repository session
- validation purposes
+ """returns a login string or None, for repository session validation
+ purposes
"""
raise NotImplementedError()