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))
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))
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))
def set_unusable_password(self): super(LDAPUser, self).set_unusable_password() ldap_utils.set_password(self.get_username(), None)