add tests for certificates
this adds both positive and negative tests for create and show certificate Change-Id: I6486838e7cfad322980f95e6ae80ff8947d14b95
This commit is contained in:
parent
06a237dcac
commit
d57f3cf582
|
@ -190,6 +190,7 @@ class BaseV2ComputeTest(BaseComputeTest):
|
|||
cls.services_client = cls.os.services_client
|
||||
cls.hypervisor_client = cls.os.hypervisor_client
|
||||
cls.servers_client_v3_auth = cls.os.servers_client_v3_auth
|
||||
cls.certificates_client = cls.os.certificates_client
|
||||
|
||||
|
||||
class BaseV2ComputeAdminTest(BaseV2ComputeTest):
|
||||
|
|
|
@ -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'
|
|
@ -23,6 +23,8 @@ from tempest.services.compute.json.aggregates_client import \
|
|||
AggregatesClientJSON
|
||||
from tempest.services.compute.json.availability_zone_client import \
|
||||
AvailabilityZoneClientJSON
|
||||
from tempest.services.compute.json.certificates_client import \
|
||||
CertificatesClientJSON
|
||||
from tempest.services.compute.json.extensions_client import \
|
||||
ExtensionsClientJSON
|
||||
from tempest.services.compute.json.fixed_ips_client import FixedIPsClientJSON
|
||||
|
@ -49,6 +51,8 @@ from tempest.services.compute.json.volumes_extensions_client import \
|
|||
from tempest.services.compute.xml.aggregates_client import AggregatesClientXML
|
||||
from tempest.services.compute.xml.availability_zone_client import \
|
||||
AvailabilityZoneClientXML
|
||||
from tempest.services.compute.xml.certificates_client import \
|
||||
CertificatesClientXML
|
||||
from tempest.services.compute.xml.extensions_client import ExtensionsClientXML
|
||||
from tempest.services.compute.xml.fixed_ips_client import FixedIPsClientXML
|
||||
from tempest.services.compute.xml.flavors_client import FlavorsClientXML
|
||||
|
@ -166,6 +170,7 @@ class Manager(object):
|
|||
self.servers_client_v3_auth = None
|
||||
|
||||
if interface == 'xml':
|
||||
self.certificates_client = CertificatesClientXML(*client_args)
|
||||
self.servers_client = ServersClientXML(*client_args)
|
||||
self.limits_client = LimitsClientXML(*client_args)
|
||||
self.images_client = ImagesClientXML(*client_args)
|
||||
|
@ -204,6 +209,7 @@ class Manager(object):
|
|||
*client_args_v3_auth)
|
||||
|
||||
elif interface == 'json':
|
||||
self.certificates_client = CertificatesClientJSON(*client_args)
|
||||
self.servers_client = ServersClientJSON(*client_args)
|
||||
self.limits_client = LimitsClientJSON(*client_args)
|
||||
self.images_client = ImagesClientJSON(*client_args)
|
||||
|
|
|
@ -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']
|
|
@ -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
|
Loading…
Reference in New Issue