Skip to content

Commit

Permalink
Added test for MockLDAP.simple_bind_s.
Browse files Browse the repository at this point in the history
  • Loading branch information
Christo Buschek committed Oct 31, 2011
1 parent 49d2141 commit 042c110
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import unittest


tree = {
directory = {
"cn=admin,dc=30loops,dc=net": {
"userPassword": "ldaptest"
}
Expand All @@ -13,7 +13,25 @@

class TestLdapOperations(unittest.TestCase):
def setUp(self):
self.mock_ldap = MockLDAP(tree)
self.mock_ldap = MockLDAP(directory)

def tearDown(self):
self.mock_ldap.reset()

def test_simple_bind_s_operation(self):
"""Try to bind a user."""
# Make a valid bind
eq_(
(97,[]),
self.mock_ldap.simple_bind_s("cn=admin,dc=30loops,dc=net", "ldaptest")
)

# Supply the wrong password
assert_raises(
MockLDAP.INVALID_CREDENTIALS,
self.mock_ldap.simple_bind_s,
who="cn=admin,dc=30loops,dc=net", cred="wrong"
)

def test_add_s_operation(self):
"""Test the addition of records to the mock ldap object."""
Expand Down

0 comments on commit 042c110

Please sign in to comment.