Best Python code snippet using tempest_python
oauth_token_client.py
Source: oauth_token_client.py
...82 signature = hmac.new(key_utf8, text_utf8, hashlib.sha1)83 sig = binascii.b2a_base64(signature.digest())[:-1].decode('utf-8')84 oauth_params.append(('oauth_signature', sig))85 return oauth_params86 def _generate_oauth_header(self, oauth_params):87 authorization_header = {}88 authorization_header_parameters_parts = []89 for oauth_parameter_name, value in oauth_params:90 escaped_name = self._escape(oauth_parameter_name)91 escaped_value = self._escape(value)92 part = '{0}="{1}"'.format(escaped_name, escaped_value)93 authorization_header_parameters_parts.append(part)94 authorization_header_parameters = ', '.join(95 authorization_header_parameters_parts)96 oauth_string = 'OAuth %s' % authorization_header_parameters97 authorization_header['Authorization'] = oauth_string98 return authorization_header99 def create_request_token(self, consumer_key, consumer_secret, project_id):100 """Create request token.101 For more information, please refer to the official API reference:102 https://docs.openstack.org/api-ref/identity/v3-ext/#create-request-token103 """104 endpoint = 'OS-OAUTH1/request_token'105 headers = {'Requested-Project-Id': project_id}106 oauth_params = self._generate_params_with_signature(107 consumer_key,108 self.base_url + '/' + endpoint,109 client_secret=consumer_secret,110 callback_uri='oob',111 http_method='POST')112 oauth_header = self._generate_oauth_header(oauth_params)113 headers.update(oauth_header)114 resp, body = self.post(endpoint,115 body=None,116 headers=headers)117 self.expected_success(201, resp.status)118 if not isinstance(body, str):119 body = body.decode('utf-8')120 body = dict(item.split("=") for item in body.split("&"))121 return rest_client.ResponseBody(resp, body)122 def authorize_request_token(self, request_token_id, role_ids):123 """Authorize request token.124 For more information, please refer to the official API reference:125 https://docs.openstack.org/api-ref/identity/v3-ext/#authorize-request-token126 """127 roles = [{'id': role_id} for role_id in role_ids]128 body = {'roles': roles}129 post_body = json.dumps(body)130 resp, body = self.put("OS-OAUTH1/authorize/%s" % request_token_id,131 post_body)132 self.expected_success(200, resp.status)133 body = json.loads(body)134 return rest_client.ResponseBody(resp, body)135 def create_access_token(self, consumer_key, consumer_secret, request_key,136 request_secret, oauth_verifier):137 """Create access token.138 For more information, please refer to the official API reference:139 https://docs.openstack.org/api-ref/identity/v3-ext/#create-access-token140 """141 endpoint = 'OS-OAUTH1/access_token'142 oauth_params = self._generate_params_with_signature(143 consumer_key,144 self.base_url + '/' + endpoint,145 client_secret=consumer_secret,146 resource_owner_key=request_key,147 resource_owner_secret=request_secret,148 verifier=oauth_verifier,149 http_method='POST')150 headers = self._generate_oauth_header(oauth_params)151 resp, body = self.post(endpoint, body=None, headers=headers)152 self.expected_success(201, resp.status)153 if not isinstance(body, str):154 body = body.decode('utf-8')155 body = dict(item.split("=") for item in body.split("&"))156 return rest_client.ResponseBody(resp, body)157 def get_access_token(self, user_id, access_token_id):158 """Get access token.159 For more information, please refer to the official API reference:160 https://docs.openstack.org/api-ref/identity/v3-ext/#get-access-token161 """162 resp, body = self.get("users/%s/OS-OAUTH1/access_tokens/%s"163 % (user_id, access_token_id))164 self.expected_success(200, resp.status)...
Check out the latest blogs from LambdaTest on this topic:
These days, development teams depend heavily on feedback from automated tests to evaluate the quality of the system they are working on.
I think that probably most development teams describe themselves as being “agile” and probably most development teams have standups, and meetings called retrospectives.There is also a lot of discussion about “agile”, much written about “agile”, and there are many presentations about “agile”. A question that is often asked is what comes after “agile”? Many testers work in “agile” teams so this question matters to us.
I routinely come across test strategy documents when working with customers. They are lengthy—100 pages or more—and packed with monotonous text that is routinely reused from one project to another. Yawn once more— the test halt and resume circumstances, the defect management procedure, entrance and exit criteria, unnecessary generic risks, and in fact, one often-used model replicates the requirements of textbook testing, from stress to systems integration.
To understand the agile testing mindset, we first need to determine what makes a team “agile.” To me, an agile team continually focuses on becoming self-organized and cross-functional to be able to complete any challenge they may face during a project.
When working on web automation with Selenium, I encountered scenarios where I needed to refresh pages from time to time. When does this happen? One scenario is that I needed to refresh the page to check that the data I expected to see was still available even after refreshing. Another possibility is to clear form data without going through each input individually.
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!