def setUpClass(cls): cls.config = openstack_api_conformance.get_configuration()['swift'] if not cls.config: cls.skipTest("Swift not configured") response = requests.post( cls.config.auth_url + 'v2.0/tokens', data=json.dumps({ 'auth': { 'passwordCredentials': { 'username': cls.config['username'], 'password': cls.config['password'], }, 'tenantId': cls.config['tenantId'], } }), headers={'content-type': 'application/json'} ) token = response.json() cls.tokenId = token['access']['token']['id'] object_stores = [ service['endpoints'][0]['publicURL'] for service in token['access']['serviceCatalog'] if service['type'] == 'object-store' ] cls.url = object_stores[0] cls.headers = {'X-Auth-Token': cls.tokenId}
def sign_headers(method, path, headers, expires=None): if 'Date' not in headers and not expires: headers['date'] = email.utils.formatdate(time.time()) string_to_sign = canonical_string(method, path, headers, expires) config = openstack_api_conformance.get_configuration()['swift'] signature = base64.b64encode(hmac.new( str(config['s3_secret']), str(string_to_sign), sha).digest()) headers['Authorization'] = 'AWS %s:%s' % (config['s3_access'], signature)
def setUpClass(cls): cls.config = openstack_api_conformance.get_configuration()['swift'] if not cls.config: cls.skipTest("Swift not configured") response = requests.post(cls.config.auth_url + 'v2.0/tokens', data=json.dumps({ 'auth': { 'passwordCredentials': { 'username': cls.config['username'], 'password': cls.config['password'], }, 'tenantId': cls.config['tenantId'], } }), headers={'content-type': 'application/json'} ) token = response.json() cls.tokenId = token['access']['token']['id'] object_stores = [ service['endpoints'][0]['publicURL'] for service in token['access']['serviceCatalog'] if service['type'] == 'object-store' ] cls.url = object_stores[0] session = requests.Session() session.headers.update({'X-Auth-Token': cls.tokenId}) session.put(cls.url + "/foo").raise_for_status() session.put(cls.url + "/foo/a", data="abcd").raise_for_status() session.put(cls.url + "/foo/b", data="abcdabcd").raise_for_status() # PUT the container again to clear caches session.put(cls.url + "/foo").raise_for_status() # Add metadata to container session.post( cls.url, headers={'X-Account-Meta-foo': 'bar'}).raise_for_status()
def setUpClass(cls): cls.config = openstack_api_conformance.get_configuration()["swift"] if not cls.config: cls.skipTest("Swift not configured") response = requests.post( cls.config.auth_url + "v2.0/tokens", data=json.dumps( { "auth": { "passwordCredentials": {"username": cls.config["username"], "password": cls.config["password"]}, "tenantId": cls.config["tenantId"], } } ), headers={"content-type": "application/json"}, ) token = response.json() cls.tokenId = token["access"]["token"]["id"] object_stores = [ service["endpoints"][0]["publicURL"] for service in token["access"]["serviceCatalog"] if service["type"] == "object-store" ] cls.url = object_stores[0] cls.headers = {"X-Auth-Token": cls.tokenId} requests.put(cls.url + "/foo", headers=cls.headers).raise_for_status() requests.put(cls.url + "/foo/a", data="abcd", headers=cls.headers).raise_for_status() requests.put(cls.url + "/foo/b", data="abcdabcd", headers=cls.headers).raise_for_status() # PUT the container again to clear caches requests.put(cls.url + "/foo", headers=cls.headers).raise_for_status()
def setUpClass(cls): cls.config = openstack_api_conformance.get_configuration()['swift']
def setUpClass(cls): cls.config = openstack_api_conformance.get_configuration()['keystone']