Exemplo n.º 1
0
def createUserCred(cForm, cName, cWord):
    '''
    Function to create a new user
    '''

    newCred = Cred(cForm, cName, cWord)
    return newCred
Exemplo n.º 2
0
 def testSaveMultiCred(self):
     '''
     testSaveMultiUser test checks if we can save multiple credential
     objects to our userList
     '''
     self.newCred.saveCred()
     testCred=Cred("hangout1","anny1","aabc@1")
     testCred.saveCred()
     self.assertEqual(len(Cred.listCred),2)
Exemplo n.º 3
0
 def test_cred_test(self):
     '''
     test to check if we can return a Boolean  if we cannot find the credentials
     '''
     self.new_cred.save_cred()
     test_cred = Cred("TC", "CredTest", "Tcred", "CT1999")
     test_cred.save_cred()
     cred_exists = Cred.cred_exist("CredTest")
     self.assertTrue(cred_exists)
Exemplo n.º 4
0
 def testCheckCredCForm(self):
      '''
      test to check if we can return a Boolean  if we cannot find the platform.
      '''
      self.newCred.saveCred()
      testCred=Cred("hangout1","anny1","aabc@1")
      testCred.saveCred()
      existCForm=Cred.checkCform('hangout1')
      self.assertTrue(existCForm)
Exemplo n.º 5
0
 def test_save_multiple_cred(self):
     '''
     test_save_multiple_cred to check if we can save multiple cred
     objects to our credentials_array
     '''
     self.new_cred.save_cred()
     test_cred = Cred("TC", "CredTest", "Tcred", "CT1999")
     test_cred.save_cred()
     self.assertEqual(len(Cred.credentials_array), 2)
Exemplo n.º 6
0
 def test_gen_password(self):
     '''
     test to check if we can generate a password based on username
     '''
     self.new_cred.save_cred()
     test_cred = Cred("instagram", "*****@*****.**", "Bart-Menz", "")
     test_cred.password = Cred.gen_password("Bart-Menz")
     test_cred.save_cred()
     self.assertTrue(len(test_cred.password) > 2)
Exemplo n.º 7
0
 def testFindCredCForm(self):
      '''
      test to check if we can find a credential by platform
      '''
      self.newCred.saveCred()
      testCred=Cred("hangout1","anny1","aabc@1")
      testCred.saveCred()
      findCForm=Cred.findCredCform('hangout1')
      self.assertEqual(findCForm,'hangout1')
Exemplo n.º 8
0
    def test_delete_contact(self):
            '''
            test_deleteCred to test if we can remove a credential from our credential list
            '''
            self.newCred.saveCred()
            testCred=Cred("hangout1","anny1","aabc@1")
            testCred.saveCred()

            self.newCred.deleteCred()# Deleting a credential object
            self.assertEqual(len(Cred.listCred),1)
Exemplo n.º 9
0
    def test_delete_cred(self):
        '''
        test_delete_cred to test if we can remove a credential from our credentials array
        '''
        self.new_cred.save_cred()
        test_cred = Cred("TC", "CredTest", "Tcred", "CT1999")
        test_cred.save_cred()

        self.new_cred.delete_cred()
        self.assertEqual(len(Cred.credentials_array), 1)
Exemplo n.º 10
0
    def test_find_cred_by_account(self):
        '''
        test to check if we can find credentials by account and display information
        '''

        self.new_cred.save_cred()
        test_cred = Cred("TC", "CredTest", "Tcred", "CT1999")
        test_cred.save_cred()
        found_cred = Cred.find_by_account("TC", "CredTest")
        self.assertEqual(found_cred.account, test_cred.account)
Exemplo n.º 11
0
    def test_cred_exists(self):
        '''
        test to check if we can return a Boolean if we cannot find the user's credentials.
        '''
        self.new_cred.save_cred()
        test_cred = Cred("facebook", "*****@*****.**", "Bart-Menz",
                         "!Bmenz@fb")
        test_cred.save_cred()

        cred_exists = Cred.cred_exists("facebook")
        self.assertTrue(cred_exists)
Exemplo n.º 12
0
    def test_delete_credentials(self):
        '''
        test_delete_credentials to test if we can remove an account from our cred list
        '''
        self.new_cred.save_cred()
        test_cred = Cred("facebook", "*****@*****.**", "Bart-Menz",
                         "!Bmenz@fb")
        test_cred.save_cred()

        self.new_cred.delete_cred()
        self.assertEqual(len(Cred.cred_list), 1)
Exemplo n.º 13
0
    def test_find_cred_by_accountName(self):
        '''
        test to check if we can find a user's credentials by accountName and display information
        '''
        self.new_cred.save_cred()
        test_cred = Cred("facebook", "*****@*****.**", "Bart-Menz",
                         "!Bmenz@fb")
        test_cred.save_cred()

        found_cred = Cred.find_by_accountName("facebook")

        self.assertEqual(found_cred.accountName, test_cred.accountName)
Exemplo n.º 14
0
def main():

    while True:
        print("Please use the following short codes:")
        print("""
        add - Add & save existing accounts, gen - Generate password for new account,
        disp - display accounts, del - Delete account, lo - Log out
        """)

        short_code = input().lower()

        if short_code == 'add':
            print('\n')
            print("Add new account")
            print("-" * 10)

            print("Account Name.....")
            accountName = input()

            print("Email Address.....")
            email = input()

            print("Username.....")
            username = input()

            print("Password.....")
            password = input()

            save_new_cred(Cred(accountName, email, username, password))
            print('\n')
            print(f"Your {accountName} account has successfully been added!")
            print('\n')

        elif short_code == 'gen':
            print('\n')
            print("A random password will be created for this account")
            print("-" * 30)

            print("Account Name.....")
            accountName = input()

            print("Email Address.....")
            email = input()

            print("Username.....")
            username = input()

            password = gen_password(username)
            print(f"Your password is {password}")
            save_new_cred(Cred(accountName, email, username, password))
            print('\n')
            print(f"Your {accountName} account has successfully been added!")
            print('\n')

        elif short_code == 'disp':
            if display_accounts():
                print('\n')
                print("Here is a list of all your accounts")
                print('\n')

                for cred in display_accounts():
                    print(
                        f"{cred.accountName}, {cred.email}, {cred.username}, {cred.password}"
                    )
                    print('\n')
            else:
                print('\n')
                print("You dont seem to have any contacts saved yet")
                print('\n')

        elif short_code == 'del':
            print('\n')
            print("What is the name of the account you want to delete?...")
            accountName = input()
            if find_cred(accountName):
                del_cred(Cred((accountName, email, username, password)))
                print('\n')
                print(
                    f"Your {accountName} account has successfully been deleted!"
                )
                print('\n')

        elif short_code == 'lo':
            print('\n')
            print("Sorry to see you go... Come back soon!")
            print('\n')
            break

        else:
            print('\n')
            print("I really didn't get that. Please use the short codes")
            print('\n')
Exemplo n.º 15
0
def create_cred(username, accnt, uname, pword):
    '''
    Function to create new credentials
    '''
    new_cred = Cred(username, accnt, uname, pword)
    return new_cred
Exemplo n.º 16
0
 def setUp(self):
     '''
     Set up method to run before each test cases.
     '''
     self.new_cred = Cred("Facebook", "*****@*****.**", "Sami-maifb",
                          "@samI!maI4fb")
Exemplo n.º 17
0
 def setUp(self):
     '''
     Set up method to run before each test case.
     '''
     self.new_cred = Cred("IJacco", "Faceb", "IJaccojwang", "I1999")
Exemplo n.º 18
0
def main():
    print("Welcome to PassLocker")
    print("-"*10)

    while True:
        print("Please use the following short codes:")
        print ("su - Sign-up, li - Login, ex - Exit")
        print('\n')
        short_code = input().lower()

        if short_code == 'su':
            print("Sign up to create a PassLocker account")
            print("-"*20)

            print("Fullname.....")
            fullname = input()

            print("Email Address.....")
            email = input()

            print("Username.....")
            username = input()

            print("Password.....")
            password = input()

            save_new_user(User(fullname, email, username, password))
            print('\n')
            print(f"Welcome {username}, your account has successfully been created")
            print ('\n')

        elif short_code == 'li':
            print("Login to your PassLocker account")
            print("-"*20)

            # while True:

            print("Username.....")
            search_user = input()
            if check_existing_user(search_user):
                search_user = find_user(search_user)
                # while True:
                print("Password.....")
                password = input()
                if password == search_user.password:
                    print(f"Welcome {username}, you are logged in!")
                    print ('\n')


                    while True:
                        print("Please use the following short codes:")
                        print("""
                        add - Add & save existing accounts, gen - Generate password for new account,
                        disp - display accounts, del - Delete account, lo - Log out
                        """)

                        short_code = input().lower()

                        if short_code == 'add':
                            print ('\n')
                            print("Add new account")
                            print("-"*10)

                            print("Account Name.....")
                            accountName = input()

                            print("Email Address.....")
                            email = input()

                            print("Username.....")
                            username = input()

                            print("Password.....")
                            password = input()

                            save_new_cred(Cred(accountName, email, username, password))
                            print('\n')
                            print(f"Your {accountName} account has successfully been added!")
                            print ('\n')

                        elif short_code == 'gen':
                            print ('\n')
                            print("A random password will be created for this account")
                            print("-"*30)

                            print("Account Name.....")
                            accountName = input()

                            print("Email Address.....")
                            email = input()

                            print("Username.....")
                            username = input()

                            password = gen_password(username)
                            print(f"Your password is {password}")
                            save_new_cred(Cred(accountName, email, username, password))
                            print('\n')
                            print(f"Your {accountName} account has successfully been added!")
                            print ('\n')

                        elif short_code == 'disp':
                            if display_accounts():
                                print ('\n')
                                print("Here is a list of all your accounts")
                                print('\n')

                                for cred in display_accounts():
                                    print(f"{cred.accountName}, {cred.email}, {cred.username}, {cred.password}")
                                    print('\n')
                            else:
                                print('\n')
                                print("You dont seem to have any contacts saved yet")
                                print('\n')

                        elif short_code == 'del':
                            print ('\n')
                            print("What is the name of the account you want to delete?...")
                            accountName = input()
                            if find_cred(accountName):
                                del_cred(Cred((accountName, email, username, password)))
                                print('\n')
                                print(f"Your {accountName} account has successfully been deleted!")
                                print ('\n')

                        elif short_code == 'lo':
                            print ('\n')
                            print("Sorry to see you go... Come back soon!")
                            print ('\n')
                            break

                        else:
                            print ('\n')
                            print("I really didn't get that. Please use the short codes")
                            print ('\n')
                            # break

                    else:
                        print("Incorrect password")
                        print ('\n')

                else:
                    print(f"{username} does not exist, please sign up.")
        elif short_code == 'ex':
            print("Bye .......")
            break
        else:
            print("I really didn't get that. Please use the short codes")
Exemplo n.º 19
0
 def setUp(self):
     self.newCred=Cred("hangout","anny","aabc@")
     '''
Exemplo n.º 20
0
 def setUp(self):
     '''
     Set up method to run before each test cases.
     '''
     self.new_cred = Cred("*****@*****.**", "123")  # create contact object