示例#1
0
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'])
示例#2
0
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'])
示例#3
0
 def setUp(self):
     super(TestLDAPSearchAuthenticatorReturnLogin, self).setUp()
     # Loading the plugin:
     self.plugin = LDAPSearchAuthenticatorPlugin(
         self.connection,
         base_dn,
         returned_id='login',
     )
示例#4
0
 def setUp(self):
     super(TestLDAPSearchAuthenticatorPluginNaming, self).setUp()
     # Loading the plugin:
     self.plugin = LDAPSearchAuthenticatorPlugin(
         self.connection,
         base_dn,
         naming_attribute='telephone',
     )
示例#5
0
 def setUp(self):
     super(TestLDAPSearchAuthenticatorReturnLogin, self).setUp()
     # Loading the plugin:
     self.plugin = LDAPSearchAuthenticatorPlugin(
         self.connection,
         base_dn,
         returned_id='login',
         )
示例#6
0
 def setUp(self):
     super(TestLDAPSearchAuthenticatorPluginNaming, self).setUp()
     # Loading the plugin:
     self.plugin = LDAPSearchAuthenticatorPlugin(
         self.connection,
         base_dn,
         naming_attribute='telephone',
         )
示例#7
0
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)
示例#8
0
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)