How to use _auth_client method in tempest

Best Python code snippet using tempest_python

main.py

Source:main.py Github

copy

Full Screen

1# Copyright 2017-2020 The Wazo Authors (see the AUTHORS file)2# SPDX-License-Identifier: GPL-3.0-or-later3import os4import os.path5import sys6from cliff.app import App7from cliff.commandmanager import CommandManager8from wazo_auth_client import Client as Auth9from wazo_amid_client import Client as Amid10from . import config11import logging12logging.getLogger('requests').setLevel(logging.ERROR)13class WazoAsteriskCLI(App):14 DEFAULT_VERBOSE_LEVEL = 015 def __init__(self):16 super().__init__(17 description='A CLI for the asterisk service',18 command_manager=CommandManager('wazo_asterisk_cli.commands'),19 version='0.0.1',20 )21 self._current_token = None22 self._remove_token = False23 self._auth_client = None24 self._client = None25 self._backend = None26 def build_option_parser(self, *args, **kwargs):27 parser = super(WazoAsteriskCLI, self).build_option_parser(*args, **kwargs)28 config_path_from_env = os.getenv('WAZO_ASTERISK_CLI_CONFIG', None)29 config_path_default = os.path.expanduser(30 os.path.join('~', '.config', 'wazo-asterisk-cli')31 )32 parser.add_argument(33 '--config',34 default=(config_path_from_env or config_path_default),35 help='Extra configuration directory to override the system configuration',36 )37 parser.add_argument('--hostname', help='The wazo-auth hostname')38 parser.add_argument('--port', help='The wazo-auth port')39 https_verification = parser.add_mutually_exclusive_group()40 https_verification.add_argument('--ssl', help="Use ssl")41 https_verification.add_argument('--no-ssl', help="Don't use ssl")42 https_verification.add_argument(43 '--verify', action='store_true', help='Verify the HTTPS certificate or not'44 )45 https_verification.add_argument(46 '--insecure', action='store_true', help='Bypass certificate verification'47 )48 https_verification.add_argument('--cacert', help='Specify the ca bundle file')49 auth_or_token = parser.add_mutually_exclusive_group()50 auth_or_token.add_argument('--token', help='The wazo-auth token to use')51 username_password = auth_or_token.add_argument_group()52 username_password.add_argument(53 '--auth-username',54 metavar='auth_username',55 help='The username to use to retrieve a token',56 )57 username_password.add_argument(58 '--auth-password',59 metavar='auth_password',60 help='The password to use to retrieve a token',61 )62 username_password.add_argument(63 '--backend', help='The backend to use when authenticating'64 )65 return parser66 @property67 def client(self):68 if not self._auth_client:69 self._auth_client = Auth(**self._auth_config)70 if not self._current_token:71 self._backend = self._auth_config.pop('backend', None) or self._backend72 self._auth_client = Auth(**self._auth_config)73 args = {'expiration': 3600}74 if self._backend:75 args['backend'] = self._backend76 token_data = self._auth_client.token.new(**args)77 self._current_token = token_data['token']78 self._auth_client.set_token(self._current_token)79 self._client = Amid(**self._amid_config)80 self._client.set_token(self._current_token)81 return self._client82 @property83 def client_without_token(self):84 if not self._client:85 self._client = Auth(**self._auth_config)86 return self._client87 def initialize_app(self, argv):88 self.LOG.debug('Wazo Asterisk CLI')89 self.LOG.debug('options=%s', self.options)90 conf = config.build(self.options)91 self.LOG.debug('Starting with config: %s', conf)92 self._current_token = self.options.token93 self.LOG.debug('client args: %s', conf['auth'])94 self._auth_config = dict(conf['auth'])95 self._amid_config = dict(conf['amid'])96 def clean_up(self, cmd, result, err):97 if err:98 self.LOG.debug('got an error: %s', err)99 if self._remove_token:100 self._auth_client.token.revoke(self._current_token)101 self._remove_token = False102def main(argv=sys.argv[1:]):103 app = WazoAsteriskCLI()104 return app.run(argv)105if __name__ == '__main__':...

Full Screen

Full Screen

AllTestInText.py

Source:AllTestInText.py Github

copy

Full Screen

1import cbpro2import os3#API Secret Key = sFmQy9dxj1+i5OykxzB19VpHLI99ZubiDCDGKRJHlvSXrrn8yj+bnLpPpR1efZ7JB2PFfWfBAhg5t1jzlDrTuw==4class AllTestInText():5 def __init__(self):6 self.folder = "./log_cbpro/"7 self._public_client = cbpro.PublicClient()8 self._key = os.getenv("API_KEY_SANDBOX")9 self._b64secret = os.getenv("API_SECRET_SANDBOX")10 self._passphrase = os.getenv("API_PASSPHRASE_SANDBOX")11 self._auth_client = cbpro.AuthenticatedClient(self._key, self._b64secret, self._passphrase, api_url="https://api-public.sandbox.pro.coinbase.com")12 def launch_all_test(self):13 self.auth_buy_limit()14 self.auth_buy_market()15 self.auth_sell_limit()16 self.auth_sell_market()17 self.get_account()18 self.get_account_history()19 self.get_account_holds()20 self.get_accounts()21 self.get_currencies()22 self.get_product()23 self.get_product_24hr_stats()24 self.get_product_historic_rates()25 self.get_product_order_book()26 self.get_product_ticker()27 self.get_product_trades()28 self.get_time()29# ----- Public Client -----30 def get_product(self):31 file = open(self.folder + "get_products.txt","w")32 file.write(str(self._public_client.get_products()))33 file.close()34 def get_product_order_book(self):35 file = open(self.folder + "get_product_order_book.txt","w")36 file.write(str(self._public_client.get_product_order_book('XRP-EUR', level=3)))37 file.close()38 def get_product_ticker(self):39 file = open(self.folder + "get_product_ticker.txt","w")40 file.write(str(self._public_client.get_product_ticker(product_id='XRP-EUR')))41 file.close()42 def get_product_trades(self):43 historic_rates_gen = self._public_client.get_product_trades(product_id='XRP-EUR')44 file = open(self.folder + "get_product_trades.txt","w")45 file.write(str(list(historic_rates_gen)))46 file.close()47 def get_product_historic_rates(self):48 file = open(self.folder + "get_product_historic_rates.txt","w")49 file.write(str(self._public_client.get_product_historic_rates('XRP-EUR')))50 file.close()51 def get_product_24hr_stats(self):52 file = open(self.folder + "get_product_24hr_stats.txt","w")53 file.write(str(self._public_client.get_product_24hr_stats('XRP-EUR')))54 file.close()55 def get_currencies(self):56 file = open(self.folder + "get_currencies.txt","w")57 file.write(str(self._public_client.get_currencies()))58 file.close()59 def get_time(self):60 file = open(self.folder + "get_time.txt","w")61 file.write(str(self._public_client.get_time()))62 file.close()63# ----- ----- ------ -----64# ----- Authenticated Client -----65 def get_accounts(self):66 file = open(self.folder + "auth_get_accounts.txt","w")67 file.write(str(self._auth_client.get_accounts()))68 file.close()69 def get_account(self):70 file = open(self.folder + "auth_get_account.txt","w")71 file.write(str(self._auth_client.get_account("72f2c996-0b93-4bae-91d0-562eecef9914")))72 file.close()73 def get_account_history(self):74 file = open(self.folder + "auth_get_account_history.txt","w")75 file.write(str(self._auth_client.get_account_history("72f2c996-0b93-4bae-91d0-562eecef9914")))76 file.close()77 def get_account_holds(self):78 file = open(self.folder + "auth_get_account_holds.txt","w")79 file.write(str(self._auth_client.get_account_holds("72f2c996-0b93-4bae-91d0-562eecef9914")))80 file.close()81 def auth_buy_limit(self):82 file = open(self.folder + "auth_buy_limit.txt","w")83 file.write(str(self._auth_client.buy(price='100.00', size='0.01', order_type='limit', product_id='BTC-EUR')))84 file.close()85 def auth_buy_market(self):86 file = open(self.folder + "auth_buy_market.txt","w")87 file.write(str(self._auth_client.place_market_order(product_id='BTC-EUR', side='buy', funds='100.00')))88 file.close()89 def auth_sell_limit(self):90 file = open(self.folder + "auth_sell_limit.txt","w")91 file.write(str(self._auth_client.sell(price='100.00', size='0.01', order_type='limit', product_id='BTC-EUR')))92 file.close()93 94 def auth_sell_market(self):95 file = open(self.folder + "auth_sell_market.txt","w")96 file.write(str(self._auth_client.place_market_order(product_id='BTC-EUR', side='sell', funds='90.00')))97 file.close()...

Full Screen

Full Screen

base.py

Source:base.py Github

copy

Full Screen

...19class Settings(BaseSettings):20 def __init__(self, d):21 super().__init__(d)22 self._auth_client: Optional[AuthClient] = None23 def _get_auth_client(self):24 client_type = settings.get("auth.type")25 client_config = settings.get("auth.config")26 ClientClass = auth_clients[client_type]27 self._auth_client = ClientClass(client_config)28 @property29 def auth_client(self):30 if self._auth_client is None:31 self._get_auth_client()32 return self._auth_client33 @auth_client.setter34 def auth_client(self, client: AuthClient):35 self._auth_client = client...

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