-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5ff8f60
commit 039eca9
Showing
1 changed file
with
7 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) |