def test_tweetsec_numerical_strength(self): #test that password_eval module function numerical_strength_value returns the proper value, numerical_strength_value = password_eval.numerical_strength_value("password1") self.assertEqual(numerical_strength_value, 4) numerical_strength_value = password_eval.numerical_strength_value("goat m4n") self.assertEqual(numerical_strength_value, 15) numerical_strength_value = password_eval.numerical_strength_value("s0_0per 5nak3") self.assertEqual(numerical_strength_value, 44)
def test_tweetsec_numerical_strength(self): #test that password_eval module function numerical_strength_value returns the proper value, numerical_strength_value = password_eval.numerical_strength_value( "password1") self.assertEqual(numerical_strength_value, 4) numerical_strength_value = password_eval.numerical_strength_value( "goat m4n") self.assertEqual(numerical_strength_value, 15) numerical_strength_value = password_eval.numerical_strength_value( "s0_0per 5nak3") self.assertEqual(numerical_strength_value, 44)
def evaluator(): if "password" in request.vars: password = request.vars.password password_strength = password_eval.numerical_strength_value(password) if password_strength >= 50: return "Congrats on the strong password" elif 10< password_strength <50: #return a modified version of the password that is strong if len(password)>=13: #replacing the first 4 chars with 4 different char types will ensure that the pw strength is strong IF there are >= 13 chars password = "******" + password[4:len(password)] else: #add 4 different char types to the beginning of the password, and add spaces at the end as necessary to reach required # of chars for strong pw password = "******" + password + (" "* (13 - (4+len(password)))) return password elif password_strength <= 10: return "Please try a better password" return