def __init__(self, cb): self.cb = cb self.credentials = Credentials() self.commands = Dudes() self.token_str = self.credentials.read(num) self.liveChatID = self.get_livechat_id() self.stopped = False self.prefix = '-' if not self.liveChatID: print("[] No livestream found :(") self.stopped = True else: print("Live Chat ID", self.liveChatID)
def test_delete_credentials(self): ''' test_delete_credentials to test if we can remove a credentials from our credentials list ''' self.new_credentials.save_credentials() test_credentials = Credentials("user", "platform", "meme", "password", "instagram") # new credentials test_credentials.save_credentials() self.new_credentials.delete_credentials( ) # Deleting a credentials object self.assertEqual(len(Credentials.credentials_list), 1)
def ep_login(self): credentials = Credentials() login_data = { 'email': utfenc(credentials.email), 'password': utfenc(credentials.password), 'udid': addon.getSetting('device_id') } encoded = urllib.urlencode({ 'data': json.dumps(login_data), 'context': json.dumps(self.context) }) url = self.CRM_LOGIN + '?' + encoded return self.json_request(url)
def test_save_multiple_credentials(self): ''' A test_save_multiple_credentials to check if we can save multiple credentials objects to our credentials_list ''' self.new_credentials.save_credentials() test_credentials = Credentials("twitter", "DavidMark", "davidmark2020") test_credentials.save_credentials() self.assertEqual(len(Credentials.credentials_list), 2)
def test_find_credentials_by_username1(self): ''' test to check if we can find a contact by phone number and display information ''' self.new_credentials.save_credentials() test_credentials = Credentials("Peter", "66820", "instagram") # new contact test_credentials.save_credentials() found_credentials = Credentials.find_by_username1("Peter") self.assertEqual(found_credentials, test_credentials)
def test_credentials_exists(self): ''' test to check if we can return a Boolean if we cannot find the contact. ''' self.new_credentials.save_credentials() test_credentials = Credentials("Peter", "66820", "instagram") # new contact test_credentials.save_credentials() credentials_exists = Credentials.credentials_exist("Peter") self.assertTrue(credentials_exists)
def test_add_new_credentials(self): """ Test to check if methods creates new credentials properly """ self.new_user.create_user() credentials = Credentials("Twitter", "victormainak") self.new_user.add_new_credentials(credentials) self.assertEqual(len(self.new_user.credentials), 1) self.assertEqual(self.new_user.credentials[0].account_name, "Twitter") self.assertEqual(self.new_user.credentials[0].user_name, "victormainak") self.assertNotEqual(self.new_user.credentials[0].password, "")
def test_add_existing_credentials(self): """ Test to check if method adds credentials to credentials list """ self.new_user.create_user() credentials = Credentials("Instagram", "victor", "pass") self.new_user.add_existing_credentials(credentials) self.assertEqual(len(self.new_user.credentials), 1) self.assertEqual(self.new_user.credentials[0].account_name, "Instagram") self.assertEqual(self.new_user.credentials[0].user_name, "victor") self.assertEqual(self.new_user.credentials[0].password, "pass")
def test_find_credentials_by_account(self): ''' test to check if we can find a credentials by phone account and display information ''' self.new_credentials.save_credentials() test_credentials = Credentials("Gmail", "user", "zxcvbnml") # new credentials test_credentials.save_credentials() found_credentials = Credentials.find_by_account("Gmail") self.assertEqual(found_credentials.username, test_credentials.username)
def test_credentials_exists(self): ''' test to check if we can return a Boolean if we cannot find the credentials. ''' self.new_credentials.save_credentials() test_credentials = Credentials("user", "platform", "meme", "password", "facebook") # new credentials test_credentials.save_credentials() credentials_exists = Credentials.credentials_exist("meme") self.assertTrue(credentials_exists)
def test_find_credentials_by_password(self): ''' This test is to verify that we can get user's credentials using their passwords ''' self.new_credentials.save_credentials() test_save_credentials = Credentials("Test", "user", "Libb19", "*****@*****.**") test_save_credentials.save_credentials() found_credentials = Credentials.find_by_password("Libb19") self.assertEqual(found_credentials.email, test_save_credentials.email)
def test_find_credential_by_name(self): ''' test to check if we can find a contact by phone number and display information ''' self.User1.save_accounts() test_credentials = Credentials("Alicia", "444") test_credentials.save_accounts() found_credentials = Credentials.find_by_name("Alicia") self.assertEqual(found_credentials.account_name, test_credentials.account_name)
def test_find_credentials_by_credentials_name(self): ''' test to check if we can find an account by account_name and display information ''' self.new_credentials.save_credentials() test_credentials = Credentials("Test", "user", "0742819636", "*****@*****.**") test_credentials.save_credentials() found_credentials = Credentials.find_by_name("Test") self.assertEqual(found_credentials.email, test_credentials.email)
def test_delete_credentials(self): ''' test_delete is a method that delete's a credential from the credentials list ''' self.new_credentials.save_credentials() test_credentials = Credentials('Erastus', 'Ruiru', 'Facebook', 'mutwech', '5678') #new credentials test_credentials.save_credentials() self.new_credentials.delete_credentials( ) #delete credentials from credentials list self.assertEqual(len(Credentials.credentials_list), 1)
def find_credentials(self): ''' find_credentials is a method that you can search a credential by using credentails account name ''' self.new_credentials.save_credentials() test_credentials = Credentials('Erastus', 'Ruiru', 'Facebook', 'mutwech', '5678') #new credentials test_credentials.save_credentials() found_credentials = Credentials.find_by_first_name('Erastus') self.assertEqual(found_credentials.second_name, test_credentials.second_name)
def test_find_credentials_by_accountname(self): ''' test to check if we can find an account credentials by name and display password ''' self.new_credentials.save_credentials() test_credentials = Credentials("Facebook", "user56789") # new account test_credentials.save_credentials() found_credentials = Credentials.find_by_accountname("Facebook") self.assertEqual(found_credentials.accountname, test_credentials.accountname)
def test_delete_credentials(self): """ testdelete to test if we can remove credentials """ self.new_user_credentials.save_credentials() new_user_credentials = Credentials("user", "*****@*****.**", "0788456789") #new inputs new_user_credentials.save_credentials() self.new_user_credentials.delete_credentials( ) # Deleting a credential object self.assertEqual(len(Credentials.credentials_inputs_list), 1)
def test_credentials_exists(self): ''' test to check if we can return a Boolean if we cannot find the credentials. ''' self.new_credentials.save_credentials() test_credentials = Credentials("twitter", "celinemmbone3", "CelineColline") # new contact test_credentials.save_credentials() credentials_exists = Credentials.credentials_exist("celinemmbone3") self.assertTrue(credentials_exists)
def test_find_credentials(self): ''' Test to check if we can find a credential by account_name ''' self.new_account.save_credentials() test_account = Credentials("audrey", "Instagram", "audrey", "123456789") #new credential test_account.save_credentials() the_account = Credentials.find_credentials("Instagram") self.assertEqual(the_account.account_name, test_account.account_name)
def test_credentials_exists(self): ''' test to check if we can return a Boolean if we cannot find the credentials. ''' self.new_credentials.save_credentials() test_credentials = Credentials( "Test", "Credentials", "88635328316", "*****@*****.**") # new credentials test_credentials.save_credentials() credentials_exists = Credentials.credentials_exist("TestUser") self.assertTrue(credentials_exists)
def test_find_credentials_by_name(self): ''' test to check if we can find a contact by phone number and display information ''' self.new_credentials.save_credentials() test_credentials = Credentials("tttttTTTTDWEW12", "Waranyanze126@ws", "eaeaeeatgg", "TTTFGGEHJGHSRTMN") # new contact test_credentials.save_credentials() found_credentials = Credentials.find_by_name("facebook") self.assertEqual(found_credentials, test_credentials.facebook)
def test_find_credentials(self): """ test to check if we can find credentials by name and display information """ self.new_credentials.save_credentials() test_credentials = Credentials("aaron", "gmail", "fecebook20") #new credentials test_credentials.save_credentials() found_credentials = Credentials.find_credentials("gmail", "fecebook") self.assertEqual(found_credentials.credentials_name, test_credentials.credentials_name)
def set_user_ref(self): credentials = Credentials() user_ref = self.ep_login(credentials) if user_ref.get('Response', None): log('[%s] login: %s' % (addon_id, utfenc(user_ref['Response']['Message']))) if user_ref.get('Id', '') and user_ref.get('Hkey', ''): self.dvs['userid'] = user_ref['Id'] addon.setSetting('userid', user_ref['Id']) self.dvs['hkey'] = user_ref['Hkey'] addon.setSetting('hkey', user_ref['Hkey']) credentials.save() else: credentials.reset()
def test_find_credentials_by_account_name(self): ''' this will check if we can find a contact by phone number and display information ''' self.new_credentials.save_credentials() test_credentials = Credentials("Twitter", "t_uname", "t_uname@gmail", "passwd") test_credentials.save_credentials() found_credentials = Credentials.find_by_account_name("Twitter") self.assertEqual(found_credentials.email, test_credentials.email)
def test_find_credential_by_account_name(self): ''' test to check if we can find a credential by account_name and display information ''' self.new_credential.save_credentials() test_credential = Credentials("Joseph", "Instagram", "123456") # new credential test_credential.save_credentials() found_credential = Credentials.find_by_account_name("Instagram") self.assertEqual(found_credential.account_name, test_credential.account_name)
def log_in(): # Log into Spotify and get username cred = Credentials() token = cred.spotify_user_access_token username = cred.spotify_username sp = spotipy.Spotify(auth=token) sp.trace = False # Get a list of playlist names and ids for user results = sp.current_user_playlists(limit=50) pl_names = [a['name'] for a in results['items']] playlist_ids = [b['id'] for b in results['items']] return (sp, username, pl_names, playlist_ids)
def parameters(self): init = Credentials() # parameters database server = init.server db = init.db user = init.user passw = init.passw stringConnect = 'postgresql://' + user + ":" + passw + '@' + server + ':5432' + '/' + db # print(stringConnect) return (stringConnect)
def lambda_handler(event, context): logger.info('## EVENT') logger.info(event) creds_secret_id = os.getenv('creds_secret_id') secrets_manager = boto3.client('secretsmanager') logger.info("Initializing credentials from AWS SecretsManager") creds = Credentials(creds_secret_id, secrets_manager) AMOUNT_TO_BUY = float(os.getenv("amount", "50.00")) PRODUCT = os.getenv("token", "ETH") if creds.sandbox: logger.info("Running in sandbox mode.") auth_client = cbpro.AuthenticatedClient(creds.key, creds.b64secret, creds.passphrase, api_url=creds.api_url) logger.info(f"Getting balances.") try: balances = get_balances(auth_client) except Exception as e: logger.error("Invalid API Key") raise e logger.info( f"We currently have {balances[PRODUCT]['available']} {PRODUCT} and {balances['USD']['available']} USD" ) logger.info(f"We want to buy {AMOUNT_TO_BUY} worth of {PRODUCT}") if balances['USD']['available'] < AMOUNT_TO_BUY: logger.info( f"We don't have enough available USD balance. ({AMOUNT_TO_BUY})") logger.info("Reloading balance for the next purchase.") deposit_funds(auth_client, AMOUNT_TO_BUY) else: logger.info(f"We have enough available USD balance.({AMOUNT_TO_BUY})") logger.info( f"Placing order for {PRODUCT}-USD in the amount of {AMOUNT_TO_BUY}" ) resp = auth_client.place_market_order(product_id=f'{PRODUCT}-USD', side='buy', funds=AMOUNT_TO_BUY) logger.info(resp) if balances['USD']['available'] < (AMOUNT_TO_BUY * 2): logger.info("Reloading balance for the next purchase.") deposit_funds(auth_client, AMOUNT_TO_BUY)
def login(self): code = None credentials = Credentials() if credentials.email and credentials.password: json_data = self.authentication(credentials) if json_data.get('message'): msg = utfenc(json_data['message'][:100]) else: msg = 'logged in' credentials.save() code = json_data['code'] log('[{0}] {1}'.format(addon_id, msg)) if code: self.user_settings(self.authorization(grant_type='urn:mlbam:params:oauth:grant_type:token', token=code)) self.profile()
def main(): dbclient = pymongo.MongoClient() dbclient.db_tweets.drop_collection('tweets') creds = Credentials(os.path.expanduser('~/.aws/credentials')) conn = S3Connection(creds.default_aws_access_key_id, creds.default_aws_secret_access_key) bucket = conn.lookup('nkrishna-mids205-hw2') for key in bucket.list(): if key.name.endswith('.jsn'): try: print("Copying tweets from", key.name) tweets = json.loads(key.get_contents_as_string()) dbclient.db_tweets.tweets.insert_many(tweets) finally: pass