How to use setup_credentials method in tempest

Best Python code snippet using tempest_python

auth.py

Source:auth.py Github

copy

Full Screen

1import os2import logging3from oauth2client.service_account import ServiceAccountCredentials4from apiclient.discovery import build5from httplib2 import Http6from GoogleApiSupport import apis7def get_service(api_name, service_credentials_path=None):8 if service_credentials_path == None:9 service_credentials_path = get_service_credentials_path()10 service = None11 credentials = ServiceAccountCredentials.from_json_keyfile_name(12 service_credentials_path,13 scopes=apis.api_configs(api_name)['scope']14 )15 service = build(apis.api_configs(api_name)['build'],16 apis.api_configs(api_name)['version'],17 http=credentials.authorize(Http()),18 cache_discovery=False19 )20 logging.info('Using credentials found in ' + file)21 if not service:22 logging.error(' UNABLE TO RETRIEVE CREDENTIALS | Expected credential paths: ' + ', '.join(23 service_credentials_path) + ' | More info in project Documentation folder setup_credentials.md file')24 return service25def get_service_credentials_path():26 if os.environ.get('SERVICE_CREDENTIALS_PATH'):27 service_credentials_path = os.environ['SERVICE_CREDENTIALS_PATH']28 logging.info('Using credentials from ' + service_credentials_path)29 if os.path.isfile(service_credentials_path):30 logging.info('Found file credentials in' +31 service_credentials_path)32 else:33 raise.Exception('File in SERVICE_CREDENTIALS_PATH not found')34 elif os.path.isfile(os.path.join(os.path.expanduser('~'), '.credentials', 'service_credentials.json')):35 service_credentials_path = os.path.join(os.path.expanduser('~'), '.credentials', 'service_credentials.json')36 logging.info('Using credentials from ' + service_credentials_path)37 elif os.path.isfile(os.path.join('.credentials','service_credentials.json')):38 service_credentials_path = os.path.join('.credentials','service_credentials.json')39 else:40 raise.Exception(41 'UNABLE TO FIND CREDENTIALS FILE | More info in project Documentation folder setup_credentials.md file'42 )...

Full Screen

Full Screen

test_auth.py

Source:test_auth.py Github

copy

Full Screen

...3from bqsqoop.utils.gcloud.auth import setup_credentials4class TestSetupCredentials(unittest.TestCase):5 # def test_using_default_service_account(self):6 # os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "auth_file.json"7 # setup_credentials()8 def test_service_key_from_config(self):9 _service_account_key_file = '/tmp/gcp_service_account_key.json'10 _key_json = '{"acc": "someone@gcp.com"}'11 setup_credentials(_key_json)12 self.assertEqual(os.environ['GOOGLE_APPLICATION_CREDENTIALS'],13 _service_account_key_file)14 with open(_service_account_key_file, "r") as f:...

Full Screen

Full Screen

delete_bucket.py

Source:delete_bucket.py Github

copy

Full Screen

...8):9 """Deletes a bucket. The bucket must be empty."""10 logging.config.fileConfig(LOGGING_CONF)11 logger = logging.getLogger("root")12 setup_credentials()13 storage_client = storage.Client(project=project_id)14 bucket = storage_client.get_bucket(bucket_name)15 bucket.delete(force=True)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful