How to use get_auth_provider method in tempest

Best Python code snippet using tempest_python

skiplagged.py

Source:skiplagged.py Github

copy

Full Screen

...30 31 def login_with_google(self, username, password):32 print time.time(), "called login_with_google" 33 google_auth = Google()34 auth_provider = google_auth.get_auth_provider()35 access_token = google_auth.get_access_token(username, password)36 access_token = access_token37 38 return self._update_login(auth_provider, access_token, username, password)39 40 def login_with_pokemon_trainer(self, username, password):41 print time.time(), "called login_with_pokemon_trainer" 42 ptc_auth = PokemonTrainerClub()43 auth_provider = ptc_auth.get_auth_provider()44 access_token = ptc_auth.get_access_token(username, password)45 46 if not access_token or 'error' in access_token: raise Exception('failed to get access_token')47 return self._update_login(auth_provider, access_token, username, password)48 49 def _update_login(self, auth_provider, access_token, username, password): 50 if access_token:51 self._auth_provider = auth_provider52 self._access_token = str(access_token)53 self._username = username54 self._password = password55 56 return (self._auth_provider, self._access_token)57 58 return False59 60 def is_logged_in(self): return self._access_token is not None61 62 def _refresh_login(self):63 if not self.is_logged_in(): raise Exception('needs an existing log in')64 65 self.SPECIFIC_API = None66 self.PROFILE = None67 self.PROFILE_RAW = None68 69 if self.auth_provider == 'google': return self.login_with_google(self._username, self._password)70 elif self.auth_provider == 'ptc': return self.login_with_pokemon_trainer(self._username, self._password)71 72 def get_access_token(self): return self._access_token73 def get_auth_provider(self): return self._auth_provider74 75 # Calls76 77 def _call(self, endpoint, data):78 is_skiplagged_api = 'skiplagged' in endpoint79 requests_session = self._requests_skiplagged_session if is_skiplagged_api else self._requests_niantic_session80 81 while 1:82 try:83 if is_skiplagged_api:84 r = requests_session.post(endpoint, data, verify=False)85 return json.loads(r.content)86 else:87 r = requests_session.post(endpoint, base64.b64decode(data), verify=False)88 if 'Server Error' in r.content: raise Exception('invalid niantic server response')89 return base64.b64encode(r.content) 90 except Exception:91 print "post exception", traceback.format_exc()92 time.sleep(1)93 94 def get_specific_api_endpoint(self):95 print time.time(), "called get_specific_api_endpoint"96 if not self.is_logged_in(): raise Exception('need to log in first')97 98 response = self._call(self.SKIPLAGGED_API, {99 'access_token': self.get_access_token(), 100 'auth_provider': self.get_auth_provider()101 })102 if not 'pdata' in response: raise Exception('failed to get pdata 1')103 104 response = self._call(self.GENERAL_API, response['pdata'])105 if not response: raise Exception('pdata api call failed')106 107 response = self._call(self.SKIPLAGGED_API, {108 'access_token': self.get_access_token(),109 'auth_provider': self.get_auth_provider(),110 'pdata': response111 })112 if not 'api_endpoint' in response or not response['api_endpoint']: raise Exception('failed to retrieve specific api endpoint')113 self.SPECIFIC_API = response['api_endpoint']114 return self.SPECIFIC_API115 116 def get_profile(self):117 print time.time(), "called get_profile" 118 if not self.SPECIFIC_API: self.get_specific_api_endpoint()119 120 response = self._call(self.SKIPLAGGED_API, {121 'access_token': self.get_access_token(), 122 'auth_provider': self.get_auth_provider(),123 'api_endpoint': self.SPECIFIC_API124 })125 if not 'pdata' in response: raise Exception('failed to get pdata 1')126 127 response = self._call(self.SPECIFIC_API, response['pdata'])128 if not response: raise Exception('pdata api call failed')129 130 self.PROFILE_RAW = response131 132 response = self._call(self.SKIPLAGGED_API, {133 'access_token': self.get_access_token(),134 'auth_provider': self.get_auth_provider(),135 'api_endpoint': self.SPECIFIC_API,136 'pdata': self.PROFILE_RAW137 })138 if not 'username' in response: raise Exception('failed to retrieve profile')139 self.PROFILE = response140 return self.PROFILE141 142 # Generates a realistic path to traverse the bounds and find spawned pokemon143 # Processed sequentially and with delay to minimize chance of getting account banned144 def find_pokemon(self, bounds, step_size=0.002):145 print time.time(), "called find_pokemon" 146 if not self.PROFILE_RAW: self.get_profile()147 148 bounds = '%f,%f,%f,%f' % (bounds[0] + bounds[1])149 150 response = self._call(self.SKIPLAGGED_API, {151 'access_token': self.get_access_token(), 152 'auth_provider': self.get_auth_provider(),153 'profile': self.PROFILE_RAW,154 'bounds': bounds,155 'step_size': step_size156 })157 if not 'requests' in response: raise Exception('failed to get requests')158 159 for request in response['requests']:160 print time.time(), "moving player"161 pokemon_data = self._call(self.SPECIFIC_API, request['pdata'])162 response = self._call(self.SKIPLAGGED_API, {'pdata': pokemon_data})163 164 num_pokemon_found = len(response['pokemons'])165 if num_pokemon_found > 0: print time.time(), "found %d pokemon" % (num_pokemon_found)166 for pokemon in response['pokemons']: yield Pokemon(pokemon )...

Full Screen

Full Screen

manager.py

Source:manager.py Github

copy

Full Screen

...36 identity_uri=uri,37 disable_ssl_certificate_validation=dscv,38 ca_certs=CONF.identity.ca_certificates_file,39 trace_requests=CONF.debug.trace_requests)40def get_auth_provider(credentials, pre_auth=False, scope='project'):41 """Shim to get_auth_provider in clients.py42 get_auth_provider used to be hosted in this module, but it has been43 moved to clients.py now as a more permanent location.44 This module will be removed eventually, and this shim is only45 maintained for the benefit of plugins already consuming this interface.46 """47 msg = ("tempest.manager.get_auth_provider is not a stable interface and "48 "as such it should not imported directly. It will be removed as "49 "the client manager becomes available in tempest.lib.")50 LOG.warning(msg)51 return tempest_clients.get_auth_provider(credentials=credentials,...

Full Screen

Full Screen

auth_provider.py

Source:auth_provider.py Github

copy

Full Screen

1from core.social_auth.models import UserSocialAuth2from django import template3register = template.Library()4@register.filter5def get_auth_provider(username):6 return UserSocialAuth.auth_provider(username)...

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