Merge "Change image client methods to return one value"
diff --git a/tempest/api/object_storage/base.py b/tempest/api/object_storage/base.py
index 905eb9f..fcb80f5 100644
--- a/tempest/api/object_storage/base.py
+++ b/tempest/api/object_storage/base.py
@@ -46,7 +46,6 @@
cls.object_client = cls.os.object_client
cls.container_client = cls.os.container_client
cls.account_client = cls.os.account_client
- cls.custom_object_client = cls.os.custom_object_client
cls.token_client = cls.os_admin.token_client
cls.identity_admin_client = cls.os_admin.identity_client
cls.object_client_alt = cls.os_alt.object_client
@@ -57,7 +56,6 @@
cls.object_client.auth_provider.clear_auth()
cls.container_client.auth_provider.clear_auth()
cls.account_client.auth_provider.clear_auth()
- cls.custom_object_client.auth_provider.clear_auth()
cls.object_client_alt.auth_provider.clear_auth()
cls.container_client_alt.auth_provider.clear_auth()
diff --git a/tempest/api/object_storage/test_container_acl.py b/tempest/api/object_storage/test_container_acl.py
index 2244900..205bc91 100644
--- a/tempest/api/object_storage/test_container_acl.py
+++ b/tempest/api/object_storage/test_container_acl.py
@@ -52,11 +52,11 @@
object_name, 'data')
self.assertHeaders(resp, 'Object', 'PUT')
# Trying to read the object with rights
- self.custom_object_client.auth_provider.set_alt_auth_data(
+ self.object_client.auth_provider.set_alt_auth_data(
request_part='headers',
auth_data=self.test_auth_data
)
- resp, _ = self.custom_object_client.get_object(
+ resp, _ = self.object_client.get_object(
self.container_name, object_name)
self.assertHeaders(resp, 'Object', 'GET')
@@ -71,12 +71,12 @@
metadata_prefix='')
self.assertHeaders(resp_meta, 'Container', 'POST')
# Trying to write the object with rights
- self.custom_object_client.auth_provider.set_alt_auth_data(
+ self.object_client.auth_provider.set_alt_auth_data(
request_part='headers',
auth_data=self.test_auth_data
)
object_name = data_utils.rand_name(name='Object')
- resp, _ = self.custom_object_client.create_object(
+ resp, _ = self.object_client.create_object(
self.container_name,
- object_name, 'data')
+ object_name, 'data', headers={})
self.assertHeaders(resp, 'Object', 'PUT')
diff --git a/tempest/api/object_storage/test_container_acl_negative.py b/tempest/api/object_storage/test_container_acl_negative.py
index fed4549..138d25a 100644
--- a/tempest/api/object_storage/test_container_acl_negative.py
+++ b/tempest/api/object_storage/test_container_acl_negative.py
@@ -43,13 +43,13 @@
# trying to create object with empty headers
# X-Auth-Token is not provided
object_name = data_utils.rand_name(name='Object')
- self.custom_object_client.auth_provider.set_alt_auth_data(
+ self.object_client.auth_provider.set_alt_auth_data(
request_part='headers',
auth_data=None
)
self.assertRaises(exceptions.Unauthorized,
- self.custom_object_client.create_object,
- self.container_name, object_name, 'data')
+ self.object_client.create_object,
+ self.container_name, object_name, 'data', headers={})
@test.attr(type=['negative', 'gate'])
def test_delete_object_without_using_creds(self):
@@ -59,12 +59,12 @@
object_name, 'data')
# trying to delete object with empty headers
# X-Auth-Token is not provided
- self.custom_object_client.auth_provider.set_alt_auth_data(
+ self.object_client.auth_provider.set_alt_auth_data(
request_part='headers',
auth_data=None
)
self.assertRaises(exceptions.Unauthorized,
- self.custom_object_client.delete_object,
+ self.object_client.delete_object,
self.container_name, object_name)
@test.attr(type=['negative', 'gate'])
@@ -73,13 +73,13 @@
# User provided token is forbidden. ACL are not set
object_name = data_utils.rand_name(name='Object')
# trying to create object with non-authorized user
- self.custom_object_client.auth_provider.set_alt_auth_data(
+ self.object_client.auth_provider.set_alt_auth_data(
request_part='headers',
auth_data=self.test_auth_data
)
self.assertRaises(exceptions.Unauthorized,
- self.custom_object_client.create_object,
- self.container_name, object_name, 'data')
+ self.object_client.create_object,
+ self.container_name, object_name, 'data', headers={})
@test.attr(type=['negative', 'gate'])
def test_read_object_with_non_authorized_user(self):
@@ -90,12 +90,12 @@
self.container_name, object_name, 'data')
self.assertHeaders(resp, 'Object', 'PUT')
# trying to get object with non authorized user token
- self.custom_object_client.auth_provider.set_alt_auth_data(
+ self.object_client.auth_provider.set_alt_auth_data(
request_part='headers',
auth_data=self.test_auth_data
)
self.assertRaises(exceptions.Unauthorized,
- self.custom_object_client.get_object,
+ self.object_client.get_object,
self.container_name, object_name)
@test.attr(type=['negative', 'gate'])
@@ -107,12 +107,12 @@
self.container_name, object_name, 'data')
self.assertHeaders(resp, 'Object', 'PUT')
# trying to delete object with non-authorized user token
- self.custom_object_client.auth_provider.set_alt_auth_data(
+ self.object_client.auth_provider.set_alt_auth_data(
request_part='headers',
auth_data=self.test_auth_data
)
self.assertRaises(exceptions.Unauthorized,
- self.custom_object_client.delete_object,
+ self.object_client.delete_object,
self.container_name, object_name)
@test.attr(type=['negative', 'smoke'])
@@ -130,12 +130,12 @@
object_name, 'data')
self.assertHeaders(resp, 'Object', 'PUT')
# Trying to read the object without rights
- self.custom_object_client.auth_provider.set_alt_auth_data(
+ self.object_client.auth_provider.set_alt_auth_data(
request_part='headers',
auth_data=self.test_auth_data
)
self.assertRaises(exceptions.Unauthorized,
- self.custom_object_client.get_object,
+ self.object_client.get_object,
self.container_name, object_name)
@test.attr(type=['negative', 'smoke'])
@@ -148,15 +148,15 @@
metadata_prefix='')
self.assertHeaders(resp_meta, 'Container', 'POST')
# Trying to write the object without rights
- self.custom_object_client.auth_provider.set_alt_auth_data(
+ self.object_client.auth_provider.set_alt_auth_data(
request_part='headers',
auth_data=self.test_auth_data
)
object_name = data_utils.rand_name(name='Object')
self.assertRaises(exceptions.Unauthorized,
- self.custom_object_client.create_object,
+ self.object_client.create_object,
self.container_name,
- object_name, 'data')
+ object_name, 'data', headers={})
@test.attr(type=['negative', 'smoke'])
def test_write_object_without_write_rights(self):
@@ -170,15 +170,15 @@
metadata_prefix='')
self.assertHeaders(resp_meta, 'Container', 'POST')
# Trying to write the object without write rights
- self.custom_object_client.auth_provider.set_alt_auth_data(
+ self.object_client.auth_provider.set_alt_auth_data(
request_part='headers',
auth_data=self.test_auth_data
)
object_name = data_utils.rand_name(name='Object')
self.assertRaises(exceptions.Unauthorized,
- self.custom_object_client.create_object,
+ self.object_client.create_object,
self.container_name,
- object_name, 'data')
+ object_name, 'data', headers={})
@test.attr(type=['negative', 'smoke'])
def test_delete_object_without_write_rights(self):
@@ -197,11 +197,11 @@
object_name, 'data')
self.assertHeaders(resp, 'Object', 'PUT')
# Trying to delete the object without write rights
- self.custom_object_client.auth_provider.set_alt_auth_data(
+ self.object_client.auth_provider.set_alt_auth_data(
request_part='headers',
auth_data=self.test_auth_data
)
self.assertRaises(exceptions.Unauthorized,
- self.custom_object_client.delete_object,
+ self.object_client.delete_object,
self.container_name,
object_name)
diff --git a/tempest/api/object_storage/test_container_staticweb.py b/tempest/api/object_storage/test_container_staticweb.py
index 3b671d4..a8e5f9a 100644
--- a/tempest/api/object_storage/test_container_staticweb.py
+++ b/tempest/api/object_storage/test_container_staticweb.py
@@ -17,6 +17,7 @@
from tempest.api.object_storage import base
from tempest.common import custom_matchers
from tempest.common.utils import data_utils
+from tempest import exceptions
from tempest import test
@@ -153,13 +154,12 @@
object_data_404)
# Do not set auth in HTTP headers for next request
- self.custom_object_client.auth_provider.set_alt_auth_data(
+ self.object_client.auth_provider.set_alt_auth_data(
request_part='headers',
auth_data=None
)
# Request non-existing object
- resp, body = self.custom_object_client.get_object(self.container_name,
- "notexisting")
- self.assertEqual(resp['status'], '404')
- self.assertEqual(body, object_data_404)
+ self.assertRaises(
+ exceptions.NotFound, self.object_client.get_object,
+ self.container_name, "notexisting")
diff --git a/tempest/api/object_storage/test_object_services.py b/tempest/api/object_storage/test_object_services.py
index f78220c..cbca5e8 100644
--- a/tempest/api/object_storage/test_object_services.py
+++ b/tempest/api/object_storage/test_object_services.py
@@ -177,7 +177,7 @@
object_name = data_utils.rand_name(name='TestObject')
data = data_utils.arbitrary_string()
metadata = {'Expect': '100-continue'}
- resp = self.custom_object_client.create_object_continue(
+ resp = self.object_client.create_object_continue(
self.container_name,
object_name,
data,
@@ -186,7 +186,7 @@
self.assertIn('status', resp)
self.assertEqual(resp['status'], '100')
- self.custom_object_client.create_object_continue(
+ self.object_client.create_object_continue(
self.container_name,
object_name,
data,
@@ -1014,11 +1014,11 @@
self.assertEqual(resp_meta['x-container-read'], '.r:*,.rlistings')
# trying to get object with empty headers as it is public readable
- self.custom_object_client.auth_provider.set_alt_auth_data(
+ self.object_client.auth_provider.set_alt_auth_data(
request_part='headers',
auth_data=None
)
- resp, body = self.custom_object_client.get_object(
+ resp, body = self.object_client.get_object(
self.container_name, object_name)
self.assertHeaders(resp, 'Object', 'GET')
@@ -1052,12 +1052,12 @@
# get auth token of alternative user
alt_auth_data = self.identity_client_alt.auth_provider.auth_data
- self.custom_object_client.auth_provider.set_alt_auth_data(
+ self.object_client.auth_provider.set_alt_auth_data(
request_part='headers',
auth_data=alt_auth_data
)
# access object using alternate user creds
- resp, body = self.custom_object_client.get_object(
+ resp, body = self.object_client.get_object(
self.container_name, object_name)
self.assertHeaders(resp, 'Object', 'GET')
diff --git a/tempest/clients.py b/tempest/clients.py
index dfb2c04..8d59742 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -14,7 +14,7 @@
# under the License.
from tempest import auth
-from tempest.common import rest_client
+from tempest.common import negative_rest_client
from tempest import config
from tempest import manager
from tempest.openstack.common import log as logging
@@ -85,8 +85,6 @@
from tempest.services.object_storage.account_client import AccountClient
from tempest.services.object_storage.container_client import ContainerClient
from tempest.services.object_storage.object_client import ObjectClient
-from tempest.services.object_storage.object_client import \
- ObjectClientCustomizedHeader
from tempest.services.orchestration.json.orchestration_client import \
OrchestrationClient
from tempest.services.telemetry.json.telemetry_client import \
@@ -155,7 +153,7 @@
if CONF.service_available.ceilometer:
self.telemetry_client = TelemetryClientJSON(
self.auth_provider)
- self.negative_client = rest_client.NegativeRestClient(
+ self.negative_client = negative_rest_client.NegativeRestClient(
self.auth_provider, service)
# TODO(andreaf) EC2 client still do their auth, v2 only
@@ -175,8 +173,6 @@
self.auth_provider)
self.ec2api_client = botoclients.APIClientEC2(*ec2_client_args)
self.s3_client = botoclients.ObjectClientS3(*ec2_client_args)
- self.custom_object_client = ObjectClientCustomizedHeader(
- self.auth_provider)
self.data_processing_client = DataProcessingClient(
self.auth_provider)
diff --git a/tempest/common/negative_rest_client.py b/tempest/common/negative_rest_client.py
new file mode 100644
index 0000000..a9ae1c3
--- /dev/null
+++ b/tempest/common/negative_rest_client.py
@@ -0,0 +1,72 @@
+# (c) 2014 Deutsche Telekom AG
+# Copyright 2014 Red Hat, Inc.
+# Copyright 2014 NEC Corporation
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.common import rest_client
+from tempest import config
+
+CONF = config.CONF
+
+
+class NegativeRestClient(rest_client.RestClient):
+ """
+ Version of RestClient that does not raise exceptions.
+ """
+
+ def __init__(self, auth_provider, service):
+ region = self._get_region(service)
+ super(NegativeRestClient, self).__init__(auth_provider,
+ service, region)
+
+ def _get_region(self, service):
+ """
+ Returns the region for a specific service
+ """
+ service_region = None
+ for cfgname in dir(CONF._config):
+ # Find all config.FOO.catalog_type and assume FOO is a service.
+ cfg = getattr(CONF, cfgname)
+ catalog_type = getattr(cfg, 'catalog_type', None)
+ if catalog_type == service:
+ service_region = getattr(cfg, 'region', None)
+ if not service_region:
+ service_region = CONF.identity.region
+ return service_region
+
+ def _error_checker(self, method, url,
+ headers, body, resp, resp_body):
+ pass
+
+ def send_request(self, method, url_template, resources, body=None):
+ url = url_template % tuple(resources)
+ if method == "GET":
+ resp, body = self.get(url)
+ elif method == "POST":
+ resp, body = self.post(url, body)
+ elif method == "PUT":
+ resp, body = self.put(url, body)
+ elif method == "PATCH":
+ resp, body = self.patch(url, body)
+ elif method == "HEAD":
+ resp, body = self.head(url)
+ elif method == "DELETE":
+ resp, body = self.delete(url)
+ elif method == "COPY":
+ resp, body = self.copy(url)
+ else:
+ assert False
+
+ return resp, body
diff --git a/tempest/common/rest_client.py b/tempest/common/rest_client.py
index 7af1e23..3802c9d 100644
--- a/tempest/common/rest_client.py
+++ b/tempest/common/rest_client.py
@@ -78,10 +78,12 @@
LOG = logging.getLogger(__name__)
- def __init__(self, auth_provider, service, endpoint_type='publicURL',
+ def __init__(self, auth_provider, service, region,
+ endpoint_type='publicURL',
build_interval=1, build_timeout=60):
self.auth_provider = auth_provider
self.service = service
+ self.region = region
self.endpoint_type = endpoint_type
self.build_interval = build_interval
self.build_timeout = build_timeout
@@ -124,21 +126,6 @@
str(self.token)[0:STRING_LIMIT],
str(self.get_headers())[0:STRING_LIMIT])
- def _get_region(self, service):
- """
- Returns the region for a specific service
- """
- service_region = None
- for cfgname in dir(CONF._config):
- # Find all config.FOO.catalog_type and assume FOO is a service.
- cfg = getattr(CONF, cfgname)
- catalog_type = getattr(cfg, 'catalog_type', None)
- if catalog_type == service:
- service_region = getattr(cfg, 'region', None)
- if not service_region:
- service_region = CONF.identity.region
- return service_region
-
@property
def user(self):
return self.auth_provider.credentials.username
@@ -172,7 +159,7 @@
_filters = dict(
service=self.service,
endpoint_type=self.endpoint_type,
- region=self._get_region(self.service)
+ region=self.region
)
if self.api_version is not None:
_filters['api_version'] = self.api_version
@@ -608,33 +595,3 @@
except jsonschema.ValidationError as ex:
msg = ("HTTP response header is invalid (%s)") % ex
raise exceptions.InvalidHTTPResponseHeader(msg)
-
-
-class NegativeRestClient(RestClient):
- """
- Version of RestClient that does not raise exceptions.
- """
- def _error_checker(self, method, url,
- headers, body, resp, resp_body):
- pass
-
- def send_request(self, method, url_template, resources, body=None):
- url = url_template % tuple(resources)
- if method == "GET":
- resp, body = self.get(url)
- elif method == "POST":
- resp, body = self.post(url, body)
- elif method == "PUT":
- resp, body = self.put(url, body)
- elif method == "PATCH":
- resp, body = self.patch(url, body)
- elif method == "HEAD":
- resp, body = self.head(url)
- elif method == "DELETE":
- resp, body = self.delete(url)
- elif method == "COPY":
- resp, body = self.copy(url)
- else:
- assert False
-
- return resp, body
diff --git a/tempest/services/baremetal/base.py b/tempest/services/baremetal/base.py
index 4bcf2aa..c1ebba5 100644
--- a/tempest/services/baremetal/base.py
+++ b/tempest/services/baremetal/base.py
@@ -50,7 +50,9 @@
def __init__(self, auth_provider):
super(BaremetalClient, self).__init__(
- auth_provider, CONF.baremetal.catalog_type,
+ auth_provider,
+ CONF.baremetal.catalog_type,
+ CONF.identity.region,
endpoint_type=CONF.baremetal.endpoint_type)
self.uri_prefix = ''
diff --git a/tempest/services/compute/json/base.py b/tempest/services/compute/json/base.py
index 9187cc4..cb4915b 100644
--- a/tempest/services/compute/json/base.py
+++ b/tempest/services/compute/json/base.py
@@ -33,6 +33,7 @@
super(ComputeClient, self).__init__(
auth_provider,
CONF.compute.catalog_type,
+ CONF.compute.region or CONF.identity.region,
endpoint_type=CONF.compute.endpoint_type,
build_interval=build_interval,
build_timeout=build_timeout)
diff --git a/tempest/services/data_processing/v1_1/client.py b/tempest/services/data_processing/v1_1/client.py
index 6004b22..1b6842d 100644
--- a/tempest/services/data_processing/v1_1/client.py
+++ b/tempest/services/data_processing/v1_1/client.py
@@ -24,7 +24,9 @@
def __init__(self, auth_provider):
super(DataProcessingClient, self).__init__(
- auth_provider, CONF.data_processing.catalog_type,
+ auth_provider,
+ CONF.data_processing.catalog_type,
+ CONF.identity.region,
endpoint_type=CONF.data_processing.endpoint_type)
def _request_and_check_resp(self, request_func, uri, resp_status):
diff --git a/tempest/services/database/json/flavors_client.py b/tempest/services/database/json/flavors_client.py
index a57b045..01be29a 100644
--- a/tempest/services/database/json/flavors_client.py
+++ b/tempest/services/database/json/flavors_client.py
@@ -25,7 +25,9 @@
def __init__(self, auth_provider):
super(DatabaseFlavorsClientJSON, self).__init__(
- auth_provider, CONF.database.catalog_type)
+ auth_provider,
+ CONF.database.catalog_type,
+ CONF.identity.region)
def list_db_flavors(self, params=None):
url = 'flavors'
diff --git a/tempest/services/database/json/versions_client.py b/tempest/services/database/json/versions_client.py
index 911b55d..8a408e9 100644
--- a/tempest/services/database/json/versions_client.py
+++ b/tempest/services/database/json/versions_client.py
@@ -25,7 +25,9 @@
def __init__(self, auth_provider):
super(DatabaseVersionsClientJSON, self).__init__(
- auth_provider, CONF.database.catalog_type)
+ auth_provider,
+ CONF.database.catalog_type,
+ CONF.identity.region)
self.skip_path()
def list_db_versions(self, params=None):
diff --git a/tempest/services/identity/json/identity_client.py b/tempest/services/identity/json/identity_client.py
index c91b63e..5a4ce72 100644
--- a/tempest/services/identity/json/identity_client.py
+++ b/tempest/services/identity/json/identity_client.py
@@ -22,9 +22,11 @@
class IdentityClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
- super(IdentityClientJSON, self).__init__(auth_provider,
- CONF.identity.catalog_type,
- endpoint_type='adminURL')
+ super(IdentityClientJSON, self).__init__(
+ auth_provider,
+ CONF.identity.catalog_type,
+ CONF.identity.region,
+ endpoint_type='adminURL')
def has_admin_extensions(self):
"""
diff --git a/tempest/services/identity/v3/json/base.py b/tempest/services/identity/v3/json/base.py
index da8e287..30d3886 100644
--- a/tempest/services/identity/v3/json/base.py
+++ b/tempest/services/identity/v3/json/base.py
@@ -24,7 +24,9 @@
"""
def __init__(self, auth_provider):
- super(IdentityV3Client, self).__init__(auth_provider,
- CONF.identity.catalog_type,
- endpoint_type='adminURL')
+ super(IdentityV3Client, self).__init__(
+ auth_provider,
+ CONF.identity.catalog_type,
+ CONF.identity.region,
+ endpoint_type='adminURL')
self.api_version = "v3"
diff --git a/tempest/services/identity/v3/json/identity_client.py b/tempest/services/identity/v3/json/identity_client.py
index 48ba909..59902bb 100644
--- a/tempest/services/identity/v3/json/identity_client.py
+++ b/tempest/services/identity/v3/json/identity_client.py
@@ -523,7 +523,7 @@
class V3TokenClientJSON(rest_client.RestClient):
def __init__(self):
- super(V3TokenClientJSON, self).__init__(None, None)
+ super(V3TokenClientJSON, self).__init__(None, None, None)
auth_url = CONF.identity.uri_v3
if not auth_url:
raise exceptions.InvalidConfiguration('you must specify a v3 uri '
diff --git a/tempest/services/image/v1/json/image_client.py b/tempest/services/image/v1/json/image_client.py
index 7aacbd7..94d2f8e 100644
--- a/tempest/services/image/v1/json/image_client.py
+++ b/tempest/services/image/v1/json/image_client.py
@@ -38,6 +38,7 @@
super(ImageClientJSON, self).__init__(
auth_provider,
CONF.image.catalog_type,
+ CONF.image.region or CONF.identity.region,
endpoint_type=CONF.image.endpoint_type)
self._http = None
diff --git a/tempest/services/image/v2/json/image_client.py b/tempest/services/image/v2/json/image_client.py
index 7996bb2..847a4c6 100644
--- a/tempest/services/image/v2/json/image_client.py
+++ b/tempest/services/image/v2/json/image_client.py
@@ -32,6 +32,7 @@
super(ImageClientV2JSON, self).__init__(
auth_provider,
CONF.image.catalog_type,
+ CONF.image.region or CONF.identity.region,
endpoint_type=CONF.image.endpoint_type)
self._http = None
diff --git a/tempest/services/messaging/json/messaging_client.py b/tempest/services/messaging/json/messaging_client.py
index caed02f..45534c7 100644
--- a/tempest/services/messaging/json/messaging_client.py
+++ b/tempest/services/messaging/json/messaging_client.py
@@ -28,8 +28,10 @@
class MessagingClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
- super(MessagingClientJSON, self).__init__(auth_provider,
- CONF.messaging.catalog_type)
+ super(MessagingClientJSON, self).__init__(
+ auth_provider,
+ CONF.messaging.catalog_type,
+ CONF.identity.region)
self.version = '1'
self.uri_prefix = 'v{0}'.format(self.version)
diff --git a/tempest/services/network/json/network_client.py b/tempest/services/network/json/network_client.py
index c279efd..8f5ed5a 100644
--- a/tempest/services/network/json/network_client.py
+++ b/tempest/services/network/json/network_client.py
@@ -39,7 +39,9 @@
def __init__(self, auth_provider):
super(NetworkClientJSON, self).__init__(
- auth_provider, CONF.network.catalog_type,
+ auth_provider,
+ CONF.network.catalog_type,
+ CONF.network.region or CONF.identity.region,
endpoint_type=CONF.network.endpoint_type,
build_interval=CONF.network.build_interval,
build_timeout=CONF.network.build_timeout)
diff --git a/tempest/services/object_storage/base.py b/tempest/services/object_storage/base.py
index 3900e82..655596f 100644
--- a/tempest/services/object_storage/base.py
+++ b/tempest/services/object_storage/base.py
@@ -25,6 +25,8 @@
def __init__(self, auth_provider):
super(ObjectStorageClient, self).__init__(
- auth_provider, CONF.object_storage.catalog_type,
+ auth_provider,
+ CONF.object_storage.catalog_type,
+ CONF.object_storage.region or CONF.identity.region,
endpoint_type=CONF.object_storage.endpoint_type)
self.format = 'json'
diff --git a/tempest/services/object_storage/object_client.py b/tempest/services/object_storage/object_client.py
index a93a9df..bb74fd7 100644
--- a/tempest/services/object_storage/object_client.py
+++ b/tempest/services/object_storage/object_client.py
@@ -17,9 +17,7 @@
import urllib
import urlparse
-from tempest.common import http
from tempest import config
-from tempest import exceptions
from tempest.services.object_storage import base
CONF = config.CONF
@@ -28,10 +26,11 @@
class ObjectClient(base.ObjectStorageClient):
def create_object(self, container, object_name, data,
- params=None, metadata=None):
+ params=None, metadata=None, headers=None):
"""Create storage object."""
- headers = self.get_headers()
+ if headers is None:
+ headers = self.get_headers()
if not data:
headers['content-length'] = '0'
if metadata:
@@ -177,82 +176,6 @@
self.expected_success(201, resp.status)
return resp.status, resp.reason, resp_headers
-
-class ObjectClientCustomizedHeader(base.ObjectStorageClient):
-
- # TODO(andreaf) This class is now redundant, to be removed in next patch
-
- def request(self, method, url, extra_headers=False, headers=None,
- body=None):
- """A simple HTTP request interface."""
- dscv = CONF.identity.disable_ssl_certificate_validation
- ca_certs = CONF.identity.ca_certificates_file
- self.http_obj = http.ClosingHttp(
- disable_ssl_certificate_validation=dscv,
- ca_certs=ca_certs)
- if headers is None:
- headers = {}
- elif extra_headers:
- try:
- headers.update(self.get_headers())
- except (ValueError, TypeError):
- headers = {}
-
- # Authorize the request
- req_url, req_headers, req_body = self.auth_provider.auth_request(
- method=method, url=url, headers=headers, body=body,
- filters=self.filters
- )
- # Use original method
- resp, resp_body = self.http_obj.request(req_url, method,
- headers=req_headers,
- body=req_body)
- self._log_request(method, req_url, resp)
- if resp.status == 401 or resp.status == 403:
- raise exceptions.Unauthorized()
-
- return resp, resp_body
-
- def get_object(self, container, object_name, metadata=None):
- """Retrieve object's data."""
- headers = {}
- if metadata:
- for key in metadata:
- headers[str(key)] = metadata[key]
-
- url = "{0}/{1}".format(container, object_name)
- resp, body = self.get(url, headers=headers)
- self.expected_success(200, resp.status)
- return resp, body
-
- def create_object(self, container, object_name, data, metadata=None):
- """Create storage object."""
-
- headers = {}
- if metadata:
- for key in metadata:
- headers[str(key)] = metadata[key]
-
- if not data:
- headers['content-length'] = '0'
- url = "%s/%s" % (str(container), str(object_name))
- resp, body = self.put(url, data, headers=headers)
- self.expected_success(201, resp.status)
- return resp, body
-
- def delete_object(self, container, object_name, metadata=None):
- """Delete storage object."""
-
- headers = {}
- if metadata:
- for key in metadata:
- headers[str(key)] = metadata[key]
-
- url = "%s/%s" % (str(container), str(object_name))
- resp, body = self.delete(url, headers=headers)
- self.expected_success(200, resp.status)
- return resp, body
-
def create_object_continue(self, container, object_name,
data, metadata=None):
"""Create storage object."""
diff --git a/tempest/services/orchestration/json/orchestration_client.py b/tempest/services/orchestration/json/orchestration_client.py
index 2dedf01..054f410 100644
--- a/tempest/services/orchestration/json/orchestration_client.py
+++ b/tempest/services/orchestration/json/orchestration_client.py
@@ -31,6 +31,7 @@
super(OrchestrationClient, self).__init__(
auth_provider,
CONF.orchestration.catalog_type,
+ CONF.orchestration.region or CONF.identity.region,
endpoint_type=CONF.orchestration.endpoint_type,
build_interval=CONF.orchestration.build_interval,
build_timeout=CONF.orchestration.build_timeout)
diff --git a/tempest/services/telemetry/json/telemetry_client.py b/tempest/services/telemetry/json/telemetry_client.py
index 622c996..2b5dc1a 100644
--- a/tempest/services/telemetry/json/telemetry_client.py
+++ b/tempest/services/telemetry/json/telemetry_client.py
@@ -28,6 +28,7 @@
super(TelemetryClientJSON, self).__init__(
auth_provider,
CONF.telemetry.catalog_type,
+ CONF.identity.region,
endpoint_type=CONF.telemetry.endpoint_type)
self.version = '2'
self.uri_prefix = "v%s" % self.version
diff --git a/tempest/services/volume/json/base.py b/tempest/services/volume/json/base.py
index 1800ee6..ef316f2 100644
--- a/tempest/services/volume/json/base.py
+++ b/tempest/services/volume/json/base.py
@@ -27,6 +27,7 @@
super(VolumeClient, self).__init__(
auth_provider,
CONF.volume.catalog_type,
+ CONF.volume.region or CONF.identity.region,
endpoint_type=CONF.volume.endpoint_type,
build_interval=CONF.volume.build_interval,
build_timeout=CONF.volume.build_timeout)
diff --git a/tempest/tests/test_rest_client.py b/tempest/tests/test_rest_client.py
index 8d933df..a133800 100644
--- a/tempest/tests/test_rest_client.py
+++ b/tempest/tests/test_rest_client.py
@@ -17,6 +17,7 @@
import httplib2
from oslotest import mockpatch
+from tempest.common import negative_rest_client
from tempest.common import rest_client
from tempest import config
from tempest import exceptions
@@ -30,18 +31,13 @@
url = 'fake_endpoint'
- def _get_region(self):
- return 'fake region'
-
def setUp(self):
super(BaseRestClientTestClass, self).setUp()
self.useFixture(fake_config.ConfigFixture())
self.stubs.Set(config, 'TempestConfigPrivate', fake_config.FakePrivate)
self.rest_client = rest_client.RestClient(
- fake_auth_provider.FakeAuthProvider(), None)
+ fake_auth_provider.FakeAuthProvider(), None, None)
self.stubs.Set(httplib2.Http, 'request', self.fake_http.request)
- self.useFixture(mockpatch.PatchObject(self.rest_client, '_get_region',
- side_effect=self._get_region()))
self.useFixture(mockpatch.PatchObject(self.rest_client,
'_log_request'))
@@ -304,7 +300,7 @@
self.useFixture(fake_config.ConfigFixture())
self.stubs.Set(config, 'TempestConfigPrivate', fake_config.FakePrivate)
self.rest_client = rest_client.RestClient(
- fake_auth_provider.FakeAuthProvider(), None)
+ fake_auth_provider.FakeAuthProvider(), None, None)
def test_response_less_than_400(self):
self.rest_client._error_checker(**self.set_data("399"))
@@ -438,7 +434,7 @@
def setUp(self):
self.fake_http = fake_http.fake_httplib2()
super(TestNegativeRestClient, self).setUp()
- self.negative_rest_client = rest_client.NegativeRestClient(
+ self.negative_rest_client = negative_rest_client.NegativeRestClient(
fake_auth_provider.FakeAuthProvider(), None)
self.useFixture(mockpatch.PatchObject(self.negative_rest_client,
'_log_request'))