コード例 #1
0
ファイル: test_ldap.py プロジェクト: MLR-au/esrc-sos-service
    def setUp(self):
        self.config = testing.setUp()
        conf = Config(settings['app.config'])

        servers = conf.app_config['ldap']['servers']
        base = conf.app_config['ldap']['base']
        binduser = conf.app_config['ldap']['binduser']
        bindpass = conf.app_config['ldap']['bindpass']

        self.ldap = LDAP(servers, base, binduser, bindpass)
コード例 #2
0
ファイル: test_ldap.py プロジェクト: MLR-au/esrc-sos-service
class LDAPTests(unittest.TestCase):
    def setUp(self):
        self.config = testing.setUp()
        conf = Config(settings['app.config'])

        servers = conf.app_config['ldap']['servers']
        base = conf.app_config['ldap']['base']
        binduser = conf.app_config['ldap']['binduser']
        bindpass = conf.app_config['ldap']['bindpass']

        self.ldap = LDAP(servers, base, binduser, bindpass)

    def tearDown(self):
        testing.tearDown()

    def test_ldap_init(self):
        self.assertIsInstance(self.ldap.conn, ldap.ldapobject.SimpleLDAPObject)

    def test_ldap_authenticate(self):
        # check user known and pass correct
        user = '******'
        passwd = 'p1'
        self.assertTrue(self.ldap.authenticate(user, passwd))

        # check good user, bad pass
        user = '******'
        passwd = 'no'
        self.assertFalse(self.ldap.authenticate(user, passwd))

        # check bad user, good pass
        user = '******'
        passwd = 'p1'
        self.assertFalse(self.ldap.authenticate(user, passwd))

    def test_ldap_get_user_data(self):
        user = '******'
        fullname = 'test user'
        passwd = 'p1'
        result = self.ldap.authenticate(user, passwd)

        user_data = self.ldap.get_user_data()
        self.assertEqual(user_data.username, user)
        self.assertEqual(user_data.fullname, fullname)