Skip to content

Commit

Permalink
update ldap tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentDcmps committed Jan 30, 2025
1 parent 5ff8f60 commit 039eca9
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions tests/managers/test_manager_ldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,22 @@ def tearDown(self):
@patch("supysonic.managers.ldap.ldap3.Connection")
def test_ldapManager_searchUser(self, mock_object):
mock_object.return_value.__enter__.return_value.entries = [
{LDAP["username_attr"]:"toto"}]
{LDAP["email_attr"]:"[email protected]",
LDAP["username_attr"]:"toto"
}]
ldap = LdapManager(**LDAP)
ldap_user = ldap.search_user("toto", LDAP["user_filter"])
self.assertEqual(ldap_user[LDAP["username_attr"]], "toto")
self.assertEqual(ldap_user[LDAP["email_attr"]], "toto@example.com")
ldap_user = ldap.search_user("tata", LDAP["user_filter"])
self.assertFalse(ldap_user)
self.assertIsNone(ldap_user)

@patch("supysonic.managers.ldap.ldap3.Connection")
def test_ldapManager_try_auth(self, mock_object):
mock_object.return_value.__enter__.return_value.entries = [
MockEntrie ("cn=toto",{"mail":"[email protected]"})]
MockEntrie ("cn=toto",{LDAP["email_attr"]:"[email protected]", LDAP["username_attr"]:"toto"})]
ldap = LdapManager(**LDAP)
ldap_user = ldap.try_auth("toto", "toto")
self.assertFalse(ldap_user["admin"])
self.assertEqual(ldap_user[LDAP["email_attr"]], "[email protected]")
ldap_user = ldap.try_auth("tata", "tata")
self.assertFalse(ldap_user)
self.assertIsNone(ldap_user)

0 comments on commit 039eca9

Please sign in to comment.