def retrieve(self): query = { "Action": "AssumeRole", "Version": "2011-06-15", "RoleArn": self._RoleArn, "RoleSessionName": self._RoleSessionName, } # Add optional elements to the request if self._Policy is not None: query["Policy"] = self._Policy if self._DurationSeconds is not None: query["DurationSeconds"] = str(self._DurationSeconds) url = self._minio_client._endpoint_url + "/" content = urlencode(query) headers = { 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8', 'User-Agent': self._minio_client._user_agent } # Create signature headers content_sha256_hex = get_sha256_hexdigest(content) signed_headers = sign_v4(self.method, url, self.region, headers, self._minio_client._credentials, content_sha256=content_sha256_hex, request_datetime=datetime.utcnow(), service_name='sts') response = self._minio_client._http.urlopen(self.method, url, body=content, headers=signed_headers, preload_content=True) if response.status != 200: raise ResponseError(response, self.method).get_exception() # Parse the XML Response - getting the credentials as a Values instance. credentials_value, expiry = parse_assume_role(response.data) self._expiry.set_expiration(expiry) return credentials_value
def test_unicode_urlencode_b(self): eq_(urlencode(b'/test/123/\xe6\xb1\x89\xe5\xad\x97'), '/test/123/%E6%B1%89%E5%AD%97')
def test_unicode_urlencode_u(self): eq_(urlencode(u'/test/123/汉字'), '/test/123/%E6%B1%89%E5%AD%97')