Merge lp:~lmc/repoze.who.plugins.ldap/bind_pass-fix into lp:repoze.who.plugins.ldap

Proposed by Lorenzo M. Catucci
Status: Needs review
Proposed branch: lp:~lmc/repoze.who.plugins.ldap/bind_pass-fix
Merge into: lp:repoze.who.plugins.ldap
Diff against target: 56 lines (+14/-2)
2 files modified
repoze/who/plugins/ldap/plugins.py (+2/-2)
repoze/who/plugins/ldap/tests.py (+12/-0)
To merge this branch: bzr merge lp:~lmc/repoze.who.plugins.ldap/bind_pass-fix
Reviewer Review Type Date Requested Status
Gustavo Narea Pending
Review via email: mp+37466@code.launchpad.net

Description of the change

The branch wraps the bugfix from lp:~salmon/repoze.who.plugins.ldap/fixes in some more unittests. The plugin coverage grows from 76% to 79%!

To post a comment you must log in.

Unmerged revisions

81. By Lorenzo M. Catucci <lorenzo@sancho>

Merge bugfix from lp:~salmon/repoze.who.plugins.ldap/fixes .

80. By Lorenzo M. Catucci <lorenzo@sancho>

Add tests for the privileged bind_dn searches.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'repoze/who/plugins/ldap/plugins.py'
2--- repoze/who/plugins/ldap/plugins.py 2010-06-03 09:13:51 +0000
3+++ repoze/who/plugins/ldap/plugins.py 2010-10-04 13:32:45 +0000
4@@ -208,7 +208,7 @@
5
6 if self.bind_dn:
7 try:
8- self.ldap_connection.bind_s(self.bind_dn, self.bind_password)
9+ self.ldap_connection.bind_s(self.bind_dn, self.bind_pass)
10 except ldap.LDAPError:
11 raise ValueError("Couldn't bind with supplied credentials")
12 try:
13@@ -300,7 +300,7 @@
14
15 if self.bind_dn:
16 try:
17- self.ldap_connection.bind_s(self.bind_dn, self.bind_password)
18+ self.ldap_connection.bind_s(self.bind_dn, self.bind_pass)
19 except ldap.LDAPError:
20 raise ValueError("Couldn't bind with supplied credentials")
21 try:
22
23=== modified file 'repoze/who/plugins/ldap/tests.py'
24--- repoze/who/plugins/ldap/tests.py 2010-05-24 22:16:50 +0000
25+++ repoze/who/plugins/ldap/tests.py 2010-10-04 13:32:45 +0000
26@@ -40,6 +40,8 @@
27 # Connecting to a fake server with a fake account:
28 conn = fakeldap.FakeLDAPConnection()
29 conn.simple_bind_s('Manager', 'some password')
30+ # monkey-patch the bind_s method into the connection
31+ conn.bind_s = conn.simple_bind_s
32 # We must explicitly create the base_dn DIT components
33 fakeldap.addTreeItems(base_dn)
34 # Adding a fake user, which is used in the tests
35@@ -271,6 +273,14 @@
36 verifyClass(IAuthenticator, LDAPAuthenticatorPlugin, tentative=True)
37
38
39+class TestLDAPSearchAuthenticatorBindDnPlugin(TestLDAPAuthenticatorPlugin):
40+ """Tests for the L{LDAPSearchAuthenticatorPlugin} IAuthenticator plugin in the bind_dn set case"""
41+
42+ def setUp(self):
43+ super(TestLDAPAuthenticatorPlugin, self).setUp()
44+ # Loading the plugin:
45+ self.plugin = LDAPSearchAuthenticatorPlugin(self.connection, base_dn, bind_dn = 'Manager', bind_pass = 'some password')
46+
47 class TestMakeLDAPAttributesPlugin(unittest.TestCase):
48 """Tests for the constructor of L{LDAPAttributesPlugin}"""
49
50@@ -478,6 +488,8 @@
51 "test"))
52 suite.addTest(unittest.makeSuite(TestLDAPAuthenticatorPluginStartTls,
53 "test"))
54+ suite.addTest(unittest.makeSuite(TestLDAPSearchAuthenticatorBindDnPlugin,
55+ "test"))
56 return suite
57
58

Subscribers

People subscribed via source and target branches