def test_add_mutliple_credentials(self):
     '''
     test case for add credentials logic
     '''
     self.new_credentials.add_credentials()
     test_credentials = Credentials("Twitter", "Moringa", "123r")
     test_credentials.add_credentials()
     self.assertEqual(len(Credentials.credentials_list), 2)
Example #2
0
 def test_add_multiple_credentials(self):
     '''
     test_add_multiple_credentials to check if we can save multiple credential objects to our credentials list
     '''
     self.new_credentials.add_credentials()
     test_credentials = Credentials("Instagram", "King", "01")
     test_credentials.add_credentials()
     self.assertEqual(len(Credentials.credentials_list), 2)
Example #3
0
 def test_add_multiple_credentials(self):
     '''
     test_create_multiple_credentials to check if we can create multiple credentials
     objects to our credentials list
     '''
     self.new_account.add_credentials()
     test_credentials = Credentials("Github", "John", "Doe")
     test_credentials.add_credentials()
     self.assertEqual(len(Credentials.credentials_list),2)
Example #4
0
 def test_add_multiple_credentials(self):
     '''
     test_create_multiple_credentials to check if we can create multiple credentials
     objects to our credentials list
     '''
     self.new_account.add_credentials()
     test_credentials = Credentials("Git", "EmmmaKibore", "AisaJemila")
     test_credentials.add_credentials()
     self.assertEqual(len(Credentials.credentials_list), 2)
Example #5
0
 def test_delete_credentials(self):
     '''
     test_delete_credentials to test if we can remove an account's credentials from our credentials list
     '''
     self.new_account.add_credentials()
     test_credentials = Credentials("Git", "EmmmaKibore", "AisaJemila")
     test_credentials.add_credentials()
     self.new_account.delete_credentials()
     self.assertEqual(len(Credentials.credentials_list), 1)
Example #6
0
 def test_delete_credentials(self):
     '''
     test_delete_credentials to test if we can remove an account's credentials from our credentials list
     '''
     self.new_account.add_credentials()
     test_credentials = Credentials("Github", "John", "Doe")
     test_credentials.add_credentials()
     self.new_account.delete_credentials("Github")
     self.assertEqual(len(Credentials.credentials_list),1)
    def test_search__app_name(self):
        '''
        test case for searching app by name
        '''
        self.new_credentials.add_credentials()
        test_credentials = Credentials("Instagram", "Burence", "Br1")
        test_credentials.add_credentials()

        found_credentials = Credentials.search_app_name("Instagram")
        self.assertEqual(found_credentials.app_name, test_credentials.app_name)
Example #8
0
    def test_delete_credentials(self):
        '''
        test_delete_credentials to test if we can remove a credential from credentials list
        '''
        self.new_credentials.add_credentials()
        test_credentials = Credentials("Instagram", "King", "01")
        test_credentials.add_credentials()

        test_credentials.delete_credentials()
        self.assertEqual(len(Credentials.credentials_list), 1)
Example #9
0
    def test_find_by_application_name(self):
        '''
        test to check if we can find a credentials by application name
        '''
        self.new_credentials.add_credentials()
        test_credentials = Credentials("Instagram", "Alfred", "101")
        test_credentials.add_credentials()

        found_credential = Credentials.find_by_application_name("Instagram")
        self.assertEqual(found_credential.account_username, test_credentials.account_username)
    def test_credentials_exist(self):
        '''
        test case for confirming credentials that exist
        '''
        self.new_credentials.add_credentials()
        test_credentials = Credentials("Instagram", "Burence", "Br1")
        test_credentials.add_credentials()

        credential_exist = Credentials.credentials_exist("Instagram")
        self.assertTrue(credential_exist)
Example #11
0
    def test_credentials_exist(self):
        ''' 
        test to check if we can return boolean if credential exist or not
        '''
        self.new_credentials.add_credentials()
        test_credentials = Credentials("Instagram", "King", "01")
        test_credentials.add_credentials()

        credentials_exist = Credentials.credentials_exist("Instagram")
        self.assertTrue(credentials_exist)
    def test_delete_credentials(self):
        '''
        test case for delete credentials logic
        '''

        self.new_credentials.add_credentials()
        test_credentials = Credentials("Instagram", "Burence", "Br1")
        test_credentials.add_credentials()

        test_credentials.delete_credentials()
        self.assertEqual(len(Credentials.credentials_list), 1)
Example #13
0
    def test_find_by_account(self):
        '''
        test_find_credentials_by_account to check if we can find an account's credentials by account name and display information
        '''
        self.new_account.add_credentials()
        test_credentials = Credentials("Github", "John", "Doe")
        test_credentials.add_credentials()

        searched_account = Credentials.find_by_account("Github")

        self.assertEqual(searched_account.account_name, test_credentials.account_name)
Example #14
0
    def test_find_by_account(self):
        '''
        test_find_credentials_by_account to check if we can find an account's credentials by account name and display information
        '''
        self.new_account.add_credentials()
        test_credentials = Credentials("Git", "EmmmaKibore", "AisaJemila")
        test_credentials.add_credentials()

        searched_account = Credentials.find_by_account("Git")

        self.assertEqual(searched_account.account_name,
                         test_credentials.account_name)
Example #15
0
 def test_adding_credentials(self):
     '''
     test if a user can add credentials to a certain site
     '''
     
     new_credentails = Credentials.add_credentials()
     self.assertTrue(new_credentails)
Example #16
0
class TestLocker(unittest.TestCase):
    """
    Test class that defines test cases for the contact class behaviours.

    Args:
        unittest.TestCase: TestCase class that helps in creating test cases
    """

    def setUp(self):
        '''
        Set up method to run before each test cases.
        '''
        self.new_user = User("JamesMutahi", "12139lenana**")

        self.new_account = Credentials("GitHub", "JamesMutahi", "12139**")

    def tearDown(self):
        '''
        does clean up/ destroys entries after each test case has run.
        '''

        User.user_list = []
        Credentials.credentials_list = []

    def test_init(self):
        '''
        test_init test case to test if the object is initialized properly
        '''

        self.assertEqual(self.new_user.user_name, "JamesMutahi")
        self.assertEqual(self.new_user.password, "12139lenana**")
        self.assertEqual(self.new_account.account_name, "GitHub")
        self.assertEqual(self.new_account.account_user_name, "JamesMutahi")
        self.assertEqual(self.new_account.account_password, "12139**")

    def test_create_user(self):
        '''
        test_create_user test case to test if the user object is saved into the user list
        '''
        self.new_user.create_user()
        self.assertEqual(len(User.user_list),1)

    def test_add_credentials(self):
        '''
        test_add_credentials test case to test if the credentials object is saved into
         the credentials list
        '''
        self.new_account.add_credentials()
        self.assertEqual(len(Credentials.credentials_list),1)

    def test_create_multiple_users(self):
        '''
        test_create_multiple_users to check if we can create multiple user
        objects to our user list
        '''
        self.new_user.create_user()
        test_user = User("John", "Doe")
        test_user.create_user()
        self.assertEqual(len(User.user_list),2)

    def test_add_multiple_credentials(self):
        '''
        test_create_multiple_credentials to check if we can create multiple credentials
        objects to our credentials list
        '''
        self.new_account.add_credentials()
        test_credentials = Credentials("Github", "John", "Doe")
        test_credentials.add_credentials()
        self.assertEqual(len(Credentials.credentials_list),2)

    def test_delete_credentials(self):
        '''
        test_delete_credentials to test if we can remove an account's credentials from our credentials list
        '''
        self.new_account.add_credentials()
        test_credentials = Credentials("Github", "John", "Doe")
        test_credentials.add_credentials()
        self.new_account.delete_credentials("Github")
        self.assertEqual(len(Credentials.credentials_list),1)

    def test_find_by_account(self):
        '''
        test_find_credentials_by_account to check if we can find an account's credentials by account name and display information
        '''
        self.new_account.add_credentials()
        test_credentials = Credentials("Github", "John", "Doe")
        test_credentials.add_credentials()

        searched_account = Credentials.find_by_account("Github")

        self.assertEqual(searched_account.account_name, test_credentials.account_name)

    def test_display_all_credentials(self):
        '''
        returns a list of all credentials saved
        '''
        self.assertEqual(Credentials.display_all_accounts(),Credentials.credentials_list)
Example #17
0
def account_management():
    global login_status
    
    global satisfactory_password
 
    
    while login_status == False:
        '''
        facilitating account creation and log in
        '''
        
        first_response = int(input('''Hello, Respond with:  
                                1 to create an account. 
                                2 to login into an existing account.
                                                '''))    
        '''
        global variable to store the first response of the user on whether he/she wants to create an account or log 
        into an existing one
        '''
    
        if first_response == 1:
                
            '''
            function to run when the user does not have an account with us
            '''
            while authentic_username == False:    
                creating_an_account()  
            '''
            loop as long as the username of the account created is not authentic i.e has been used before
            '''


        elif(first_response == 2):
            
            '''
            Function to login if the user already has an account
            '''
            loging_in()

        else:
            print('invalid response')
    
    if login_status == True:
    
        while login_status == True:
            second_response = int(input('''Choose an option from the following : 
                                        1 => to add a new site and input your own passowrd.
                                        2 => to add a new site but let the app generate the password for you.
                                        3 => to search site passwords by sitename.
                                        4 => to display all sites and their passords.
                                        5 => to delete a site you no longer use.
                                        6 => to log out of your account.
                                                      '''))
            
            satisfactory_password = False
            
            if second_response == 1:
                new_credentials = Credentials.add_credentials()
                new_credentials.save_credentials()
                print(f"You have successfully added your new site credentials ")   
            
            
            elif second_response == 2:
                '''
                to generate a user's passord automaticaly
                '''
                
                while satisfactory_password == False:
                    new_credentials = Credentials.generate_random_password()
                    password_generation_response = int(input('''Respond with:
                        1 => If you are Ok with the password
                        2 => If you are not Ok with the password and would like another one to be generated for you
                        3 => If you would like to go back to the main menu and input a password of your own
                                                '''))
                    if password_generation_response == 1:
                        new_credentials.save_credentials()
                        print(f"You have successfully added your new site credentials ")
                        satisfactory_password = True
                    
                    elif password_generation_response == 2:
                        continue
                    
                    elif password_generation_response == 3:
                        satisfactory_password = True
                    else:
                        print("invalide response please sselect an option once more")  
            
            elif second_response == 3:
                
                found_credentials = Credentials.find_credentials()
                
                if found_credentials != None:
                
                    pyperclip.copy(found_credentials)    
                else:
                    print('The site you entered does not exist in our database')
            elif second_response == 4:
                credential_list = Credentials.display_credentials()
                
                for credential in credential_list:
                    print(f"{credential.site_name} Account Password = {credential.site_password}")     
            
            elif second_response == 5:
                site_deleting = input("Enter the site name of the site you want to delete")
                site_to_be_deleted = site_deleting.find_credentials
                site_to_be_deleted.delete_account()
                print("Site success fully deleted")
                        
            elif second_response == 6:
                print("Thank you and see you later!")
                login_status = False    
            
            else:
                print ("Invalide Response! Please try once more")
Example #18
0
class TestLocker(unittest.TestCase):
    """
    Test class that defines test cases for the contact class behaviours.

    Args:
        unittest.TestCase: TestCase class that helps in creating test cases
    """
    def setUp(self):
        '''
        Set up method to run before each test cases.
        '''
        self.new_user = User("eddyyonnie", "neurosurge0n")

        self.new_account = Credentials("GitHub", "eddyyonnie", "neurosurge0n")

    def tearDown(self):
        '''
        tearDown method that does clean up after each test case has run.
        '''

        User.user_list = []
        Credentials.credentials_list = []

    def test_init(self):
        '''
        test_init test case to test ......{search_account.account_user_name}")
                                            print(f"Password.......{search_account.account_password}")
                                    else:
                                            print('-'*10)if the object is initialized properly
        '''

        self.assertEqual(self.new_user.user_name, "eddyyonnie")
        self.assertEqual(self.new_user.password, "neurosurge0n")
        self.assertEqual(self.new_account.account_name, "GitHub")
        self.assertEqual(self.new_account.account_user_name, "eddyyonnie")
        self.assertEqual(self.new_account.account_password, "neurosurge0n")

    def test_create_user(self):
        '''
        test_create_user test case to test if the user object is saved into
         the user list
        '''
        self.new_user.create_user()
        self.assertEqual(len(User.user_list), 1)

    def test_add_credentials(self):
        '''
        test_add_credentials test case to test if the credentials object is saved into
         the credentials list
        '''
        self.new_account.add_credentials()
        self.assertEqual(len(Credentials.credentials_list), 1)

    def test_create_multiple_users(self):
        '''
        test_create_multiple_users to check if we can create multiple user
        objects to our user list
        '''
        self.new_user.create_user()
        test_user = User("EmmmaKibore", "AisaJemila")
        test_user.create_user()
        self.assertEqual(len(User.user_list), 2)

    def test_add_multiple_credentials(self):
        '''
        test_create_multiple_credentials to check if we can create multiple credentials
        objects to our credentials list
        '''
        self.new_account.add_credentials()
        test_credentials = Credentials("Git", "EmmmaKibore", "AisaJemila")
        test_credentials.add_credentials()
        self.assertEqual(len(Credentials.credentials_list), 2)

    def test_delete_credentials(self):
        '''
        test_delete_credentials to test if we can remove an account's credentials from our credentials list
        '''
        self.new_account.add_credentials()
        test_credentials = Credentials("Git", "EmmmaKibore", "AisaJemila")
        test_credentials.add_credentials()
        self.new_account.delete_credentials()
        self.assertEqual(len(Credentials.credentials_list), 1)

    def test_find_by_account(self):
        '''
        test_find_credentials_by_account to check if we can find an account's credentials by account name and display information
        '''
        self.new_account.add_credentials()
        test_credentials = Credentials("Git", "EmmmaKibore", "AisaJemila")
        test_credentials.add_credentials()

        searched_account = Credentials.find_by_account("Git")

        self.assertEqual(searched_account.account_name,
                         test_credentials.account_name)

    def test_display_all_credentials(self):
        '''
        method that returns a list of all credentials saved
        '''
        self.assertEqual(Credentials.display_all_accounts(),
                         Credentials.credentials_list)
Example #19
0
class TestCredentials(unittest.TestCase):
    '''
    Test class that defines test cases for Credentials class behaviours
    
    Args:
        unittest.TestCase: TestCase class that  helps in creating test cases
    '''
    def setUp(self):
        '''
        Set up method to run before each test cases
        '''
        self.new_credentials = Credentials("Twitter", "Kingori", "01")

    def test_initialization(self):
        '''
        Test initialization test case to test if the object is initialized properly
        '''
        self.assertEqual(self.new_credentials.application_name, "Twitter")
        self.assertEqual(self.new_credentials.account_username, "Kingori")
        self.assertEqual(self.new_credentials.account_password, "01")

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

    def test_add_multiple_credentials(self):
        '''
        test_add_multiple_credentials to check if we can save multiple credential objects to our credentials list
        '''
        self.new_credentials.add_credentials()
        test_credentials = Credentials("Instagram", "King", "01")
        test_credentials.add_credentials()
        self.assertEqual(len(Credentials.credentials_list), 2)

    def test_delete_credentials(self):
        '''
        test_delete_credentials to test if we can remove a credential from credentials list
        '''
        self.new_credentials.add_credentials()
        test_credentials = Credentials("Instagram", "King", "01")
        test_credentials.add_credentials()

        test_credentials.delete_credentials()
        self.assertEqual(len(Credentials.credentials_list), 1)

    def test_display_all_credentials(self):
        '''
        test method that returns a list of all credentials saved
        '''
        self.assertEqual(Credentials.display_credentials(),
                         Credentials.credentials_list)

    def test_find_by_application_name(self):
        '''
        test to check if we can find a credentials by application name
        '''
        self.new_credentials.add_credentials()
        test_credentials = Credentials("Instagram", "King", "01")
        test_credentials.add_credentials()

        found_credential = Credentials.find_by_application_name("Instagram")
        self.assertEqual(found_credential.account_username,
                         test_credentials.account_username)

    def test_credentials_exist(self):
        ''' 
        test to check if we can return boolean if credential exist or not
        '''
        self.new_credentials.add_credentials()
        test_credentials = Credentials("Instagram", "King", "01")
        test_credentials.add_credentials()

        credentials_exist = Credentials.credentials_exist("Instagram")
        self.assertTrue(credentials_exist)
class TestCredentials(unittest.TestCase):
    '''
      class that defines TestCredentials' test cases

      Args:
      unittest.TestCase: aids in creating new testcases.
      '''
    def setUp(self):
        '''
        runs before every test case
        '''

        self.new_credentials = Credentials("Instagram", "Burence", "Br1")

    def test_init(self):
        '''
        test for testing proper object initialization
        '''

        self.assertEqual(self.new_credentials.app_name, "Instagram")
        self.assertEqual(self.new_credentials.acc_username, "Burence")
        self.assertEqual(self.new_credentials.acc_password, "Br1")

    def tearDown(self):
        '''
        test case to clear credentials list after every test has run
        '''
        Credentials.credentials_list = []

    def test_add_mutliple_credentials(self):
        '''
        test case for add credentials logic
        '''
        self.new_credentials.add_credentials()
        test_credentials = Credentials("Twitter", "Moringa", "123r")
        test_credentials.add_credentials()
        self.assertEqual(len(Credentials.credentials_list), 2)

    def test_display_credentials(self):
        '''
        test case for displaying user's credentials
        '''

        self.assertEqual(Credentials.credentials_list,
                         Credentials.display_credentials())

    def test_credentials_exist(self):
        '''
        test case for confirming credentials that exist
        '''
        self.new_credentials.add_credentials()
        test_credentials = Credentials("Instagram", "Burence", "Br1")
        test_credentials.add_credentials()

        credential_exist = Credentials.credentials_exist("Instagram")
        self.assertTrue(credential_exist)

    def test_search__app_name(self):
        '''
        test case for searching app by name
        '''
        self.new_credentials.add_credentials()
        test_credentials = Credentials("Instagram", "Burence", "Br1")
        test_credentials.add_credentials()

        found_credentials = Credentials.search_app_name("Instagram")
        self.assertEqual(found_credentials.app_name, test_credentials.app_name)

    def test_delete_credentials(self):
        '''
        test case for delete credentials logic
        '''

        self.new_credentials.add_credentials()
        test_credentials = Credentials("Instagram", "Burence", "Br1")
        test_credentials.add_credentials()

        test_credentials.delete_credentials()
        self.assertEqual(len(Credentials.credentials_list), 1)