Ejemplo n.º 1
0
def main():
    print("Safest password locker\n")
    register = welcome()
    print(register)
    print("you can now proceed\n")

    if register:
        login = True
        while login:
            options = int(
                input(
                    "1)create account\n2)view account\n3)delete account\n4)Exit\n"
                ))
            if options == 1:

                account = input("enter account name")

                email = input("enter email")
                num = int(input("length password"))
                password = actual(num)

                Credential(account, password, email)
            elif options == 2:
                Credential.display_account()
            elif options == 3:
                acc = input("which account to delete ? ")
                Credential.delete(acc)
            elif options == 4:
                login = False
Ejemplo n.º 2
0
 def copypasswordTest(self):
     """
   this functions helps to copy password and test if it was successfully copied on clipboard
 """
     self.newAccount.saveAccount()
     Credential.copyPwd('moriinga03')
     self.assertEqual(self.newAccount.l_password, pyperclip.paste())
Ejemplo n.º 3
0
 def test_saveMoreAccount(self):
     """
  this function helps us to save more than one account and test them
 """
     self.newAccount.saveAccount()
     testAccount = Credential("facebook", "hernandez", "moringa02")
     testAccount.saveAccount()
     self.assertEqual(len(Credential.accountList), 2)
Ejemplo n.º 4
0
    def test_save_credentials(self):
        '''
		Test to check if the new credential info is saved into the credentials list
		'''
        self.new_credential.save_credentials()
        account = Credential("shema", "Instagram", "shema")
        account.save_credentials()
        self.assertEqual(len(Credential.credentials_list), 2)
Ejemplo n.º 5
0
 def deleteAccountTest(self):
     """
   this function delete account check if test has passed from account list
 """
     self.newAccount.saveAccount()
     testAccount = Credential("Twitter", "dennishg250", "moriinga03")
     testAccount.saveAccount()
     self.newAccount.deleteAccount()
     self.assertEqual(len(Credential.accountList), 1)
Ejemplo n.º 6
0
 def findByUsername(self):
     """
   function to test account by username
 """
     self.newAccount.saveAccount()
     testAccount = Credential("Pinterest", "Dennis Hg" "momo05")
     testAccount.saveAccount()
     findbyUsername = Credential.findByuser()
     self.assertEqual(findbyUsername.l_username.testAccount.l_username)
Ejemplo n.º 7
0
 def testCheckExistingAccount(self):
     """
   Function to test and check if account exist or not
 """
     self.newAccount.saveAccount()
     testAccount = Credential("Ayoba", "deno", "dano")
     testAccount.saveAccount()
     existingAccount = Credential.existingAccount("Ayoba")
     self.assertTrue(existingAccount)
Ejemplo n.º 8
0
class TestCredentials(unittest.TestCase):
    '''
	Test class that defines test cases for the credentials class behaviours.
	Args:
	    unittest.TestCase: helps in creating test cases
	'''
    def test_check_user(self):
        '''
		Function to test whether the login in function check_user works as expected
		'''
        self.new_user = User("", "", "", "")
        self.new_user.save_user()
        user2 = User("", "", "", "")
        user2.save_user()

        for user in User.user_list:
            if user.first_name == user2.first_name and user.password == user2.password:
                current_user = user.first_name
        return current_user

        self.assertEqual(
            current_user,
            Credential.check_user(user2.password, user2.first_name))

    def setUp(self):
        '''
		Function to create an account's credentials before each test
		'''
        self.new_credential = Credential("Nancy", "Twitter", "nancy")

    def test__init__(self):
        '''
		Test to if check the initialization/creation of credential instances is properly done
		'''
        self.assertEqual(self.new_credential.user_name, 'Nancy')
        self.assertEqual(self.new_credential.site_name, 'Twitter')

        self.assertEqual(self.new_credential.password, 'nancy')

    def test_save_credentials(self):
        '''
		Test to check if the new credential info is saved into the credentials list
		'''
        self.new_credential.save_credentials()
        account = Credential("shema", "Instagram", "shema")
        account.save_credentials()
        self.assertEqual(len(Credential.credentials_list), 2)
Ejemplo n.º 9
0
    def test_check_user(self):
        '''
		Function to test whether the login in function check_user works as expected
		'''
        self.new_user = User("", "", "", "")
        self.new_user.save_user()
        user2 = User("", "", "", "")
        user2.save_user()

        for user in User.user_list:
            if user.first_name == user2.first_name and user.password == user2.password:
                current_user = user.first_name
        return current_user

        self.assertEqual(
            current_user,
            Credential.check_user(user2.password, user2.first_name))
Ejemplo n.º 10
0
def rema_konti(konti, username, password):
    '''
    Function to create a new credential
    '''
    account = Credential(konti, username, password)
    return account
Ejemplo n.º 11
0
def check_existing_credential(string):
    '''
    Function that check if credential exists
    '''
    return Credential.genzura_neza_konti(string)
Ejemplo n.º 12
0
    def setUp(self):
        '''
		Function to create an account's credentials before each test
		'''
        self.new_credential = Credential("Nancy", "Twitter", "nancy")
Ejemplo n.º 13
0
def pwd_random(creds):
    """
    generating a random password
  """
    pwd = Credential.pwd_random(creds)
    return pwd
Ejemplo n.º 14
0
def display_credential():
    '''
    Function that returns all the saved credentials
    '''
    return Credential.konti_zose()
Ejemplo n.º 15
0
def findAll():
    """
    display all account
  """
    return Credential.findAll()
Ejemplo n.º 16
0
def existingAccount(creds):
    """
    checks exist account credential
  """
    return Credential.existingAccount(creds)
Ejemplo n.º 17
0
def createAccount(accountName, l_username, l_password):
    """
    function to create new account
  """
    newAccount = Credential(accountName, l_username, l_password)
    return newAccount
Ejemplo n.º 18
0
def findByusername(creds):
    """
    find account by username
  """
    return Credential.findByusername(creds)
Ejemplo n.º 19
0
 def setUp(self):
     """
   set up function to run before each test
 """
     self.newAccount = Credential("Instagram", "dennis_250", "moringa01")
Ejemplo n.º 20
0
def search_credential(string):
    '''
    Function that searchs credential
    '''
    return Credential.search_konti(string)
Ejemplo n.º 21
0
 def findallTest(self):
     """
   Function to test if we can find all accounts registered
 """
     self.assertEqual(Credential.findAll(), Credential.accountList)
Ejemplo n.º 22
0
 def randomPwdGenerate(self):
     """
   Function to generate random password
 """
     random = Credential.pwd_random()
     self.assertTrue(random)
Ejemplo n.º 23
0
class TestAccount(unittest.TestCase):
    """
    Test class defines test cases for credentials class behaviours
    Args: 
      unittest.Testcase this class will helps creating cases
  """
    def setUp(self):
        """
      set up function to run before each test
    """
        self.newAccount = Credential("Instagram", "dennis_250", "moringa01")

    def test_init(self):
        """
      this function is all about initial save test them if are properly initializeed
    """
        self.assertEqual(self.newAccount.accountName, "Instagram")
        self.assertEqual(self.newAccount.l_username, "dennis_250")
        self.assertEqual(self.newAccount.l_password, "moringa01")

    def test_saveAccount(self):
        """
      this is about save account and test them using account list
    """
        self.newAccount.saveAccount()
        self.assertEqual(len(Credential.accountList), 1)

    def tearDown(self):
        Credential.accountList = []

    def test_saveMoreAccount(self):
        """
     this function helps us to save more than one account and test them
    """
        self.newAccount.saveAccount()
        testAccount = Credential("facebook", "hernandez", "moringa02")
        testAccount.saveAccount()
        self.assertEqual(len(Credential.accountList), 2)

    def deleteAccountTest(self):
        """
      this function delete account check if test has passed from account list
    """
        self.newAccount.saveAccount()
        testAccount = Credential("Twitter", "dennishg250", "moriinga03")
        testAccount.saveAccount()
        self.newAccount.deleteAccount()
        self.assertEqual(len(Credential.accountList), 1)

    def copypasswordTest(self):
        """
      this functions helps to copy password and test if it was successfully copied on clipboard
    """
        self.newAccount.saveAccount()
        Credential.copyPwd('moriinga03')
        self.assertEqual(self.newAccount.l_password, pyperclip.paste())

    def randomPwdGenerate(self):
        """
      Function to generate random password
    """
        random = Credential.pwd_random()
        self.assertTrue(random)

    def findallTest(self):
        """
      Function to test if we can find all accounts registered
    """
        self.assertEqual(Credential.findAll(), Credential.accountList)

    def testCheckExistingAccount(self):
        """
      Function to test and check if account exist or not
    """
        self.newAccount.saveAccount()
        testAccount = Credential("Ayoba", "deno", "dano")
        testAccount.saveAccount()
        existingAccount = Credential.existingAccount("Ayoba")
        self.assertTrue(existingAccount)

    def findByUsername(self):
        """
      function to test account by username
    """
        self.newAccount.saveAccount()
        testAccount = Credential("Pinterest", "Dennis Hg" "momo05")
        testAccount.saveAccount()
        findbyUsername = Credential.findByuser()
        self.assertEqual(findbyUsername.l_username.testAccount.l_username)