Validate list_keypair attribute of Nova V2/V3 APIs
This patch adds the JSON Schema for response of Nova V2 & V3
list_keypair APIs and validate the response with added JSON Schema to
block the backward incompatibility change in the future.
The response body of V2 & V3 list_keypairs APIs is same and given below:
{
"keypairs": [
{
"keypair": {
"public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD
nPe3MJhEwcQNGZpYRaGYTwY9D9L3pr1c+eqJIP99
mtrUuqTEp3/YPiAzpL0Dem/32WWPOV4DEc27NBMx
rpOi9JJBssDq+6UdK5hMIwrZ/6dZt+CPz+76Lwxn
R1vilVFocis+OC9ddntazV1wrAWGyYL9a83vwcuT
V01FJzSNlYV4hni2vxcgQPkbgt+ldYoTmBS9X3W5
Qy/NrzuG53zHjkYjmz3tjiadZwgffDvjT3SBYWU3
kBGy6gxIs5f/wIvZUSUXGorOJNUw6FubMj4sLfE4
cbHS6W72xs6bmEhqxyjSLQK5fuHE1MgCCDPTd0vq
XdbLnCZ6+l0I8lpDhd Generated by Nova\n",
"name": "test_key",
"fingerprint": "52:53:dd:89:6a:73:c6:18:87:4b:1e:c1:4c
:b8:c3:c9"
}
},
{
"keypair": {
"public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC
9E3tf6msdTyVcytQrs882e4aX3Zhkp1ELIAowspL
OykUbzq21+0JALCxMkUxXig2GCF3jomfWez1frhG
o+Qj/ZgdwJG44k1ZzLswPZn5k5SMQzROTsnzDLXX
f95q6fWZLlfAbF7MA/wd/d/7oBmmrTfaiV27Xq9B8
x/TlWldmMd1Cst6SEYkeVhaynlxaFnrW9sr1nKGec
XSOtVagtUFP4XPxsN1XbAwxZX+ZeWMTYUgliD4+Sm
QevNuWfpHXPSTZ947GMxMythCIPjmZ34W4wq5xVI9
o1MCgL7s2nLUDqYm/DesB+m9MI/ylCpLVqwFDdDHg
rI9x+fRYInsHbUuF Generated by Nova\n",
"name": "test_key2",
"fingerprint": "ea:51:b2:56:85:b3:fb:43:6f:b7:a5:54:b7:
bd:ab:6d"
}
}
]
}
Partially implements blueprint nova-api-attribute-test
Change-Id: Ie500239af2e862c14d49daac0e8018b24c92982b
diff --git a/tempest/api_schema/compute/keypairs.py b/tempest/api_schema/compute/keypairs.py
new file mode 100644
index 0000000..8973c02
--- /dev/null
+++ b/tempest/api_schema/compute/keypairs.py
@@ -0,0 +1,41 @@
+# 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.
+
+list_keypairs = {
+ 'status_code': [200],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'keypairs': {
+ 'type': 'array',
+ 'items': {
+ 'type': 'object',
+ 'properties': {
+ 'keypair': {
+ 'type': 'object',
+ 'properties': {
+ 'public_key': {'type': 'string'},
+ 'name': {'type': 'string'},
+ 'fingerprint': {'type': 'string'}
+ },
+ 'required': ['public_key', 'name', 'fingerprint']
+ }
+ },
+ 'required': ['keypair']
+ }
+ }
+ },
+ 'required': ['keypairs']
+ }
+}
diff --git a/tempest/services/compute/json/keypairs_client.py b/tempest/services/compute/json/keypairs_client.py
index 889e2ed..71f235d 100644
--- a/tempest/services/compute/json/keypairs_client.py
+++ b/tempest/services/compute/json/keypairs_client.py
@@ -15,6 +15,7 @@
import json
+from tempest.api_schema.compute import keypairs as common_schema
from tempest.api_schema.compute.v2 import keypairs as schema
from tempest.common import rest_client
from tempest import config
@@ -36,6 +37,7 @@
# servers, etc. A bug?
# For now we shall adhere to the spec, but the spec for keypairs
# is yet to be found
+ self.validate_response(common_schema.list_keypairs, resp, body)
return resp, body['keypairs']
def get_keypair(self, key_name):
diff --git a/tempest/services/compute/v3/json/keypairs_client.py b/tempest/services/compute/v3/json/keypairs_client.py
index f412e30..d315bc4 100644
--- a/tempest/services/compute/v3/json/keypairs_client.py
+++ b/tempest/services/compute/v3/json/keypairs_client.py
@@ -15,6 +15,7 @@
import json
+from tempest.api_schema.compute import keypairs as common_schema
from tempest.api_schema.compute.v3 import keypairs as schema
from tempest.common import rest_client
from tempest import config
@@ -36,6 +37,7 @@
# servers, etc. A bug?
# For now we shall adhere to the spec, but the spec for keypairs
# is yet to be found
+ self.validate_response(common_schema.list_keypairs, resp, body)
return resp, body['keypairs']
def get_keypair(self, key_name):