Merge "port certificates tests into nova v3 part1"
diff --git a/tempest/api/compute/v3/certificates/__init__.py b/tempest/api/compute/v3/certificates/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/api/compute/v3/certificates/__init__.py
diff --git a/tempest/api/compute/v3/certificates/test_certificates.py b/tempest/api/compute/v3/certificates/test_certificates.py
new file mode 100644
index 0000000..4be1cff
--- /dev/null
+++ b/tempest/api/compute/v3/certificates/test_certificates.py
@@ -0,0 +1,40 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2012 OpenStack Foundation
+# 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.api.compute import base
+from tempest.test import attr
+
+
+class CertificatesTestJSON(base.BaseV2ComputeTest):
+    _interface = 'json'
+
+    @attr(type='gate')
+    def test_create_and_get_root_certificate(self):
+        # create certificates
+        resp, create_body = self.certificates_client.create_certificate()
+        self.assertEqual(200, resp.status)
+        self.assertIn('data', create_body)
+        self.assertIn('private_key', create_body)
+        # get the root certificate
+        resp, body = self.certificates_client.get_certificate('root')
+        self.assertEqual(200, resp.status)
+        self.assertIn('data', body)
+        self.assertIn('private_key', body)
+
+
+class CertificatesTestXML(CertificatesTestJSON):
+    _interface = 'xml'
diff --git a/tempest/services/compute/v3/json/certificates_client.py b/tempest/services/compute/v3/json/certificates_client.py
new file mode 100644
index 0000000..9fdce17
--- /dev/null
+++ b/tempest/services/compute/v3/json/certificates_client.py
@@ -0,0 +1,42 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# 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.
+
+import json
+
+from tempest.common.rest_client import RestClient
+
+
+class CertificatesClientJSON(RestClient):
+
+    def __init__(self, config, username, password, auth_url, tenant_name=None):
+        super(CertificatesClientJSON, self).__init__(config, username,
+                                                     password,
+                                                     auth_url, tenant_name)
+        self.service = self.config.compute.catalog_type
+
+    def get_certificate(self, id):
+        url = "os-certificates/%s" % (id)
+        resp, body = self.get(url)
+        body = json.loads(body)
+        return resp, body['certificate']
+
+    def create_certificate(self):
+        """create certificates."""
+        url = "os-certificates"
+        resp, body = self.post(url, None, self.headers)
+        body = json.loads(body)
+        return resp, body['certificate']
diff --git a/tempest/services/compute/v3/xml/certificates_client.py b/tempest/services/compute/v3/xml/certificates_client.py
new file mode 100644
index 0000000..7523352
--- /dev/null
+++ b/tempest/services/compute/v3/xml/certificates_client.py
@@ -0,0 +1,40 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# 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 tempest.common.rest_client import RestClientXML
+
+
+class CertificatesClientXML(RestClientXML):
+
+    def __init__(self, config, username, password, auth_url, tenant_name=None):
+        super(CertificatesClientXML, self).__init__(config, username, password,
+                                                    auth_url, tenant_name)
+        self.service = self.config.compute.catalog_type
+
+    def get_certificate(self, id):
+        url = "os-certificates/%s" % (id)
+        resp, body = self.get(url, self.headers)
+        body = self._parse_resp(body)
+        return resp, body
+
+    def create_certificate(self):
+        """create certificates."""
+        url = "os-certificates"
+        resp, body = self.post(url, None, self.headers)
+        body = self._parse_resp(body)
+        return resp, body