Esempio n. 1
0
 def change_password_info(self) -> None:
     result = self.find_app_and_username('What is the app whose information you want change?')
     if not result:
         return
     # show password info
     obtain_password(result, False)
     # ask user what should be changed
     # print('\n')
     while True:
         new_data = get_changed_info()
         new_line = list(result)
         for i, key in enumerate(('username', 'email', 'placeholder', 'app_name', 'url')):
             if key in new_data:
                 new_line[i+1] = new_data[key]
         print_info('The following information will be updated in the database:', new_line[1:])
         ans = yes_or_no_question('Do you want to proceed?')
         if ans == 'y':
             self.pm.update_password_data(result[0], new_data)
             print('Information has been updated.')
             return
         else:
             ans2 = yes_or_no_question('Do you want to try again?')
             if ans2 == 'n':
                 print('Updating cancelled.\n')
                 return
Esempio n. 2
0
    def test_print_info(self, capsys, title, info):
        pm_ui_fcns.print_info(title, info)

        email = info[1] if pm_ui_fcns.is_valid_email(info[1]) else '-'

        printed = f'{title}\nUsername: {info[0]}\nPassword: [HIDDEN]\nEmail: {email}\nApp name: {info[3]}\nApp url: {info[4]}\n'

        assert capsys.readouterr()[0] == printed
Esempio n. 3
0
 def delete_password(self) -> None:
     result = self.find_app_and_username('What is the app whose password you want to delete')
     if not result:
         return
     print_info('The following information will be deleted from the database:', result[1:])
     ans = yes_or_no_question('Do you want to delete this information?')
     if ans == 'y':
         self.pm.delete_password(result[0])
         print('Password has been deleted from the database.')
     if ans == 'n':
         print('Delete process cancelled.\n')
Esempio n. 4
0
 def change_password_in_db_or_not(self, db_line: tuple[int, str, str, str, str, str]) -> bool:
     answer = yes_or_no_question('Do you want to save this password to the database?')
     if answer == 'y':
         print_info('The following information will be updated in the database:', db_line[1:])
         answer2 = yes_or_no_question('Do you want to proceed?')
         if answer2 == 'y':
             self.pm.change_password(db_line[0], db_line[3])
             print('Password has been updated.')
             return True
         if answer2 == 'n':
             print('Changing password canceled.')
             return True
     if answer == 'n':
         answer2 = yes_or_no_question('Do you want to generate new password again?')
         if answer2 == 'y':
             return False
         if answer2 == 'n':
             print('Changing password canceled.')
             return True
Esempio n. 5
0
 def save_password_to_db_or_not(self, info: tuple[str, str, str, str, str]) -> bool:
     answer = yes_or_no_question('Do you want to save this password to the database?')
     if answer == 'y':
         print_info('The following information will be saved to the database:', info)
         answer2 = yes_or_no_question('Do you want to proceed?')
         if answer2 == 'y':
             self.pm.force_add_password(*info)
             print(f'Password for user {info[0]} to app {info[3]} has been saved to the database.')
             return True
         if answer2 == 'n':
             answer3 = yes_or_no_question('Do you want to generate password again?')
             if answer3 == 'y':
                 return False
             if answer3 == 'n':
                 print('Adding password canceled.')
                 return True
     if answer == 'n':
         answer2 = yes_or_no_question('Do you want to generate password again?')
         if answer2 == 'y':
             return False
         if answer2 == 'n':
             print('Adding password canceled.')
             return True