Exemple #1
0
 def test_evaluatePassword_fail_empty(self, mock_evaluatePasswordDictionary,
                                      mock_evaluatePasswordCharacters):
     password = ""
     mock_evaluatePasswordDictionary.return_value = [password, 0]
     mock_evaluatePasswordCharacters.return_value = 0
     security_bits, security_digits, safe, safer = robustness.evaluatePassword(
         password)
     self.assertEqual(security_bits, 0, "Security bits is wrong")
     self.assertEqual(security_digits, 0, "Security digits is wrong")
     self.assertFalse(safe, "This an empty password and is not safe")
     self.assertFalse(safer, "This an empty password and is not safer")
Exemple #2
0
 def test_evaluatePassword_success(self, mock_evaluatePasswordDictionary,
                                   mock_evaluatePasswordCharacters):
     password = "******"
     mock_evaluatePasswordDictionary.return_value = [password, 100000000]
     mock_evaluatePasswordCharacters.return_value = 200000000
     security_bits, security_digits, safe, safer = robustness.evaluatePassword(
         password)
     self.assertEqual(security_bits, 54.15, "Security bits is wrong")
     self.assertEqual(security_digits, 16, "Security digits is wrong")
     self.assertTrue(safe, "xxxxx")
     self.assertTrue(safer, "xxxxx")
Exemple #3
0
 def test_evaluatePassword_fail(self, mock_evaluatePasswordDictionary,
                                mock_evaluatePasswordCharacters):
     password = "******"
     mock_evaluatePasswordDictionary.return_value = [password, 10]
     mock_evaluatePasswordCharacters.return_value = 50
     security_bits, security_digits, safe, safer = robustness.evaluatePassword(
         password)
     self.assertEqual(security_bits, 8.97, "Security bits is wrong")
     self.assertEqual(security_digits, 3, "Security digits is wrong")
     self.assertFalse(safe, "This should not be safe")
     self.assertFalse(safer, "This should not be safe or safer")
Exemple #4
0
 def test_evaluatePassword_real(self):
     password = "******"  # 5^1 * (26+26+28+10)^8 = 21523360500000000
     mocked_open = mock_open(
         read_data='abc \n def \n abcdefghi \n klm \n opq')
     with patch('derivatex.robustness.open', mocked_open, create=True):
         security_bits, security_digits, safe, safer = robustness.evaluatePassword(
             password)
     self.assertEqual(security_bits, 54.26, "Security bits is wrong")
     self.assertEqual(security_digits, 16, "Security digits is wrong")
     self.assertTrue(safe,
                     "This has 54.26 bits of security and should be safe")
     self.assertTrue(safer,
                     "This has 54.26 bits of security and should be safer")
Exemple #5
0
def check_master_password(master_password1, master_password2):
    valid = True
    safer = True
    if not master_password1 == master_password2:
        return not valid, not safer, "Passwords do not match. Please try again."
    security_bits, security_digits, _safe, _safer = evaluatePassword(master_password1)
    message = "Your password has a security of "+str(security_bits)+" bits, equivalent to " + \
               "a suitcase lock of "+str(security_digits)+" digits. "
    if not _safe:
        return not valid, not safer, message + "This is not safe. Please try again with a more complex password." 
    if not _safer:
        return valid, not safer, message + "Your password has a weak security. " + \
                        "Would you like to enter a more complex password?"
    return valid, safer, message + "Your password is safe, good job."