Пример #1
0
 def test_generate_password(self):
     '''
     method that returns a list of all accounts saved
     '''
     self.twitter = Credentials('Twitter', 'maryjoe', '')
     self.twitter.password = Credentials.generate_password(8)
     self.assertEqual(len(Credentials.generate_password(8)), 8)
    def test_save_multiple_credentials(self):
        '''
        test_save_many_credentials test case to test if we can save multiple credentials at a time
        '''
        self.new_credential.save_credentials()
        test_credential = Credentials('Gmail','*****@*****.**','seekme')
        test_credential.save_credentials()

        self.assertEqual(len(Credentials.credentials_list),2)
Пример #3
0
 def test_delete_credential(self):
   '''
   Test to remove credential from the credentials list
   '''
   self.new_application.append_application()
   test_credential = Credentials("Twitter","bird") #new credential
   test_credential.append_application()
   self.new_application.delete_credential() #method to delete credential object
   self.assertEqual(len(Credentials.credentials_list),1)
Пример #4
0
 def test_save_multiple_cred(self):
     '''
     test_save_multiple_cred to check if we can save multiple cred
     objects to our cred_list
     '''
     self.new_cred.save_cred()
     test_cred = Credentials('Twitter', 'Mary', 'Aragon')
     test_cred.save_cred()
     self.assertEqual(len(Credentials.cred_list), 2)
Пример #5
0
 def test_delete_cred(self):
     '''
     test_delete_cred to test if we can remove a cred from our cred list
     '''
     self.new_cred.save_cred()
     test_cred = Credentials('Facebook', 'Pope', 'Clement')
     test_cred.save_cred()
     self.new_cred.delete_cred()
     self.assertEqual(len(Credentials.cred_list), 1)
Пример #6
0
 def test_find_cred_by_accountName(self):
     '''
     test to check if we can find a cred by accountName and display information
     '''
     self.new_cred.save_cred()
     test_cred = Credentials('Medium', 'Ferdinand', 'Isabella')
     test_cred.save_cred()
     found_cred = Credentials.find_by_name('Medium')
     self.assertEqual(found_cred.acc, test_cred.acc)
Пример #7
0
 def test_find_contact_by_name(self):
   '''
   Test to check if we can find a credential by the credential name.
   '''
   self.new_application.append_application()
   test_credential = Credentials("Instagram", "gram343") #new credential
   test_credential.append_application()
   found_credential = Credentials.find_credential("Instagram")
   self.assertEqual(found_credential.application_name, test_credential.application_name)
Пример #8
0
 def test_cred_exists(self):
     '''
     test to check if we can return a Boolean  if we cannot find the cred.
     '''
     self.new_cred.save_cred()
     test_cred = Credentials('Medium', 'Ferdinand', 'Isabella')
     test_cred.save_cred()
     cred_exists = Credentials.cred_exists('Medium')
     self.assertTrue(cred_exists)
    def test_find_credentials(self):
        '''
        test_find_credentials test case to test if we can find credentials and display the information
        '''
        self.new_credential.save_credentials()
        test_credential = Credentials('Gmail','*****@*****.**','seekme')
        test_credential.save_credentials()

        found_credentials = Credentials.find_credentials('Gmail')
        self.assertEqual(found_credentials.platform,test_credential.platform)
 def test_delete_credentials(self):
     '''
     test_delete_credentials test case to test if we can remove a credential
     '''
     self.new_credential.save_credentials()
     test_credential = Credentials('Gmail','*****@*****.**','seekme')
     test_credential.save_credentials()
     
     self.new_credential.delete_credentials()
     self.assertEqual(len(Credentials.credentials_list),1)
    def test_credential_exists(self):
        '''
        test_credential_exists test case to test if credentials exists to get True and false otherwise
        '''
        self.new_credential.save_credentials()
        test_credential = Credentials('Gmail','*****@*****.**','seekme')
        test_credential.save_credentials()

        found_credential_exists = Credentials.credential_exists('Gmail')
        self.assertTrue(found_credential_exists)
Пример #12
0
    def test_display_all_accounts(self):
        '''
        method that returns a list of all accounts saved
        '''

        self.assertEqual(Credentials.display_accounts(),
                         Credentials.accounts_list)
Пример #13
0
    def test_init2(self):
        '''
        test case to test if the object is initialized properly
        '''
        self.new_account = Credentials("Twitter", "darknight", "unlock")

        self.assertEqual(self.new_account.account_name, "Twitter")
        self.assertEqual(self.new_account.user_name, "darknight")
        self.assertEqual(self.new_account.key, "unlock")
Пример #14
0
 def test_copy_password(self):
     '''
     test to check if we can return a copy of the saved password.
     '''
     self.new_cred.save_cred()
     test_cred = Credentials('Medium', 'Ferdinand', 'Isabella')
     test_cred.save_cred()
     Credentials.copy_credential_psw('Medium')
     self.assertEqual(pyperclip.paste(), 'Isabella')
     pyperclip.paste()
Пример #15
0
class TestUser(unittest.TestCase):
  '''
  Test class that defines test cases for the user class behaviours
  Args:
    TestCase class that helps in creating new test cases.
  '''

  def setUp(self):
    '''
    Set up method that runs before each taste case, creating the results we expect.
    '''
    self.new_account = User("David","boot")
    self.new_application = Credentials("Facebook", "word")

  def test_initialization(self): 
    '''
    Test initialization case to test if object is initialized properly
    '''
    self.assertEqual(self.new_account.username,"David")
    self.assertEqual(self.new_account.password,"boot")
    self.assertEqual(self.new_application.application_name,"Facebook")
    self.assertEqual(self.new_application.application_password,"word")

  def test_display_credentials(self):
    '''
    Method that returns a list of the credentials saved.
    '''
    self.assertEqual(Credentials.display_applications(), Credentials.credentials_list)

  def test_delete_credential(self):
    '''
    Test to remove credential from the credentials list
    '''
    self.new_application.append_application()
    test_credential = Credentials("Twitter","bird") #new credential
    test_credential.append_application()
    self.new_application.delete_credential() #method to delete credential object
    self.assertEqual(len(Credentials.credentials_list),1)

  def test_find_contact_by_name(self):
    '''
    Test to check if we can find a credential by the credential name.
    '''
    self.new_application.append_application()
    test_credential = Credentials("Instagram", "gram343") #new credential
    test_credential.append_application()
    found_credential = Credentials.find_credential("Instagram")
    self.assertEqual(found_credential.application_name, test_credential.application_name)
Пример #16
0
def new_Password():
    '''
    new_password method to generate a new password
    '''
    auto_password = Credentials.new_password()
    return auto_password
Пример #17
0
class TestCredentials(unittest.TestCase):
    '''
    Test class that  defines test cases for the credentials class behaviours.
    '''
    def setUp(self):
        '''
        Set up method to run before each test cases.
        '''
        self.new_cred = Credentials('Instagram', 'Junius',
                                    'Brutus')  # create credentials object

    def tearDown(self):
        '''
        tearDown method that does clean up after each test case has run.
        '''
        Credentials.cred_list = []

    def test_init(self):
        '''
        test_init test case to test if the object is initialized properly
        '''
        self.assertEqual(self.new_cred.acc, 'Instagram')
        self.assertEqual(self.new_cred.userName, 'Junius')
        self.assertEqual(self.new_cred.credPsw, 'Brutus')

    def test_save_cred(self):
        '''
        test_save_cred test case to test if the cred object is saved into
        the cred list
        '''
        self.new_cred.save_cred()  # saving the new cred
        self.assertEqual(len(Credentials.cred_list), 1)

    def test_save_multiple_cred(self):
        '''
        test_save_multiple_cred to check if we can save multiple cred
        objects to our cred_list
        '''
        self.new_cred.save_cred()
        test_cred = Credentials('Twitter', 'Mary', 'Aragon')
        test_cred.save_cred()
        self.assertEqual(len(Credentials.cred_list), 2)

    def test_delete_cred(self):
        '''
        test_delete_cred to test if we can remove a cred from our cred list
        '''
        self.new_cred.save_cred()
        test_cred = Credentials('Facebook', 'Pope', 'Clement')
        test_cred.save_cred()
        self.new_cred.delete_cred()
        self.assertEqual(len(Credentials.cred_list), 1)

    def test_find_cred_by_accountName(self):
        '''
        test to check if we can find a cred by accountName and display information
        '''
        self.new_cred.save_cred()
        test_cred = Credentials('Medium', 'Ferdinand', 'Isabella')
        test_cred.save_cred()
        found_cred = Credentials.find_by_name('Medium')
        self.assertEqual(found_cred.acc, test_cred.acc)

    def test_cred_exists(self):
        '''
        test to check if we can return a Boolean  if we cannot find the cred.
        '''
        self.new_cred.save_cred()
        test_cred = Credentials('Medium', 'Ferdinand', 'Isabella')
        test_cred.save_cred()
        cred_exists = Credentials.cred_exists('Medium')
        self.assertTrue(cred_exists)

    def test_copy_password(self):
        '''
        test to check if we can return a copy of the saved password.
        '''
        self.new_cred.save_cred()
        test_cred = Credentials('Medium', 'Ferdinand', 'Isabella')
        test_cred.save_cred()
        Credentials.copy_credential_psw('Medium')
        self.assertEqual(pyperclip.paste(), 'Isabella')
        pyperclip.paste()
Пример #18
0
 def test_display_credentials(self):
   '''
   Method that returns a list of the credentials saved.
   '''
   self.assertEqual(Credentials.display_applications(), Credentials.credentials_list)
Пример #19
0
def check_credentials(platform):
    """
    check_credentials method to check if credentials already existed inside that platform and return true or false

    """
    return Credentials.credential_exists(platform)
Пример #20
0
def display_accounts():
    '''
    Function that returns all the saved accounts
    '''
    return Credentials.display_accounts()
Пример #21
0
def find_acc(name):
    '''
    Function that finds an account and returns the account
    '''
    return Credentials.find_by_name(name)
Пример #22
0
def main():
    print("Welcome to your Password_Locker. Proceed to create your account")
    print("New User")
    print("-" * 10)
    print("Username ....")
    username = input()
    print("Password ....")
    password = input()
    id = len(User.user_list) + 1
    save_user(create_user(id, username, password))
    print('\n')
    while True:
        print(f"Welcome {username}. To continue please log in")
        print("Password ....")
        pass_word = input()
        # login_user(username,pass_word)
        if login_user(username, pass_word):
            print(
                "Use these short codes : ca - create a new account, da - display accounts, fa -find an account, cc -copy the password, ex -exit the cred list "
            )
            short_code = input().lower()
            if short_code == 'ca':
                print("New Account")
                print("-" * 10)
                print("Account name ....")
                acc_name = input()
                print("User Name ....")
                userName = input()
                print("Enter preffered password length ....")
                pswLength = int(input())
                password = Credentials.generate_password(pswLength)
                save_acc(create_account(acc_name, userName, password))
                print('\n')
                print(
                    f"New Account for {acc_name} with the username: {userName} has been created successfully"
                )
                print('\n')
            elif short_code == 'da':
                if display_accounts():
                    print("Here is a list of all your accounts")
                    print('\n')
                    for account in display_accounts():
                        print(
                            f"{account.acc} {account.userName} .....{account.credPsw}"
                        )
                        print('\n')
                else:
                    print('\n')
                    print("You dont seem to have any accounts saved yet")
                    print('\n')
            elif short_code == 'fa':
                print("Enter the account name you want to search for")
                search_name = input()
                if check_existing_acc(search_name):
                    search_account = find_acc(search_name)
                    print(f" Account Name:{search_account.acc}")
                    print('-' * 20)
                    print(f"Username.......{search_account.userName}")
                    print(f"Account Password.......{search_account.credPsw}")
                else:
                    print("That Account does not exist")
            elif short_code == 'cc':
                print("Enter the account name you want to copy the password")
                copy_psw = input()
                if check_existing_acc(copy_psw):
                    password_copy = copy_password(copy_psw)
                    print(f"Password for {copy_psw} has been copied")
                    print('-' * 20)
                else:
                    print("That Account does not exist")
            elif short_code == 'ex':
                print('You are now exiting the app ...........')
            else:
                print("I really didn't get that. Please use the short codes")
        else:
            print('Username and password do not match.Please try again ')
Пример #23
0
 def setUp(self):
     '''
     Set up method to run before each test cases.
     '''
     self.new_cred = Credentials('Instagram', 'Junius',
                                 'Brutus')  # create credentials object
Пример #24
0
def copy_credentials(platform):
    """
    copy_credentials class to be able to copy credentials to the clipboard
    """
    return Credentials.copy_credentials(platform)
Пример #25
0
def create_account(account, userName, password):
    '''
    Function to create a new account
    '''
    new_acc = Credentials(account, userName, password)
    return new_acc
Пример #26
0
def create_credential(platform, email, password):
    """
    create_credential method to create new credentials
    """
    new_credential = Credentials(platform, email, password)
    return new_credential
Пример #27
0
def check_existing_acc(name):
    '''
    Function that check if an acc exists with that name and return a Boolean
    '''
    return Credentials.cred_exists(name)
Пример #28
0
def display_credentials():
    """
    display_credentials method to display user's credentials.
    """
    return Credentials.display_credentials()
Пример #29
0
def copy_password(name):
    '''
    Function that copies a specific account's password
    '''
    return Credentials.copy_credential_psw(name)
Пример #30
0
def find_credential(platform):
    """
    find_credential method to find credentials by the platform name and return the credentials that belong to that platform
    """
    return Credentials.find_credentials(platform)