コード例 #1
0
    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)
コード例 #2
0
    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)
コード例 #3
0
    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)
コード例 #4
0
    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)
コード例 #5
0
    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)
コード例 #6
0
    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)
コード例 #7
0
    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)
コード例 #8
0
    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)
コード例 #9
0
    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)