Merge "Validate list_keypair attribute of Nova V2/V3 APIs"
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):