class TestLDAPSearchAuthenticatorPluginNaming(Base): """Tests for the L{LDAPSearchAuthenticatorPlugin} IAuthenticator plugin""" def setUp(self): super(TestLDAPSearchAuthenticatorPluginNaming, self).setUp() # Loading the plugin: self.plugin = LDAPSearchAuthenticatorPlugin( self.connection, base_dn, naming_attribute='telephone', ) def test_authenticate_noresults(self): identity = { 'login': '******', 'password': '******' } result = self.plugin.authenticate(self.env, identity) self.assertEqual(result, None) def test_authenticate_comparefail(self): identity = { 'login': fakeuser['telephone'], 'password': '******' } result = self.plugin.authenticate(self.env, identity) self.assertEqual(result, None) def test_authenticate_comparesuccess(self): identity = { 'login': fakeuser['telephone'], 'password': fakeuser['password'] } result = self.plugin.authenticate(self.env, identity) self.assertEqual(result, fakeuser['dn'])
class TestLDAPSearchAuthenticatorPluginNaming(Base): """Tests for the L{LDAPSearchAuthenticatorPlugin} IAuthenticator plugin""" def setUp(self): super(TestLDAPSearchAuthenticatorPluginNaming, self).setUp() # Loading the plugin: self.plugin = LDAPSearchAuthenticatorPlugin( self.connection, base_dn, naming_attribute='telephone', ) def test_authenticate_noresults(self): identity = {'login': '******', 'password': '******'} result = self.plugin.authenticate(self.env, identity) self.assertEqual(result, None) def test_authenticate_comparefail(self): identity = {'login': fakeuser['telephone'], 'password': '******'} result = self.plugin.authenticate(self.env, identity) self.assertEqual(result, None) def test_authenticate_comparesuccess(self): identity = {'login': fakeuser['telephone'], 'password': fakeuser['password']} result = self.plugin.authenticate(self.env, identity) self.assertEqual(result, fakeuser['dn'])
def setUp(self): super(TestLDAPSearchAuthenticatorReturnLogin, self).setUp() # Loading the plugin: self.plugin = LDAPSearchAuthenticatorPlugin( self.connection, base_dn, returned_id='login', )
def setUp(self): super(TestLDAPSearchAuthenticatorPluginNaming, self).setUp() # Loading the plugin: self.plugin = LDAPSearchAuthenticatorPlugin( self.connection, base_dn, naming_attribute='telephone', )
class TestLDAPSearchAuthenticatorReturnLogin(Base): """ Tests the L{LDAPSearchAuthenticatorPlugin} IAuthenticator plugin returning login. """ def setUp(self): super(TestLDAPSearchAuthenticatorReturnLogin, self).setUp() # Loading the plugin: self.plugin = LDAPSearchAuthenticatorPlugin( self.connection, base_dn, returned_id='login', ) def test_authenticate_noresults(self): identity = {'login': '******', 'password': '******'} result = self.plugin.authenticate(self.env, identity) self.assertEqual(result, None) def test_authenticate_comparefail(self): identity = {'login': fakeuser['uid'], 'password': '******'} result = self.plugin.authenticate(self.env, identity) self.assertEqual(result, None) def test_authenticate_comparesuccess(self): identity = {'login': fakeuser['uid'], 'password': fakeuser['password']} result = self.plugin.authenticate(self.env, identity) self.assertEqual(result, fakeuser['uid']) def test_authenticate_dn_in_userdata(self): identity = {'login': fakeuser['uid'], 'password': fakeuser['password']} expected_dn = '<dn:%s>' % b64encode(fakeuser['dn']) result = self.plugin.authenticate(self.env, identity) self.assertEqual(identity['userdata'], expected_dn)
class TestLDAPSearchAuthenticatorReturnLogin(Base): """ Tests the L{LDAPSearchAuthenticatorPlugin} IAuthenticator plugin returning login. """ def setUp(self): super(TestLDAPSearchAuthenticatorReturnLogin, self).setUp() # Loading the plugin: self.plugin = LDAPSearchAuthenticatorPlugin( self.connection, base_dn, returned_id='login', ) def test_authenticate_noresults(self): identity = { 'login': '******', 'password': '******' } result = self.plugin.authenticate(self.env, identity) self.assertEqual(result, None) def test_authenticate_comparefail(self): identity = {'login': fakeuser['uid'], 'password': '******'} result = self.plugin.authenticate(self.env, identity) self.assertEqual(result, None) def test_authenticate_comparesuccess(self): identity = {'login': fakeuser['uid'], 'password': fakeuser['password']} result = self.plugin.authenticate(self.env, identity) self.assertEqual(result, fakeuser['uid']) def test_authenticate_dn_in_userdata(self): identity = {'login': fakeuser['uid'], 'password': fakeuser['password']} expected_dn = '<dn:%s>' % b64encode(fakeuser['dn']) result = self.plugin.authenticate(self.env, identity) self.assertEqual(identity['userdata'], expected_dn)