Exemplo n.º 1
0
 def test_change_password(self):
     """Can change password, and authenticate with new password"""
     new_password = '******'
     self.assertTrue(utils.check_password(self.user, self.password))
     self.assertTrue(utils.set_password(self.user, new_password))
     self.assertTrue(utils.check_password(self.user, new_password))
     self.assertTrue(utils.has_usable_password(self.user))
Exemplo n.º 2
0
 def test_change_password(self):
     """Can change password, and authenticate with new password"""
     new_password = '******'
     self.assertTrue(utils.check_password(self.user, self.password))
     self.assertTrue(utils.set_password(self.user, new_password))
     self.assertTrue(utils.check_password(self.user, new_password))
     self.assertTrue(utils.has_usable_password(self.user))
Exemplo n.º 3
0
 def test_unusable_password_empty(self):
     """Setting empty string as unusable password disables auth"""
     new_password = ''
     self.assertTrue(utils.has_usable_password(self.user))
     self.assertTrue(utils.check_password(self.user, self.password))
     self.assertTrue(utils.set_password(self.user, new_password))
     self.assertFalse(utils.check_password(self.user, self.password))
     self.assertFalse(utils.check_password(self.user, new_password))
     self.assertFalse(utils.has_usable_password(self.user))
Exemplo n.º 4
0
 def test_unusable_password_none(self):
     """Setting None as unusable password disables auth"""
     new_password = None
     self.assertTrue(utils.has_usable_password(self.user))
     self.assertTrue(utils.check_password(self.user, self.password))
     self.assertTrue(utils.set_password(self.user, new_password))
     self.assertFalse(utils.check_password(self.user, self.password))
     self.assertFalse(utils.check_password(self.user, new_password))
     self.assertFalse(utils.has_usable_password(self.user))
Exemplo n.º 5
0
 def test_unusable_password_empty(self):
     """Setting empty string as unusable password disables auth"""
     new_password = ''
     self.assertTrue(utils.has_usable_password(self.user))
     self.assertTrue(utils.check_password(self.user, self.password))
     self.assertTrue(utils.set_password(self.user, new_password))
     self.assertFalse(utils.check_password(self.user, self.password))
     self.assertFalse(utils.check_password(self.user, new_password))
     self.assertFalse(utils.has_usable_password(self.user))
Exemplo n.º 6
0
 def test_unusable_password_none(self):
     """Setting None as unusable password disables auth"""
     new_password = None
     self.assertTrue(utils.has_usable_password(self.user))
     self.assertTrue(utils.check_password(self.user, self.password))
     self.assertTrue(utils.set_password(self.user, new_password))
     self.assertFalse(utils.check_password(self.user, self.password))
     self.assertFalse(utils.check_password(self.user, new_password))
     self.assertFalse(utils.has_usable_password(self.user))
Exemplo n.º 7
0
    def authenticate(self, username=None, password=None):
        if not getattr(settings, 'USE_LDAP', False):
            # Must have USE_LDAP set to True to authenticate with this backend
            return None

        if username is None or password is None:
            return None

        if not utils.check_password(username, password):
            return None

        try:
            return User.objects.get(username=username)
        except User.DoesNotExist:
            return self.__create_user(username)
Exemplo n.º 8
0
 def check_password(self, raw_password):
     return ldap_utils.check_password(self.get_username(), raw_password)
Exemplo n.º 9
0
 def test_empty_incorrect_password(self):
     """Check authentication fails with empty or None password"""
     self.assertTrue(utils.has_usable_password(self.user))
     self.assertFalse(utils.check_password(self.user, ''))
     self.assertFalse(utils.check_password(self.user, None))
Exemplo n.º 10
0
 def test_empty_incorrect_password(self):
     """Check authentication fails with empty or None password"""
     self.assertTrue(utils.has_usable_password(self.user))
     self.assertFalse(utils.check_password(self.user, ''))
     self.assertFalse(utils.check_password(self.user, None))
Exemplo n.º 11
0
 def check_password(self, raw_password):
     return ldap_utils.check_password(self.get_username(), raw_password)