Verify certificate API response attributes
Now most attributes of Nova v2/v3 APIs are not checked in Tempest, and this patch adds some tests which check these attributes to block the backward incompatibility change in the future. This patch adds the checks of certificate API responses. The response body of this API is the following: { 'certificate': { 'data': 'Certificate:\n Data:\n Version:...', 'private_key': '-----BEGIN RSA PRIVATE KEY-----\nM...' } } Partially implements blueprint nova-api-attribute-test Change-Id: I5e97cfb5be56b4fa8de5d7262375b5b5b6de1b2a
This commit is contained in:
parent
d0602f0138
commit
ca36c2be99
37
tempest/api_schema/compute/certificates.py
Normal file
37
tempest/api_schema/compute/certificates.py
Normal file
@ -0,0 +1,37 @@
|
||||
# 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'},
|
||||
},
|
||||
'required': ['data', 'private_key'],
|
||||
}
|
||||
},
|
||||
'required': ['certificate'],
|
||||
}
|
||||
}
|
||||
|
||||
get_certificate = copy.deepcopy(_common_schema)
|
||||
get_certificate['response_body']['properties']['certificate'][
|
||||
'properties']['private_key'].update({'type': 'null'})
|
19
tempest/api_schema/compute/v2/certificates.py
Normal file
19
tempest/api_schema/compute/v2/certificates.py
Normal file
@ -0,0 +1,19 @@
|
||||
# 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
|
||||
|
||||
from tempest.api_schema.compute import certificates
|
||||
|
||||
create_certificate = copy.deepcopy(certificates._common_schema)
|
20
tempest/api_schema/compute/v3/certificates.py
Normal file
20
tempest/api_schema/compute/v3/certificates.py
Normal file
@ -0,0 +1,20 @@
|
||||
# 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
|
||||
|
||||
from tempest.api_schema.compute import certificates
|
||||
|
||||
create_certificate = copy.deepcopy(certificates._common_schema)
|
||||
create_certificate['status_code'] = [201]
|
@ -15,6 +15,8 @@
|
||||
|
||||
import json
|
||||
|
||||
from tempest.api_schema.compute import certificates as schema
|
||||
from tempest.api_schema.compute.v2 import certificates as v2schema
|
||||
from tempest.common import rest_client
|
||||
from tempest import config
|
||||
|
||||
@ -31,6 +33,7 @@ class CertificatesClientJSON(rest_client.RestClient):
|
||||
url = "os-certificates/%s" % (id)
|
||||
resp, body = self.get(url)
|
||||
body = json.loads(body)
|
||||
self.validate_response(schema.get_certificate, resp, body)
|
||||
return resp, body['certificate']
|
||||
|
||||
def create_certificate(self):
|
||||
@ -38,4 +41,5 @@ class CertificatesClientJSON(rest_client.RestClient):
|
||||
url = "os-certificates"
|
||||
resp, body = self.post(url, None)
|
||||
body = json.loads(body)
|
||||
self.validate_response(v2schema.create_certificate, resp, body)
|
||||
return resp, body['certificate']
|
||||
|
@ -15,6 +15,8 @@
|
||||
|
||||
import json
|
||||
|
||||
from tempest.api_schema.compute import certificates as schema
|
||||
from tempest.api_schema.compute.v3 import certificates as v3schema
|
||||
from tempest.common import rest_client
|
||||
from tempest import config
|
||||
|
||||
@ -31,6 +33,7 @@ class CertificatesV3ClientJSON(rest_client.RestClient):
|
||||
url = "os-certificates/%s" % (id)
|
||||
resp, body = self.get(url)
|
||||
body = json.loads(body)
|
||||
self.validate_response(schema.get_certificate, resp, body)
|
||||
return resp, body['certificate']
|
||||
|
||||
def create_certificate(self):
|
||||
@ -38,4 +41,5 @@ class CertificatesV3ClientJSON(rest_client.RestClient):
|
||||
url = "os-certificates"
|
||||
resp, body = self.post(url, None)
|
||||
body = json.loads(body)
|
||||
self.validate_response(v3schema.create_certificate, resp, body)
|
||||
return resp, body['certificate']
|
||||
|
Loading…
Reference in New Issue
Block a user