def test_04_testconnection_fail(self): ldap3mock.setLDAPDirectory(LDAPDirectory) y = LDAPResolver() res = y.testconnection({ 'LDAPURI': 'ldap://localhost', 'LDAPBASE': 'o=test', 'BINDDN': 'cn=manager,ou=example,o=test', 'BINDPW': 'wrongpw', 'LOGINNAMEATTRIBUTE': 'cn', 'LDAPSEARCHFILTER': '(cn=*)', 'LDAPFILTER': '(&(cn=%s))', 'USERINFO': '{ "username": "******",' '"phone" : "telephoneNumber", ' '"mobile" : "mobile"' ', "email" : "mail", ' '"surname" : "sn", ' '"givenname" : "givenName" }', 'UIDTYPE': 'oid', }) self.assertFalse(res[0], res) self.assertTrue("Wrong credentials" in res[1], res)
def test_05_authtype_not_supported(self): ldap3mock.setLDAPDirectory(LDAPDirectory) y = LDAPResolver() res = y.testconnection({ 'LDAPURI': 'ldap://localhost', 'LDAPBASE': 'o=test', 'BINDDN': 'cn=manager,ou=example,o=test', 'BINDPW': 'ldaptest', 'AUTHTYPE': 'unknown', 'LOGINNAMEATTRIBUTE': 'cn', 'LDAPSEARCHFILTER': '(cn=*)', 'LDAPFILTER': '(&(cn=%s))', 'USERINFO': '{ "username": "******",' '"phone" : "telephoneNumber", ' '"mobile" : "mobile"' ', "email" : "mail", ' '"surname" : "sn", ' '"givenname" : "givenName" }', 'UIDTYPE': 'oid', }) self.assertFalse(res[0], res) self.assertTrue("Authtype unknown not supported" in res[1], res)
def test_05_authtype_not_supported(self): ldap3mock.setLDAPDirectory(LDAPDirectory) y = LDAPResolver() res = y.testconnection( { "LDAPURI": "ldap://localhost", "LDAPBASE": "o=test", "BINDDN": "cn=manager,ou=example,o=test", "BINDPW": "ldaptest", "AUTHTYPE": "unknown", "LOGINNAMEATTRIBUTE": "cn", "LDAPSEARCHFILTER": "(cn=*)", "LDAPFILTER": "(&(cn=%s))", "USERINFO": '{ "username": "******",' '"phone" : "telephoneNumber", ' '"mobile" : "mobile"' ', "email" : "mail", ' '"surname" : "sn", ' '"givenname" : "givenName" }', "UIDTYPE": "oid", } ) self.assertFalse(res[0], res) self.assertTrue("Authtype unknown not supported" in res[1], res)
def test_03_testconnection_anonymous(self): ldap3mock.setLDAPDirectory(LDAPDirectory) y = LDAPResolver() res = y.testconnection({ 'LDAPURI': 'ldap://localhost', 'LDAPBASE': 'o=test', 'LOGINNAMEATTRIBUTE': 'cn', 'LDAPSEARCHFILTER': '(cn=*)', 'BINDDN': '', 'LDAPFILTER': '(&(cn=%s))', 'USERINFO': '{ "username": "******",' '"phone" : "telephoneNumber", ' '"mobile" : "mobile"' ', "email" : "mail", ' '"surname" : "sn", ' '"givenname" : "givenName" }', 'UIDTYPE': 'oid', }) self.assertTrue(res[0], res) self.assertTrue( res[1] == 'Your LDAP config seems to be OK, 3 user ' 'objects found.', res)
def test_04_testconnection_fail(self): ldap3mock.setLDAPDirectory(LDAPDirectory) y = LDAPResolver() res = y.testconnection({'LDAPURI': 'ldap://localhost', 'LDAPBASE': 'o=test', 'BINDDN': 'cn=manager,ou=example,o=test', 'BINDPW': 'wrongpw', 'LOGINNAMEATTRIBUTE': 'cn', 'LDAPSEARCHFILTER': '(cn=*)', 'LDAPFILTER': '(&(cn=%s))', 'USERINFO': '{ "username": "******",' '"phone" : "telephoneNumber", ' '"mobile" : "mobile"' ', "email" : "mail", ' '"surname" : "sn", ' '"givenname" : "givenName" }', 'UIDTYPE': 'oid', }) self.assertFalse(res[0], res) self.assertTrue("Wrong credentials" in res[1], res)
def test_03_testconnection_anonymous(self): ldap3mock.setLDAPDirectory(LDAPDirectory) y = LDAPResolver() res = y.testconnection({'LDAPURI': 'ldap://localhost', 'LDAPBASE': 'o=test', 'LOGINNAMEATTRIBUTE': 'cn', 'LDAPSEARCHFILTER': '(cn=*)', 'BINDDN': '', 'LDAPFILTER': '(&(cn=%s))', 'USERINFO': '{ "username": "******",' '"phone" : "telephoneNumber", ' '"mobile" : "mobile"' ', "email" : "mail", ' '"surname" : "sn", ' '"givenname" : "givenName" }', 'UIDTYPE': 'oid', }) self.assertTrue(res[0], res) self.assertTrue(res[1] == 'Your LDAP config seems to be OK, 3 user ' 'objects found.', res)
def test_05_authtype_not_supported(self): ldap3mock.setLDAPDirectory(LDAPDirectory) y = LDAPResolver() res = y.testconnection({'LDAPURI': 'ldap://localhost', 'LDAPBASE': 'o=test', 'BINDDN': 'cn=manager,ou=example,o=test', 'BINDPW': 'ldaptest', 'AUTHTYPE': 'unknown', 'LOGINNAMEATTRIBUTE': 'cn', 'LDAPSEARCHFILTER': '(cn=*)', 'LDAPFILTER': '(&(cn=%s))', 'USERINFO': '{ "username": "******",' '"phone" : "telephoneNumber", ' '"mobile" : "mobile"' ', "email" : "mail", ' '"surname" : "sn", ' '"givenname" : "givenName" }', 'UIDTYPE': 'oid', }) self.assertFalse(res[0], res) self.assertTrue("Authtype unknown not supported" in res[1], res)
def test_03_testconnection_anonymous(self): ldap3mock.setLDAPDirectory(LDAPDirectory) y = LDAPResolver() res = y.testconnection( { "LDAPURI": "ldap://localhost", "LDAPBASE": "o=test", "LOGINNAMEATTRIBUTE": "cn", "LDAPSEARCHFILTER": "(cn=*)", "BINDDN": "", "LDAPFILTER": "(&(cn=%s))", "USERINFO": '{ "username": "******",' '"phone" : "telephoneNumber", ' '"mobile" : "mobile"' ', "email" : "mail", ' '"surname" : "sn", ' '"givenname" : "givenName" }', "UIDTYPE": "oid", } ) self.assertTrue(res[0], res) self.assertTrue(res[1] == "Your LDAP config seems to be OK, 3 user " "objects found.", res)
def test_04_testconnection_fail(self): ldap3mock.setLDAPDirectory(LDAPDirectory) y = LDAPResolver() res = y.testconnection( { "LDAPURI": "ldap://localhost", "LDAPBASE": "o=test", "BINDDN": "cn=manager,ou=example,o=test", "BINDPW": "wrongpw", "LOGINNAMEATTRIBUTE": "cn", "LDAPSEARCHFILTER": "(cn=*)", "LDAPFILTER": "(&(cn=%s))", "USERINFO": '{ "username": "******",' '"phone" : "telephoneNumber", ' '"mobile" : "mobile"' ', "email" : "mail", ' '"surname" : "sn", ' '"givenname" : "givenName" }', "UIDTYPE": "oid", } ) self.assertFalse(res[0], res) self.assertTrue("Wrong credentials" in res[1], res)