Remove ObjectClientCustomizedHeader class

ObjectClientCustomizedHeader contains some API methods, and most of
them are duplicated with ObjectClient and we can replace them with
ObjectClient methods in many cases.
This patch removes ObjectClientCustomizedHeader and makes some tests
use ObjectClient instead.

Change-Id: I548cade87fdd719f71ffdd87950831e2b7c2287e
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..f57cc98 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -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 \
@@ -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/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."""