示例#1
0
    def test_display_app_credential(self):
        """
        Test to check if we can find a user's credential by the app name and display the information.
        """

        self.new_credential.save_credentials()
        test_credential = Credentials("Snapchat", "test43", "wordpass")
        test_credential.save_credentials()
        found_credential = Credentials.display_app_credential("Snapchat")
        self.assertEqual(found_credential.username, test_credential.username)
示例#2
0
def main():
    print("Hello, welcome to Password Manager")
    while True:
        print("\nPlease use these short codes to execute your desired task: ca - create new account, li - login to account, ex - exit program")
        
        short_code = input().lower().strip()

        if short_code == "ca":
            fname = input("Enter your first name: ").strip()
            lname = input("Enter your last name: ").strip()
            username = input("Enter your preferred username: "******"\nThat username has already been taken. Please enter a different username.")
                username = input("Enter your preferred username: "******"Enter your password: "******"\nYour new account has been created with the following details:\nName: {fname} {lname}\nUsername: {username}\nPassword: {password}\n")

        elif short_code == "li":
            print("\nPlease enter your user details to login.")
            login_username = input("Enter your username: "******"Enter your password: "******"\nHello {login_username}, please use the following codes to select a task.")
                while True:
                    print("\ncc - Create Credentials\ndelc - Delete Credential\ndc -Display Credentials\ndsc - Display Specific Credential\nex - Exit")
                    code = input().lower().strip()

                    if code == "cc":
                        app = input("\nEnter the name of the app: ")
                        credential_username = input("Enter your username: "******"\nUse the following options to select which password you prefer\ncp - Custom Password\nap - Auto-Generated Password\nex - Exit")
                            option = input().lower().strip()

                            if option == "cp":
                                credential_password = input("\nEnter your password: "******"ap":
                                credential_password = Credentials.password()
                                break
                            elif option == "ex":
                                break
                            else:
                                print("\nInvalid input. Check options and try again.")
                    
                        new_credential = create_credentials(app, credential_username, credential_password)
                        new_credential.save_credentials()

                        print(f"\nNewly created credential details:\nApp Name: {app}\nUsername: {credential_username}\nPassword: {credential_password}")

                    elif code == "delc":
                        delete_app = input("\nEnter the app name of the credential you wish to delete: ")
                        Credentials.delete_credential(delete_app)
                        print(f"{delete_app} Credentials has been deleted.")

                    elif code == "dc":
                        if Credentials.display_credentials():
                            for credential in Credentials.display_credentials():
                                print(f"\nApp: {credential.app}\nUsername: {credential.username}\nPassword: {credential.password}\n")
                        else:
                            print("\nYou haven't created any credentials yet.")

                    elif code == "dsc":
                        app_credential = input("\nEnter app name of the credential you wish to be displayed: ")

                        credential_information = Credentials.display_app_credential(app_credential)

                        if credential_information:
                            print(f"\nApp: {credential_information.app}\nUsername: {credential_information.username}\nPassword: {credential_information.password}")
                        else:
                            print("\nThat credential cannot be found. Please try again")
                    
                    elif code == "ex":
                        break
                        
                    else:
                        print("\nInvalid input. Please check the code and try again.")

        elif short_code == "ex":
            break

        else:
            print("\nInvalid input. Please check your entry and try again.")