コード例 #1
0
    def test_account_exist(self):
        self.user_details.register()
        test_userDetails = User("Test", "user", "gmail.com")
        test_userDetails.register()

        account_exist = User.account_exist("Test")
        self.assertTrue(account_exist)
コード例 #2
0
    def test_delete_password(self):
        self.user_details.register()
        test_userDetails = User("Test", "user", "gmail.com")
        test_userDetails.register()

        self.user_details.delete_password()
        self.assertEqual(len(User.user_details), 1)
コード例 #3
0
    def test_find_by_accountName(self):
        self.user_details.register()
        test_userDetails = User("Test", "user", "gmail.com")
        test_userDetails.register()

        found_account = User.find_by_accountName("Test")
        self.assertEqual(found_account.username, test_userDetails.username)
コード例 #4
0
 def setUp(self):
     """
         This is a set up function that runs every time before each test clauses
     """
     #checks if there is data in our list
     self.user_details = User("rustique254", "uwimpaye250",
                              "*****@*****.**")
コード例 #5
0
 def test_user_exists(self):
     """
     test_check_user_exists to test if a user exists or not
     """
     self.new_user.save_user()
     test_user = User("victor maina","*****@*****.**","grooviq","254groove")
     test_user.save_user()
     user_exists = User.user_exists("grooviq")
     self.assertTrue(user_exists)
コード例 #6
0
ファイル: run.py プロジェクト: grooviq/password
def check_existing_user(username):
    """
    Function that check if a user exists & login details
    """
    return User.user_exists(username)
コード例 #7
0
 def test_display_all_pass(self):
     self.assertEqual(User.display_user(), User.user_details)
コード例 #8
0
class UserTest(unittest.TestCase):
    def tearDown(self):
        '''
        This function ensures that each time the test runs it runs afresh without memory of previous details
        '''
        User.user_details = []

    def setUp(self):
        """
            This is a set up function that runs every time before each test clauses
        """
        #checks if there is data in our list
        self.user_details = User("rustique254", "uwimpaye250",
                                 "*****@*****.**")

    def test_init(self):
        self.assertEqual(self.user_details.username, "rustique254")
        self.assertEqual(self.user_details.password, "uwimpaye250")
        self.assertEqual(self.user_details.email, "*****@*****.**")

    def test_register(self):
        self.user_details.register()
        self.assertEqual(len(User.user_details), 1)

    def test_save_user_details(self):
        self.user_details.register()
        test_userDetails = User("Test", "user", "gmail.com")
        test_userDetails.register()
        self.assertEqual(len(User.user_details), 2)
        #delete password test
    def test_delete_password(self):
        self.user_details.register()
        test_userDetails = User("Test", "user", "gmail.com")
        test_userDetails.register()

        self.user_details.delete_password()
        self.assertEqual(len(User.user_details), 1)

    #find user credentials by account name
    def test_find_by_accountName(self):
        self.user_details.register()
        test_userDetails = User("Test", "user", "gmail.com")
        test_userDetails.register()

        found_account = User.find_by_accountName("Test")
        self.assertEqual(found_account.username, test_userDetails.username)

    '''
    method to check if account exist
    '''

    def test_account_exist(self):
        self.user_details.register()
        test_userDetails = User("Test", "user", "gmail.com")
        test_userDetails.register()

        account_exist = User.account_exist("Test")
        self.assertTrue(account_exist)

    #method to display all account password
    def test_display_all_pass(self):
        self.assertEqual(User.display_user(), User.user_details)
コード例 #9
0
ファイル: run.py プロジェクト: kipkemoimayor/PasswordLocker
def display_passwords():
    return User.display_user()
コード例 #10
0
ファイル: run.py プロジェクト: grooviq/password
def create_user(fullname, email, username, password):
    """
    Function to create a new user
    """
    new_user = User(fullname, email, username, password)
    return new_user
コード例 #11
0
 def setUp(self):
     """
         This is a set up function that runs every time before each test clauses
     """
     #checks if there is data in our list
     self.user_details = User("collins24", "ki154", "*****@*****.**")
コード例 #12
0
 def setUp(self):
     """
     set up method to run each test case
     """
     self.new_user = User("victor maina","*****@*****.**","grooviq","254groove")
コード例 #13
0
ファイル: run.py プロジェクト: kipkemoimayor/PasswordLocker
def register(username, password, accountName):
    user_details = User(username, password, accountName)
    return user_details
コード例 #14
0
ファイル: run.py プロジェクト: kipkemoimayor/PasswordLocker
def check_if_accountExist(number):
    return User.account_exist(number)
コード例 #15
0
ファイル: run.py プロジェクト: kipkemoimayor/PasswordLocker
def search_accountPassword(number):
    return User.find_by_accountName(number)
コード例 #16
0
ファイル: run.py プロジェクト: grooviq/password
def find_user(username):
    """
    Function that finds a user by username
    """
    return User.find_by_username(username)
コード例 #17
0
ファイル: run.py プロジェクト: grooviq/password
def create_cred(accountName, email, username, password):
    """
    Function to create new credentials
    """
    new_cred = User(accountName, email, username, password)
    return new_cred
コード例 #18
0
 def test_save_user_details(self):
     self.user_details.register()
     test_userDetails = User("Test", "user", "gmail.com")
     test_userDetails.register()
     self.assertEqual(len(User.user_details), 2)
コード例 #19
0
ファイル: run.py プロジェクト: grooviq/password
def main():
    print("Welcome to Password Locker")
    print("-" * 10)

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

        if short_code == 'si':
            print("Sign up to create a Password Locker 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 == 'lo':
            print("Login to your Password Locker account")
            print("-" * 20)

            # while True:

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

                    while True:
                        print("Please use the following short codes:")
                        print("""
                        add - Add to save new account's credentials, gen - Generate password for new account,
                        disp - display already saved accounts, del - Delete existing account, lt - 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(
                                Credential(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(
                                Credential(accountName, email, username,
                                           password))
                            print('\n')
                            print(
                                f"Your {accountName} account addition successful!"
                            )
                            print('\n')

                        elif short_code == 'disp':
                            if display_accounts():
                                print('\n')
                                print("Here are your saved 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 have any contacts saved yet")
                                print('\n')

                        elif short_code == 'del':
                            print('\n')
                            print(
                                "type in name of account you want deleted...")
                            accountName = input()
                            if find_cred(accountName):
                                del_cred = input()
                                print('\n')
                                print(
                                    f"Your {accountName} account has been deleted successfully!"
                                )
                                print('\n')

                        elif short_code == 'lt':
                            print('\n')
                            print("bye-bye")
                            print('\n')
                            break

                        else:
                            print('\n')
                            print("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("\n")
            print("..Exiting..")
            print("\n")
            break
        else:
            print("Please use the short codes")
コード例 #20
0
ファイル: run.py プロジェクト: kipkemoimayor/PasswordLocker
def deletepassword(username, password, email):
    user_details = User(username, password, email)
    return user_details