Example #1
0
def initiateCommandLine():
    from derivatex.tools import isMasterpassworddigestfilePresent
    from derivatex.initiate import check_master_password, setup
    from getpass import getpass
    try:
        from builtins import input
    except ImportError:
        from __builtin__ import raw_input as input
    success = False
    if isMasterpassworddigestfilePresent():
        if input(
                "Digest file already exists. Do you want to overwrite it? yes/no? [no]: "
        ) != "yes":
            return
    valid = retry = False
    while not valid or retry:
        master_password1 = getpass("Enter your master password: "******"Enter your master password again: ")
        valid, safer, message = check_master_password(master_password1,
                                                      master_password2)
        print(message)
        if valid and not safer:
            retry = input("yes/no? [no]") == 'yes'
    birthdate = input("Enter your birthdate (dd/mm/yyyy): ")
    retry = False
    while not success or retry:
        print("Computing master digest...")
        success, message = setup(master_password1, birthdate)
        print(message)
        if not success:
            retry = input(
                "Do you want to run the procedure again? [no]") == "yes"
Example #2
0
 def test_check_master_password_unmatch(self, mock_evaluatePassword):
     master_password1 = "abc"
     master_password2 = "def"
     mock_evaluatePassword.return_value = [10, 3, True, True]
     valid, safer, message = initiate.check_master_password(master_password1, master_password2)
     self.assertFalse(valid, "This should not be valid")
     self.assertFalse(safer, "This should not be safer")
     self.assertEqual(message, "Passwords do not match. Please try again.")
Example #3
0
 def test_check_master_password_TT(self, mock_evaluatePassword):
     master_password1 = "test"
     master_password2 = "test"
     mock_evaluatePassword.return_value = [10, 3, True, True]
     valid, safer, message = initiate.check_master_password(master_password1, master_password2)
     self.assertTrue(valid, "This should be valid")
     self.assertTrue(safer, "This should be safer")
     self.assertEqual(message, "Your password has a security of 10 bits, equivalent to a suitcase lock of 3 digits. Your password is safe, good job.")
Example #4
0
 def test_check_master_password_TF(self, mock_evaluatePassword):
     master_password1 = "test"
     master_password2 = "test"
     mock_evaluatePassword.return_value = [10, 3, True, False]
     valid, safer, message = initiate.check_master_password(master_password1, master_password2)
     self.assertTrue(valid, "This should be valid")
     self.assertFalse(safer, "This should not be safer")
     self.assertEqual(message, "Your password has a security of 10 bits, equivalent to a suitcase lock of 3 digits. Your password has a weak security. Would you like to enter a more complex password?")
Example #5
0
 def test_check_master_password_FF(self, mock_evaluatePassword):
     master_password1 = "test"
     master_password2 = "test"
     mock_evaluatePassword.return_value = [10, 3, False, False]
     valid, safer, message = initiate.check_master_password(master_password1, master_password2)
     self.assertFalse(valid, "This should not be valid")
     self.assertFalse(safer, "This should not be safer")
     self.assertEqual(message, "Your password has a security of 10 bits, equivalent to a suitcase lock of 3 digits. This is not safe. Please try again with a more complex password.")
Example #6
0
 def continue_part1(self):
     valid, safer, message = check_master_password(self.p1, self.p2)
     print(message)
     if not valid:
         self.customPopUp("Invalid password", message, "Close",
                          self._close_popup)
     elif not safer:
         self.customPopUp("Password has a weak security", message,
                          "Enter again", self._close_popup, "Continue",
                          self._close_go_part2)
     else:
         self.continue_part2()