Merge "Use Tempest-lib's compute certificates_client"
diff --git a/tempest/api_schema/response/compute/v2_1/certificates.py b/tempest/api_schema/response/compute/v2_1/certificates.py
deleted file mode 100644
index 4e7cbe4..0000000
--- a/tempest/api_schema/response/compute/v2_1/certificates.py
+++ /dev/null
@@ -1,41 +0,0 @@
-# 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.
-
-import copy
-
-_common_schema = {
-    'status_code': [200],
-    'response_body': {
-        'type': 'object',
-        'properties': {
-            'certificate': {
-                'type': 'object',
-                'properties': {
-                    'data': {'type': 'string'},
-                    'private_key': {'type': 'string'},
-                },
-                'additionalProperties': False,
-                'required': ['data', 'private_key']
-            }
-        },
-        'additionalProperties': False,
-        'required': ['certificate']
-    }
-}
-
-get_certificate = copy.deepcopy(_common_schema)
-get_certificate['response_body']['properties']['certificate'][
-    'properties']['private_key'].update({'type': 'null'})
-
-create_certificate = copy.deepcopy(_common_schema)
diff --git a/tempest/clients.py b/tempest/clients.py
index 9cdc0a5..4e69424 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -22,6 +22,8 @@
     AvailabilityZoneClient
 from tempest_lib.services.compute.baremetal_nodes_client import \
     BaremetalNodesClient
+from tempest_lib.services.compute.certificates_client import \
+    CertificatesClient
 from tempest_lib.services.identity.v2.token_client import TokenClient
 from tempest_lib.services.identity.v3.token_client import V3TokenClient
 
@@ -33,8 +35,6 @@
 from tempest.services.baremetal.v1.json.baremetal_client import \
     BaremetalClient
 from tempest.services import botoclients
-from tempest.services.compute.json.certificates_client import \
-    CertificatesClient
 from tempest.services.compute.json.extensions_client import \
     ExtensionsClient
 from tempest.services.compute.json.fixed_ips_client import FixedIPsClient
diff --git a/tempest/services/compute/json/certificates_client.py b/tempest/services/compute/json/certificates_client.py
deleted file mode 100644
index d6c72f4..0000000
--- a/tempest/services/compute/json/certificates_client.py
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright 2013 IBM Corp
-# 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 oslo_serialization import jsonutils as json
-
-from tempest.api_schema.response.compute.v2_1 import certificates as schema
-from tempest.common import service_client
-
-
-class CertificatesClient(service_client.ServiceClient):
-
-    def show_certificate(self, certificate_id):
-        url = "os-certificates/%s" % certificate_id
-        resp, body = self.get(url)
-        body = json.loads(body)
-        self.validate_response(schema.get_certificate, resp, body)
-        return service_client.ResponseBody(resp, body)
-
-    def create_certificate(self):
-        """create certificates."""
-        url = "os-certificates"
-        resp, body = self.post(url, None)
-        body = json.loads(body)
-        self.validate_response(schema.create_certificate, resp, body)
-        return service_client.ResponseBody(resp, body)
diff --git a/tempest/tests/common/test_service_clients.py b/tempest/tests/common/test_service_clients.py
index 45de762..3a6d2d3 100644
--- a/tempest/tests/common/test_service_clients.py
+++ b/tempest/tests/common/test_service_clients.py
@@ -17,7 +17,6 @@
 import six
 
 from tempest.services.baremetal.v1.json import baremetal_client
-from tempest.services.compute.json import certificates_client
 from tempest.services.compute.json import extensions_client
 from tempest.services.compute.json import fixed_ips_client
 from tempest.services.compute.json import flavors_client
@@ -106,7 +105,6 @@
     def test_service_client_creations_with_specified_args(self, mock_init):
         test_clients = [
             baremetal_client.BaremetalClient,
-            certificates_client.CertificatesClient,
             extensions_client.ExtensionsClient,
             fixed_ips_client.FixedIPsClient,
             flavors_client.FlavorsClient,
diff --git a/tempest/tests/services/compute/test_certificates_client.py b/tempest/tests/services/compute/test_certificates_client.py
deleted file mode 100644
index 2ba90d0..0000000
--- a/tempest/tests/services/compute/test_certificates_client.py
+++ /dev/null
@@ -1,65 +0,0 @@
-# Copyright 2015 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.
-
-import copy
-
-from tempest_lib.tests import fake_auth_provider
-
-from tempest.services.compute.json import certificates_client
-from tempest.tests.services.compute import base
-
-
-class TestCertificatesClient(base.BaseComputeServiceTest):
-
-    FAKE_CERTIFICATE = {
-        "certificate": {
-            "data": "-----BEGIN----MIICyzCCAjSgAwI----END CERTIFICATE-----\n",
-            "private_key": None
-        }
-    }
-
-    def setUp(self):
-        super(TestCertificatesClient, self).setUp()
-        fake_auth = fake_auth_provider.FakeAuthProvider()
-        self.client = certificates_client.CertificatesClient(
-            fake_auth, 'compute', 'regionOne')
-
-    def _test_show_certificate(self, bytes_body=False):
-        self.check_service_client_function(
-            self.client.show_certificate,
-            'tempest.common.service_client.ServiceClient.get',
-            self.FAKE_CERTIFICATE,
-            bytes_body,
-            certificate_id="fake-id")
-
-    def test_show_certificate_with_str_body(self):
-        self._test_show_certificate()
-
-    def test_show_certificate_with_bytes_body(self):
-        self._test_show_certificate(bytes_body=True)
-
-    def _test_create_certificate(self, bytes_body=False):
-        cert = copy.deepcopy(self.FAKE_CERTIFICATE)
-        cert['certificate']['private_key'] = "my_private_key"
-        self.check_service_client_function(
-            self.client.create_certificate,
-            'tempest.common.service_client.ServiceClient.post',
-            cert,
-            bytes_body)
-
-    def test_create_certificate_with_str_body(self):
-        self._test_create_certificate()
-
-    def test_create_certificate_with_bytes_body(self):
-        self._test_create_certificate(bytes_body=True)