class CredentialTests(unittest.TestCase): def setUp(self): self.cred = Credential() self.cred.loadCredential() def test_db_name(self): self.assertGreater(len(self.cred.dbname), 0) def test_db_user(self): self.assertGreater(len(self.cred.dbuser), 0)
def test_credential_exist(self): ''' Test to check if we can return a boolean if we can't find the credential ''' # Save the new credential self.new_credential.save_credential() test_credential = Credential("doe2","Facebook","facebook17") test_credential.save_credential() # use contact exist method credential_exists = Credential.credential_exist("Facebook") self.assertTrue(credential_exists)
def send_query(self, input_data): try: credentials = Credential() server_address = credentials.server_address() print('\nSending input data to remote tensorflow server at {}'.format(server_address)) channel = grpc.insecure_channel(server_address) predict_service = prediction_service_pb2_grpc.PredictionServiceStub(channel) response = predict_service.Predict( self.prepare_request(input_data), timeout = 10.0 ) print('Response from remote server received') return response except: # if tensorflow server isn't responding, send error report through email and quit program print('\nRemote tensorflow server not responding') return None
def create_credentials(app, app_password): ''' function to create new credential ''' new_credential = Credential(app, app_password) return new_credential
def check_existing_credentials(name): ''' Function that checks if a user credential name already exists Args: name : the credential name ''' return Credential.credential_exist(name)
def test_get_entry_by_path(self): container = self.set_container_hierarchy( self.password_store.get_root(), ["A New Beginning"]) entry = Credential() container.add_credential(entry, u"Entry1") self.assertEqual( (u"Entry1", entry), self.password_store.get_entry_by_path(u"/A New Beginning/Entry1"))
def create_generated_passcode(name): ''' Function that generates a passcode for the user account Args: name : the name of the account ''' passcode = Credential.generate_passcode() return passcode
def generate_password(self, size=8, char=string.ascii_uppercase + string.ascii_lowercase + string.digits): ''' Function to generate an 8 character password for a credential ''' gen_pass = Credential.generate_password() return gen_pass
def test_rename_entry(self): entry_name1 = "Rogue One" entry_name2 = "Rogue Two" self.cut.add_credential(Credential(), name=entry_name1) self.cut.rename_credential(entry_name1, entry_name2) with self.assertRaises(ECNotFoundException): self.cut.remove_credential(entry_name1) self.cut.remove_credential(entry_name2) self.assertEqual(0, self.cut.get_entry_count())
def test_credential_exist(self): ''' Test to check if we can return a boolean if we can't find the credential ''' # Save the new credential self.new_credential.save_credential() test_credential = Credential("fiona","gmail","gmail2020") test_credential.save_credential() # use contact exist method credential_exists = Credential.credential_exist("gmail") self.assertTrue(credential_exists)
def generated_password(pass_length): ''' Function that generate a random password for a user's credential Args: pass_length:Length the user wants the password to be ''' password = Credential.generate_password(pass_length) return password
def create_generated_password(name): ''' Function that generates a password for the user Args: name : the name of the account ''' password = Credential.generate_password() return password
def create_new_prof(profile_name, profile_username=None, profile_email=None, profile_password=None): new_profile = Credential(profile_name, profile_name, profile_username=None, profile_email=None, profile_password=None) return new_profile
def test_display_credential(self): ''' test case for display credential method ''' # Save the new credential self.new_credential.save_credential() test_credential = Credential("doe2", "Facebook", "facebook17") test_credential.save_credential() test_credential = Credential("doe2", "Yahoo", "yahoo17") test_credential.save_credential() self.assertEqual(len(Credential.display_credential("doe2")), 2)
def test_display_credential(self): ''' Test case to test if a user can see a list of all the credentials saved ''' self.new_credential.save_credential() test_credential = Credential("Nyugi2", "Facebook", "kenyan12") test_credential.save_credential() test_credential = Credential("Nyugi2", "Gmail", "kenya1") test_credential.save_credential() self.assertEqual(len(Credential.display_credential("Nyugi2")), 2)
def test_auto_generate_password(self): ''' test auto generate to see if we can generate a password for a user credentials ''' #password length pass_length = 7 #variable to hold the password generated_password = Credential.generate_password(pass_length) self.assertEqual(len(generated_password), pass_length)
class TestCredential(unittest.TestCase): def setUp(self): self.new_credential = Credential("Eid","Eid","12345a","*****@*****.**") # create Account object def test_init(self): self.assertEqual(self.new_credential.credential_name,"Eid") self.assertEqual(self.new_credential.user_name,"Eid") self.assertEqual(self.new_credential.password,"12345a") self.assertEqual(self.new_credential.email,"*****@*****.**") def test_save_credential(self): ''' test to save the credentials ''' self.new_credential.save_credential() # saving the new account self.assertEqual(len(Credential.credential_list),1)
class TestCredential(unittest.TestCase): def setUp(self): self.new_credential = Credential("anthony","muli","123456","*****@*****.**") # create Account object def test_init(self): self.assertEqual(self.new_credential.credential_name,"anthony") self.assertEqual(self.new_credential.user_name,"muli") self.assertEqual(self.new_credential.password,"123456") self.assertEqual(self.new_credential.email,"*****@*****.**") def test_save_credential(self): ''' test to save the credentials ''' self.new_credential.save_credential() # saving the new account self.assertEqual(len(Credential.credential_list),1)
def create_credential(site_name, userName, password, emailUsed): ''' function to create new credential :param site_name: :param userName: :param password: :param emailUsed: :return: ''' new_credential = Credential(site_name, userName, password, emailUsed) return new_credential
def test_display_credential(self): ''' Test case to test if a user can see a list of all the credentials saved ''' # Save the new credential self.new_credential.save_credential() test_credential = Credential("doe2","Facebook","facebook17") test_credential.save_credential() test_credential = Credential("doe2","Yahoo","yahoo17") test_credential.save_credential() self.assertEqual( len(Credential.display_credential("doe2")) , 2 )
def test_display_credential(self): ''' Test case to test if a user can see a list of all the credentials saved ''' # Save the new credential self.new_credential.save_credential() test_credential = Credential("Aggie", "Twitter", "Twitter20") test_credential.save_credential() test_credential = Credential("Aggie", "Facebook20", "Facebook20") test_credential.save_credential() self.assertEqual(len(Credential.display_credential("Aggie")), 2)
def create_credentail(user_password, name, password): ''' Function to create a credential Args: user_password : the password for Password Locker name : the name of the account password : the password for the account ''' new_credentail = Credential(user_password,name,password) return new_credentail
def testDelete_cred(self): ''' this testcase tests if a user can delete a username ''' self.new_cred.save_cred() test_cred = Credential("fb","*****@*****.**","1234") test_cred.save_cred() cred_del = Credential.cred_exist(test_cred.filename) Credential.del_cred(cred_del) self.assertEqual(len(Credential.creds_list),1)
class TestCredential(unittest.TestCase): def setUp(self): """ run before each test """ self.credential = Credential() def tearDown(self): ''' tearDown method that does clean up after each test case has run. ''' pass def test_init(self): ''' test_init test case to test if the object is initialized properly ''' self.assertEqual(self.credential.credentials_list, []) def test_add_new_credential(self): """ test to test whether new credential added has been saved """ self.credential.add_credential("facebook", "*****@*****.**", "password") self.assertEqual(len(self.credential.credentials_list), 1) def test_remove_credential(self): """ test removing credential """ self.credential.add_credential("facebook", "*****@*****.**", "password") self.assertEqual(len(self.credential.credentials_list), 1) self.credential.remove_credential("facebook") self.assertEqual(len(self.credential.credentials_list), 0)
class TestCredential(unittest.TestCase): def setUp(self): self.new_credential = Credential("facebook", "Emerance", "123") def test_init(self): self.assertEqual(self.new_credential.accountName, ("facebook")) self.assertEqual(self.new_credential.username, "Emerance") self.assertEqual(self.new_credential.password, "123") def test_save_credential(self): self.new_credential.save_credential # self.assertEqual(len(Credential.credentials_list),1) def test_delete_credential(self): self.new_credential.save_credential() test_credential = Credential("facebook", "Emerance", "123") test_credential.save_credential self.new_credential.delete_credential() # self.assertEqual(len(Credential.credentials_list),1) def test_findCredential(self): self.new_credential.save_credential() test_credential = Credential("instagram", "Emile", "123") test_credential.save_credential() findCredential = Credential.find_by_accountname("instagram") self.assertEqual(findCredential.password, test_credential.password) def test_displayCredentials(self): self.assertEqual(Credential.display_credentials(), Credential.credentials_list)
def test_copy_credentials(self): """ test copy_credentials to test if a user can be able to copy an item to the clipboard """ test_profile1 = Credential("twitter","Marion","*****@*****.**","testPassword") test_profile1.save_profile() Credential.copy_credentials("twitter") self.assertEqual(test_profile1.profile_password,pyperclip.paste())
def test_copy_credentials(self): """ test copy_credentials to test if a user can be able to copy an item to the clipboard """ test_profile1 = Credential("github","musyoka","*****@*****.**","testPassword") test_profile1.save_profile() Credential.copy_credentials("github") self.assertEqual(test_profile1.profile_password,pyperclip.paste())
def test_delete_profile(self): """ test delete_profile to test if a user can be able to delete a particular profile """ test_profile1 = Credential("github","musyoka","*****@*****.**") test_profile1.save_profile() test_profile1.delete_profile() self.assertEqual(len(Credential.profile_list),0)
def test_delete_profile(self): """ test_delete_profile to test if a user can delete a specific profile """ test_profile1 = Credential("twitter", "Marion", "*****@*****.**") test_profile1.save_profile() test_profile1.delete_profile() self.assertEqual(len(Credential.profile_list), 0)
class TestUser(unittest.TestCase): def setUp(self): """ Set up method to run before each test cases. """ self.new_credential = Credential( "margaret", "royals", "123456", "*****@*****.**") # create Account obj def tearDown(self): """ tearDown method that does clean up after each test case has run. """ Credential.credential_array = [] def test_init(self): """ test_init test case to test if the object is initialized properly """ self.assertEqual(self.new_credential.credential_name, "margaret") self.assertEqual(self.new_credential.usr_name, "royals") self.assertEqual(self.new_credential.password, "123456") self.assertEqual(self.new_credential.email, "*****@*****.**") def test_save_cred(self): """ test_save_cred test case to test if the credential object is saved into the credentials array """ self.new_credential.save_credential() self.assertEqual(len(Credential.credential_array), 1) def test_display_credentials(self): """ method that returns a list of saved credentials """ self.assertEqual(Credential.display_credential(), Credential.credential_array)
def test_display_credential(self): ''' display credential that returns a list of a users credentials ''' self.new_credential.save_credential() test_credential = Credential("Fenamial", "Henry", "Jason", "_Kenneth") test_credential.save_credential() test_credential = test_credential = Credential("Fenamial", "Henry", "Fatandol", "Kenneth") test_credential.save_credential() self.assertEqual( len(Credential.display_credential("Fenamial", "Kenneth")), 2)
def identifier_to_remote_service(self, remote_data_source, generator=None): """Find or randomly create an identifier to use when identifying this patron to a remote service. :param remote_data_source: A DataSource object (or name of a DataSource) corresponding to the remote service. """ _db = Session.object_session(self) def refresh(credential): if generator and callable(generator): identifier = generator() else: identifier = str(uuid.uuid1()) credential.credential = identifier credential = Credential.lookup( _db, remote_data_source, Credential.IDENTIFIER_TO_REMOTE_SERVICE, self, refresh, allow_persistent_token=True ) return credential.credential
'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'pvvopen.wsgi.application' # Database # https://docs.djangoproject.com/en/1.9/ref/settings/#databases credential = Credential() credential.loadCredential() DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': credential.dbname, 'USER': credential.dbuser, } } # Password validation # https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ {
def setUp(self): self.cred = Credential() self.cred.loadCredential()