def test_change_algorithm(self): new_algorithm = 'sha256' PasswordHelper.algorithm = new_algorithm result = PasswordHelper.create_password('my shiny password') self.assertTrue(PasswordHelper.algorithm == 'sha256', 'Algorithm change did not stick') self.assertTrue(result[:len(new_algorithm)] == new_algorithm, 'new algorithm not used to hash')
def test_invalid_password(self): new_password = '******' stored_password = PasswordHelper.create_password(new_password) guess_password = '******' result = PasswordHelper.validate_password(stored_password, guess_password) self.assertFalse(result.success, 'Incorrect password was found valid') self.assertEqual(result.new_password, stored_password, 'No new password should be needed')
def test_valid_password(self): new_password = '******' stored_password = PasswordHelper.create_password(new_password) guess_password = '******' result = PasswordHelper.validate_password(stored_password, guess_password) self.assertTrue(result.success, 'Correct password not valid') self.assertEqual(result.new_password, stored_password, 'No new password should be needed')
def test_change_algorithm(self): new_algorithm = 'sha256' PasswordHelper.algorithm = new_algorithm result = PasswordHelper.create_password('my shiny password') self.assertTrue(PasswordHelper.algorithm == 'sha256', 'Algorithm change did not stick') self.assertTrue(result[:len(new_algorithm)] == new_algorithm, 'new algorithm not used to hash')
def test_change_password_success(self): old_password = '******' stored_password = PasswordHelper.create_password(old_password) new_password = '******' result = PasswordHelper.change_password(stored_password, old_password, new_password) self.assertTrue(result.success) self.assertIsInstance(result.new_password, str, 'New password to store after changing password not returned') self.assertTrue(result.new_password, 'New password not returned')
def test_change_password_fail(self): actual_password = '******' stored_password = PasswordHelper.create_password(actual_password) incorrect_password = '******' new_password = '******' result = PasswordHelper.change_password(stored_password, incorrect_password, new_password) self.assertFalse(result.success) self.assertEqual(result.new_password, stored_password, 'No new password should be needed')
def test_incorrect_current_password(self): new_password = '******' stored_password = PasswordHelper.create_password(new_password) guess_password = '******' result = PasswordHelper.validate_password(stored_password, guess_password, legacy_validator=self.old_comparator) self.assertFalse(result.success, 'Correct password not valid') self.assertEqual(result.new_password, stored_password, 'No new password should be needed')
def test_invalid_password(self): new_password = '******' stored_password = PasswordHelper.create_password(new_password) guess_password = '******' result = PasswordHelper.validate_password(stored_password, guess_password) self.assertFalse(result.success, 'Incorrect password was found valid') self.assertEqual(result.new_password, stored_password, 'No new password should be needed')
def test_valid_password(self): new_password = '******' stored_password = PasswordHelper.create_password(new_password) guess_password = '******' result = PasswordHelper.validate_password(stored_password, guess_password) self.assertTrue(result.success, 'Correct password not valid') self.assertEqual(result.new_password, stored_password, 'No new password should be needed')
def test_change_password_success(self): old_password = '******' stored_password = PasswordHelper.create_password(old_password) new_password = '******' result = PasswordHelper.change_password(stored_password, old_password, new_password) self.assertTrue(result.success) self.assertIsInstance( result.new_password, str, 'New password to store after changing password not returned') self.assertTrue(result.new_password, 'New password not returned')
def test_change_password_fail(self): actual_password = '******' stored_password = PasswordHelper.create_password(actual_password) incorrect_password = '******' new_password = '******' result = PasswordHelper.change_password(stored_password, incorrect_password, new_password) self.assertFalse(result.success) self.assertEqual(result.new_password, stored_password, 'No new password should be needed')
def test_incorrect_current_password(self): new_password = '******' stored_password = PasswordHelper.create_password(new_password) guess_password = '******' result = PasswordHelper.validate_password( stored_password, guess_password, legacy_validator=self.old_comparator) self.assertFalse(result.success, 'Correct password not valid') self.assertEqual(result.new_password, stored_password, 'No new password should be needed')
def test_create_password(self): new_password = '******' result = PasswordHelper.create_password(new_password) self.assertIsNotNone(result, 'password was not able to be created')
def test_create_password(self): new_password = '******' result = PasswordHelper.create_password(new_password) self.assertIsNotNone(result, 'password was not able to be created')