[tryton-debian-vcs] tryton-modules-ldap-authentication branch upstream updated. upstream/3.4.1-1-g236f823
Mathias Behrle
tryton-debian-vcs at alioth.debian.org
Thu Apr 23 16:04:08 UTC 2015
The following commit has been merged in the upstream branch:
https://alioth.debian.org/plugins/scmgit/cgi-bin/gitweb.cgi/?p=tryton/tryton-modules-ldap-authentication.git;a=commitdiff;h=upstream/3.4.1-1-g236f823
commit 236f8234e684a7b1eb472372303570147e5039b1
Author: Mathias Behrle <mathiasb at m9s.biz>
Date: Thu Apr 23 16:59:59 2015 +0200
Adding upstream version 3.6.0.
Signed-off-by: Mathias Behrle <mathiasb at m9s.biz>
diff --git a/CHANGELOG b/CHANGELOG
index b0c8923..22db2a0 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,4 +1,4 @@
-Version 3.4.1 - 2015-02-26
+Version 3.6.0 - 2015-04-20
* Bug fixes (see mercurial logs for details)
Version 3.4.0 - 2014-10-20
diff --git a/PKG-INFO b/PKG-INFO
index be04963..d0d0e42 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,12 +1,12 @@
Metadata-Version: 1.1
Name: trytond_ldap_authentication
-Version: 3.4.1
+Version: 3.6.0
Summary: Tryton module to authenticate users through LDAP
Home-page: http://www.tryton.org/
Author: Tryton
Author-email: issue_tracker at tryton.org
License: GPL-3
-Download-URL: http://downloads.tryton.org/3.4/
+Download-URL: http://downloads.tryton.org/3.6/
Description: trytond_ldap_authentication
===========================
diff --git a/__init__.py b/__init__.py
index c79ab3e..2da691f 100644
--- a/__init__.py
+++ b/__init__.py
@@ -1,5 +1,5 @@
-#This file is part of Tryton. The COPYRIGHT file at the top level of
-#this repository contains the full copyright notices and license terms.
+# This file is part of Tryton. The COPYRIGHT file at the top level of
+# this repository contains the full copyright notices and license terms.
from trytond.pool import Pool
from .res import *
diff --git a/res.py b/res.py
index e31f512..7081a3f 100644
--- a/res.py
+++ b/res.py
@@ -1,5 +1,5 @@
-#This file is part of Tryton. The COPYRIGHT file at the top level of
-#this repository contains the full copyright notices and license terms.
+# This file is part of Tryton. The COPYRIGHT file at the top level of
+# this repository contains the full copyright notices and license terms.
import logging
import urlparse
@@ -44,7 +44,7 @@ def ldap_connection():
scheme, port = 'ldap', 389
conn = ldap.initialize('%s://%s:%s/' % (
scheme, uri.hostname, uri.port or port))
- if config.getboolean(section, 'active_directory', 'False'):
+ if config.getboolean(section, 'active_directory', default=False):
conn.set_option(ldap.OPT_REFERRALS, 0)
if 'tls' in uri.scheme:
conn.start_tls_s()
@@ -83,7 +83,7 @@ class User:
'onelevel': ldap.SCOPE_ONELEVEL,
'subtree': ldap.SCOPE_SUBTREE,
}.get(scope)
- uid = config.get(section, 'uid', 'uid')
+ uid = config.get(section, 'uid', default='uid')
if filter_:
filter_ = '(&(%s=%s)%s)' % (uid, login, filter_)
else:
@@ -107,8 +107,8 @@ class User:
if cls.ldap_search_user(login, con, attrs=[]):
find = True
break
- except ldap.LDAPError, e:
- logger.error('LDAPError: %s' % str(e))
+ except ldap.LDAPError:
+ logger.error('LDAPError when checking password', exc_info=True)
if find:
cls.raise_user_error('set_passwd_ldap_user', (login,))
@@ -139,7 +139,7 @@ class User:
con = ldap_connection()
if con:
user = cls(Transaction().user)
- uid = config.get(section, 'uid', 'uid')
+ uid = config.get(section, 'uid', default='uid')
users = cls.ldap_search_user(user.login, con, attrs=[uid])
if users and len(users) == 1:
[(dn, attrs)] = users
@@ -149,8 +149,9 @@ class User:
del values['password']
else:
cls.raise_user_error('wrong_password')
- except ldap.LDAPError, e:
- logger.error('LDAPError: %s' % str(e))
+ except ldap.LDAPError:
+ logger.error('LDAPError when setting preferences',
+ exc_info=True)
super(User, cls).set_preferences(values, old_password=old_password)
@classmethod
@@ -160,21 +161,23 @@ class User:
try:
con = ldap_connection()
if con:
- uid = config.get(section, 'uid', 'uid')
+ uid = config.get(section, 'uid', default='uid')
users = cls.ldap_search_user(login, con, attrs=[uid])
if users and len(users) == 1:
[(dn, attrs)] = users
if password and con.simple_bind_s(dn, password):
+ # Use ldap uid so we always get the right case
+ login = attrs.get(uid, [login])[0]
user_id, _ = cls._get_login(login)
if user_id:
LoginAttempt.remove(login)
return user_id
elif config.getboolean(section, 'create_user'):
user, = cls.create([{
- 'name': attrs.get(uid, [login])[0],
+ 'name': login,
'login': login,
}])
return user.id
- except ldap.LDAPError, e:
- logger.error('LDAPError: %s' % str(e))
+ except ldap.LDAPError:
+ logger.error('LDAPError when login', exc_info=True)
return super(User, cls).get_login(login, password)
diff --git a/setup.py b/setup.py
index de9c700..b238e85 100644
--- a/setup.py
+++ b/setup.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
-#This file is part of Tryton. The COPYRIGHT file at the top level of
-#this repository contains the full copyright notices and license terms.
+# This file is part of Tryton. The COPYRIGHT file at the top level of
+# this repository contains the full copyright notices and license terms.
from setuptools import setup
import re
diff --git a/tests/__init__.py b/tests/__init__.py
index a33f381..acbe705 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -1,5 +1,5 @@
-#This file is part of Tryton. The COPYRIGHT file at the top level of
-#this repository contains the full copyright notices and license terms.
+# This file is part of Tryton. The COPYRIGHT file at the top level of
+# this repository contains the full copyright notices and license terms.
from .test_ldap_authentication import suite
diff --git a/tests/test_ldap_authentication.py b/tests/test_ldap_authentication.py
index f42b5fa..222459e 100644
--- a/tests/test_ldap_authentication.py
+++ b/tests/test_ldap_authentication.py
@@ -1,12 +1,12 @@
-#This file is part of Tryton. The COPYRIGHT file at the top level of
-#this repository contains the full copyright notices and license terms.
+# This file is part of Tryton. The COPYRIGHT file at the top level of
+# this repository contains the full copyright notices and license terms.
import unittest
from mock import patch
import ldap
import trytond.tests.test_tryton
-from trytond.tests.test_tryton import test_depends
+from trytond.tests.test_tryton import ModuleTestCase
from trytond.tests.test_tryton import POOL, DB_NAME, USER, CONTEXT
from trytond.transaction import Transaction
from trytond.config import config
@@ -16,21 +16,18 @@ from trytond.modules.ldap_authentication.res import parse_ldap_url
section = 'ldap_authentication'
-class LDAPAuthenticationTestCase(unittest.TestCase):
+class LDAPAuthenticationTestCase(ModuleTestCase):
'Test LDAPAuthentication module'
+ module = 'ldap_authentication'
def setUp(self):
- trytond.tests.test_tryton.install_module('ldap_authentication')
+ super(LDAPAuthenticationTestCase, self).setUp()
config.add_section(section)
config.set(section, 'uri', 'ldap://localhost/dc=tryton,dc=org')
def tearDown(self):
config.remove_section(section)
- def test0006depends(self):
- 'Test depends'
- test_depends()
-
def test_user_get_login(self):
'Test User.get_login'
with Transaction().start(DB_NAME, USER, context=CONTEXT):
@@ -42,26 +39,33 @@ class LDAPAuthenticationTestCase(unittest.TestCase):
con = initialize.return_value
con.simple_bind_s.return_value = True
if find:
- ldap_search_user.return_value = [('dn', {})]
+ ldap_search_user.return_value = [('dn', {'uid': [find]})]
else:
ldap_search_user.return_value = None
return User.get_login(login, password)
# Test existing user
- self.assertEqual(get_login('admin', 'admin', False), USER)
- self.assertEqual(get_login('admin', 'admin', True), USER)
+ self.assertEqual(get_login('admin', 'admin', None), USER)
+ self.assertEqual(get_login('admin', 'admin', 'admin'), USER)
+ self.assertEqual(get_login('AdMiN', 'admin', 'admin'), USER)
# Test new user
- self.assertFalse(get_login('foo', 'bar', False))
- self.assertFalse(get_login('foo', 'bar', True))
+ self.assertFalse(get_login('foo', 'bar', None))
+ self.assertFalse(get_login('foo', 'bar', 'foo'))
# Test create new user
config.set(section, 'create_user', 'True')
- user_id = get_login('foo', 'bar', True)
+ user_id = get_login('foo', 'bar', 'foo')
foo, = User.search([('login', '=', 'foo')])
self.assertEqual(user_id, foo.id)
self.assertEqual(foo.name, 'foo')
+ # Test create new user with different case
+ user_id = get_login('BaR', 'foo', 'bar')
+ bar, = User.search([('login', '=', 'bar')])
+ self.assertEqual(user_id, bar.id)
+ self.assertEqual(bar.name, 'bar')
+
def test_parse_ldap_url(self):
'Test parse_ldap_url'
self.assertEqual(
diff --git a/tryton.cfg b/tryton.cfg
index 5b29448..299814d 100644
--- a/tryton.cfg
+++ b/tryton.cfg
@@ -1,5 +1,5 @@
[tryton]
-version=3.4.1
+version=3.6.0
depends:
ir
res
diff --git a/trytond_ldap_authentication.egg-info/PKG-INFO b/trytond_ldap_authentication.egg-info/PKG-INFO
index e9aa2db..3009439 100644
--- a/trytond_ldap_authentication.egg-info/PKG-INFO
+++ b/trytond_ldap_authentication.egg-info/PKG-INFO
@@ -1,12 +1,12 @@
Metadata-Version: 1.1
Name: trytond-ldap-authentication
-Version: 3.4.1
+Version: 3.6.0
Summary: Tryton module to authenticate users through LDAP
Home-page: http://www.tryton.org/
Author: Tryton
Author-email: issue_tracker at tryton.org
License: GPL-3
-Download-URL: http://downloads.tryton.org/3.4/
+Download-URL: http://downloads.tryton.org/3.6/
Description: trytond_ldap_authentication
===========================
diff --git a/trytond_ldap_authentication.egg-info/requires.txt b/trytond_ldap_authentication.egg-info/requires.txt
index 775bac8..c8cb0cd 100644
--- a/trytond_ldap_authentication.egg-info/requires.txt
+++ b/trytond_ldap_authentication.egg-info/requires.txt
@@ -1,2 +1,2 @@
python-ldap
-trytond >= 3.4, < 3.5
\ No newline at end of file
+trytond >= 3.6, < 3.7
\ No newline at end of file
--
tryton-modules-ldap-authentication
More information about the tryton-debian-vcs
mailing list