diff --git a/doc/api_samples/os-keypairs/keypairs-get-resp.json b/doc/api_samples/os-keypairs/keypairs-get-resp.json deleted file mode 100644 index f1c609c09f0a..000000000000 --- a/doc/api_samples/os-keypairs/keypairs-get-resp.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "keypair": { - "created_at": "2014-05-07T12:06:13.681238", - "deleted": false, - "deleted_at": null, - "fingerprint": "9d:00:f4:d7:26:6e:52:06:4c:c1:d3:1d:fd:06:66:01", - "id": 1, - "name": "keypair-3582d8b7-e588-4aad-b7f7-f4e76f0e4314", - "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDYJrTVpcMwFqQy/oMvtUSRofZdSRHEwrsX8AYkRvn2ZnCXM+b6+GZ2NQuuWj+ocznlnwiGFQDsL/yeE+/kurqcPJFKKp60mToXIMyzioFxW88fJtwEWawHKAclbHWpR1t4fQ4DS+/sIbX/Yd9btlVQ2tpQjodGDbM9Tr9/+/3i6rcR+EoLqmbgCgAiGiVV6VbM2Zx79yUwd+GnQejHX8BlYZoOjCnt3NREsITcmWE9FVFy6TnLmahs3FkEO/QGgWGkaohAJlsgaVvSWGgDn2AujKYwyDokK3dXyeX3m2Vmc3ejiqPa/C4nRrCOlko5nSgV/9IXRx1ERImsqZnE9usB Generated-by-Nova\n", - "updated_at": null, - "user_id": "fake" - } -} \ No newline at end of file diff --git a/doc/api_samples/os-keypairs/keypairs-import-post-req.json b/doc/api_samples/os-keypairs/keypairs-import-post-req.json deleted file mode 100644 index 40df344dc6fb..000000000000 --- a/doc/api_samples/os-keypairs/keypairs-import-post-req.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "keypair": { - "name": "keypair-dab428fe-6186-4a14-b3de-92131f76cd39", - "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDx8nkQv/zgGgB4rMYmIf+6A4l6Rr+o/6lHBQdW5aYd44bd8JttDCE/F/pNRr0lRE+PiqSPO8nDPHw0010JeMH9gYgnnFlyY3/OcJ02RhIPyyxYpv9FhY+2YiUkpwFOcLImyrxEsYXpD/0d3ac30bNH6Sw9JD9UZHYcpSxsIbECHw== Generated-by-Nova" - } -} \ No newline at end of file diff --git a/doc/api_samples/os-keypairs/keypairs-import-post-resp.json b/doc/api_samples/os-keypairs/keypairs-import-post-resp.json deleted file mode 100644 index 20ceb5e945dd..000000000000 --- a/doc/api_samples/os-keypairs/keypairs-import-post-resp.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "keypair": { - "fingerprint": "1e:2c:9b:56:79:4b:45:77:f9:ca:7a:98:2c:b0:d5:3c", - "name": "keypair-dab428fe-6186-4a14-b3de-92131f76cd39", - "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDx8nkQv/zgGgB4rMYmIf+6A4l6Rr+o/6lHBQdW5aYd44bd8JttDCE/F/pNRr0lRE+PiqSPO8nDPHw0010JeMH9gYgnnFlyY3/OcJ02RhIPyyxYpv9FhY+2YiUkpwFOcLImyrxEsYXpD/0d3ac30bNH6Sw9JD9UZHYcpSxsIbECHw== Generated-by-Nova", - "user_id": "fake" - } -} \ No newline at end of file diff --git a/doc/api_samples/os-keypairs/keypairs-list-resp.json b/doc/api_samples/os-keypairs/keypairs-list-resp.json deleted file mode 100644 index c2d59b14bffd..000000000000 --- a/doc/api_samples/os-keypairs/keypairs-list-resp.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "keypairs": [ - { - "keypair": { - "fingerprint": "15:b0:f8:b3:f9:48:63:71:cf:7b:5b:38:6d:44:2d:4a", - "name": "keypair-601a2305-4f25-41ed-89c6-2a966fc8027a", - "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC+Eo/RZRngaGTkFs7I62ZjsIlO79KklKbMXi8F+KITD4bVQHHn+kV+4gRgkgCRbdoDqoGfpaDFs877DYX9n4z6FrAIZ4PES8TNKhatifpn9NdQYWA+IkU8CuvlEKGuFpKRi/k7JLos/gHi2hy7QUwgtRvcefvD/vgQZOVw/mGR9Q== Generated-by-Nova\n" - } - } - ] -} \ No newline at end of file diff --git a/doc/api_samples/os-keypairs/keypairs-post-req.json b/doc/api_samples/os-keypairs/keypairs-post-req.json deleted file mode 100644 index 3ef7dd1f3bee..000000000000 --- a/doc/api_samples/os-keypairs/keypairs-post-req.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "keypair": { - "name": "keypair-7d7c3650-dabe-4eb0-b904-5c464453c043" - } -} \ No newline at end of file diff --git a/doc/api_samples/os-keypairs/keypairs-post-resp.json b/doc/api_samples/os-keypairs/keypairs-post-resp.json deleted file mode 100644 index 5afee037e0f7..000000000000 --- a/doc/api_samples/os-keypairs/keypairs-post-resp.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "keypair": { - "fingerprint": "35:9d:d0:c3:4a:80:d3:d8:86:f1:ca:f7:df:c4:f9:d8", - "name": "keypair-7d7c3650-dabe-4eb0-b904-5c464453c043", - "private_key": "-----BEGIN RSA PRIVATE KEY-----\nMIICXAIBAAKBgQC9mC3WZN9UGLxgPBpP7H5jZMc6pKwOoSgre8yun6REFktn/Kz7\nDUt9jaR1UJyRzHxITfCfAIgSxPdGqB/oF1suMyWgu5i0625vavLB5z5kC8Hq3qZJ\n9zJO1poE1kyD+htiTtPWJ88e12xuH2XB/CZN9OpEiF98hAagiOE0EnOS5QIDAQAB\nAoGAE5XO1mDhORy9COvsg+kYPUhB1GsCYxh+v88wG7HeFDKBY6KUc/Kxo6yoGn5T\nTjRjekyi2KoDZHz4VlIzyZPwFS4I1bf3oCunVoAKzgLdmnTtvRNMC5jFOGc2vUgP\n9bSyRj3S1R4ClVk2g0IDeagko/jc8zzLEYuIK+fbkds79YECQQDt3vcevgegnkga\ntF4NsDmmBPRkcSHCqrANP/7vFcBQN3czxeYYWX3DK07alu6GhH1Y4sHbdm616uU0\nll7xbDzxAkEAzAtN2IyftNygV2EGiaGgqLyo/tD9+Vui2qCQplqe4jvWh/5Sparl\nOjmKo+uAW+hLrLVMnHzRWxbWU8hirH5FNQJATO+ZxCK4etXXAnQmG41NCAqANWB2\nB+2HJbH2NcQ2QHvAHUm741JGn/KI/aBlo7KEjFRDWUVUB5ji64BbUwCsMQJBAIku\nLGcjnBf/oLk+XSPZC2eGd2Ph5G5qYmH0Q2vkTx+wtTn3DV+eNsDfgMtWAJVJ5t61\ngU1QSXyhLPVlKpnnxuUCQC+xvvWjWtsLaFtAsZywJiqLxQzHts8XLGZptYJ5tLWV\nrtmYtBcJCN48RrgQHry/xWYeA4K/AFQpXfNPgprQ96Q=\n-----END RSA PRIVATE KEY-----\n", - "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC9mC3WZN9UGLxgPBpP7H5jZMc6pKwOoSgre8yun6REFktn/Kz7DUt9jaR1UJyRzHxITfCfAIgSxPdGqB/oF1suMyWgu5i0625vavLB5z5kC8Hq3qZJ9zJO1poE1kyD+htiTtPWJ88e12xuH2XB/CZN9OpEiF98hAagiOE0EnOS5Q== Generated-by-Nova\n", - "user_id": "fake" - } -} \ No newline at end of file diff --git a/nova/tests/functional/api_samples/os-keypairs/keypairs-get-resp.json.tpl b/nova/tests/functional/api_samples/os-keypairs/keypairs-get-resp.json.tpl deleted file mode 100644 index 4fde60f14b53..000000000000 --- a/nova/tests/functional/api_samples/os-keypairs/keypairs-get-resp.json.tpl +++ /dev/null @@ -1,13 +0,0 @@ -{ - "keypair": { - "public_key": "%(public_key)s", - "name": "%(keypair_name)s", - "fingerprint": "%(fingerprint)s", - "user_id": "fake", - "deleted": false, - "created_at": "%(strtime)s", - "updated_at": null, - "deleted_at": null, - "id": 1 - } -} diff --git a/nova/tests/functional/api_samples/os-keypairs/keypairs-import-post-req.json.tpl b/nova/tests/functional/api_samples/os-keypairs/keypairs-import-post-req.json.tpl deleted file mode 100644 index 2301fa05b22c..000000000000 --- a/nova/tests/functional/api_samples/os-keypairs/keypairs-import-post-req.json.tpl +++ /dev/null @@ -1,6 +0,0 @@ -{ - "keypair": { - "name": "%(keypair_name)s", - "public_key": "%(public_key)s" - } -} diff --git a/nova/tests/functional/api_samples/os-keypairs/keypairs-import-post-resp.json.tpl b/nova/tests/functional/api_samples/os-keypairs/keypairs-import-post-resp.json.tpl deleted file mode 100644 index ca7192d5dc5d..000000000000 --- a/nova/tests/functional/api_samples/os-keypairs/keypairs-import-post-resp.json.tpl +++ /dev/null @@ -1,8 +0,0 @@ -{ - "keypair": { - "fingerprint": "%(fingerprint)s", - "name": "%(keypair_name)s", - "public_key": "%(public_key)s", - "user_id": "fake" - } -} diff --git a/nova/tests/functional/api_samples/os-keypairs/keypairs-list-resp.json.tpl b/nova/tests/functional/api_samples/os-keypairs/keypairs-list-resp.json.tpl deleted file mode 100644 index 29ba63c00b03..000000000000 --- a/nova/tests/functional/api_samples/os-keypairs/keypairs-list-resp.json.tpl +++ /dev/null @@ -1,11 +0,0 @@ -{ - "keypairs": [ - { - "keypair": { - "fingerprint": "%(fingerprint)s", - "name": "%(keypair_name)s", - "public_key": "%(public_key)s" - } - } - ] -} diff --git a/nova/tests/functional/api_samples/os-keypairs/keypairs-post-req.json.tpl b/nova/tests/functional/api_samples/os-keypairs/keypairs-post-req.json.tpl deleted file mode 100644 index 68e2f03487b7..000000000000 --- a/nova/tests/functional/api_samples/os-keypairs/keypairs-post-req.json.tpl +++ /dev/null @@ -1,5 +0,0 @@ -{ - "keypair": { - "name": "%(keypair_name)s" - } -} diff --git a/nova/tests/functional/api_samples/os-keypairs/keypairs-post-resp.json.tpl b/nova/tests/functional/api_samples/os-keypairs/keypairs-post-resp.json.tpl deleted file mode 100644 index aace6f5ccc23..000000000000 --- a/nova/tests/functional/api_samples/os-keypairs/keypairs-post-resp.json.tpl +++ /dev/null @@ -1,9 +0,0 @@ -{ - "keypair": { - "fingerprint": "%(fingerprint)s", - "name": "%(keypair_name)s", - "private_key": "%(private_key)s", - "public_key": "%(public_key)s", - "user_id": "fake" - } -} diff --git a/nova/tests/functional/test_api_samples.py b/nova/tests/functional/test_api_samples.py index 86013204d516..725b499b3a0a 100644 --- a/nova/tests/functional/test_api_samples.py +++ b/nova/tests/functional/test_api_samples.py @@ -16,7 +16,6 @@ import inspect import os -import uuid as uuid_lib from oslo_config import cfg from oslo_log import log as logging @@ -207,60 +206,6 @@ class LimitsSampleJsonTest(ApiSampleTestBaseV2): self._verify_response('limit-get-resp', subs, response, 200) -class KeyPairsSampleJsonTest(ApiSampleTestBaseV2): - extension_name = "nova.api.openstack.compute.contrib.keypairs.Keypairs" - - def generalize_subs(self, subs, vanilla_regexes): - subs['keypair_name'] = 'keypair-[0-9a-f-]+' - return subs - - def test_keypairs_post(self, public_key=None): - """Get api sample of key pairs post request.""" - key_name = 'keypair-' + str(uuid_lib.uuid4()) - response = self._do_post('os-keypairs', 'keypairs-post-req', - {'keypair_name': key_name}) - subs = self._get_regexes() - subs['keypair_name'] = '(%s)' % key_name - self._verify_response('keypairs-post-resp', subs, response, 200) - # NOTE(maurosr): return the key_name is necessary cause the - # verification returns the label of the last compared information in - # the response, not necessarily the key name. - return key_name - - def test_keypairs_import_key_post(self): - # Get api sample of key pairs post to import user's key. - key_name = 'keypair-' + str(uuid_lib.uuid4()) - subs = { - 'keypair_name': key_name, - 'public_key': "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDx8nkQv/zgGg" - "B4rMYmIf+6A4l6Rr+o/6lHBQdW5aYd44bd8JttDCE/F/pNRr0l" - "RE+PiqSPO8nDPHw0010JeMH9gYgnnFlyY3/OcJ02RhIPyyxYpv" - "9FhY+2YiUkpwFOcLImyrxEsYXpD/0d3ac30bNH6Sw9JD9UZHYc" - "pSxsIbECHw== Generated-by-Nova" - } - response = self._do_post('os-keypairs', 'keypairs-import-post-req', - subs) - subs = self._get_regexes() - subs['keypair_name'] = '(%s)' % key_name - self._verify_response('keypairs-import-post-resp', subs, response, 200) - - def test_keypairs_list(self): - # Get api sample of key pairs list request. - key_name = self.test_keypairs_post() - response = self._do_get('os-keypairs') - subs = self._get_regexes() - subs['keypair_name'] = '(%s)' % key_name - self._verify_response('keypairs-list-resp', subs, response, 200) - - def test_keypairs_get(self): - # Get api sample of key pairs get request. - key_name = self.test_keypairs_post() - response = self._do_get('os-keypairs/%s' % key_name) - subs = self._get_regexes() - subs['keypair_name'] = '(%s)' % key_name - self._verify_response('keypairs-get-resp', subs, response, 200) - - class VirtualInterfacesJsonTest(ServersSampleBase): extension_name = ("nova.api.openstack.compute.contrib" ".virtual_interfaces.Virtual_interfaces") diff --git a/nova/tests/functional/v3/api_sample_base.py b/nova/tests/functional/v3/api_sample_base.py index b9a8df16ab81..7d55e19ce3a5 100644 --- a/nova/tests/functional/v3/api_sample_base.py +++ b/nova/tests/functional/v3/api_sample_base.py @@ -40,7 +40,9 @@ class ApiSampleTestBaseV3(testscenarios.WithScenarios, # TODO(gmann): Below condition is to skip the tests which running # for 'v2' and have not been merged yet. Once all tests are merged # this condition needs to be removed. - if ((self._test == 'v2') and (self._api_version == 'v3')): + if (hasattr(self, '_test') and + (self._test == 'v2') and + (self._api_version == 'v3')): raise testtools.TestCase.skipException('tests are not merged yet') self.flags(use_ipv6=False, osapi_compute_link_prefix=self._get_host(), @@ -60,7 +62,8 @@ class ApiSampleTestBaseV3(testscenarios.WithScenarios, 'osapi_v3') # TODO(gmann): Currently redirecting only merged tests # after merging all tests, second condition needs to be removed. - if ((self._test == 'v2.1') and (self._api_version == 'v2')): + if (not hasattr(self, '_test') or + ((self._test == 'v2.1') and (self._api_version == 'v2'))): # NOTE(gmann)For v2.1 API testing, override /v2 endpoint with v2.1 self.useFixture(api_paste_fixture.ApiPasteFixture()) super(ApiSampleTestBaseV3, self).setUp() diff --git a/nova/tests/functional/v3/test_keypairs.py b/nova/tests/functional/v3/test_keypairs.py index e605e758236f..98216287fd31 100644 --- a/nova/tests/functional/v3/test_keypairs.py +++ b/nova/tests/functional/v3/test_keypairs.py @@ -15,16 +15,30 @@ import uuid +from oslo_config import cfg + from nova.objects import keypair as keypair_obj from nova.tests.functional.v3 import api_sample_base from nova.tests.unit import fake_crypto +CONF = cfg.CONF +CONF.import_opt('osapi_compute_extension', + 'nova.api.openstack.compute.extensions') + class KeyPairsSampleJsonTest(api_sample_base.ApiSampleTestBaseV3): request_api_version = None sample_dir = "keypairs" expected_delete_status_code = 202 expected_post_status_code = 200 + _api_version = 'v2' + + def _get_flags(self): + f = super(KeyPairsSampleJsonTest, self)._get_flags() + f['osapi_compute_extension'] = CONF.osapi_compute_extension[:] + f['osapi_compute_extension'].append( + 'nova.api.openstack.compute.contrib.keypairs.Keypairs') + return f def generalize_subs(self, subs, vanilla_regexes): subs['keypair_name'] = 'keypair-[0-9a-f-]+' @@ -99,6 +113,11 @@ class KeyPairsV22SampleJsonTest(KeyPairsSampleJsonTest): request_api_version = '2.2' expected_post_status_code = 201 expected_delete_status_code = 204 + # NOTE(gmann): microversion tests do not need to run for v2 API + # so defining scenarios only for v2.2 which will run the original tests + # by appending '(v2_2)' in test_id. + scenarios = [('v2_2', {})] + _api_version = 'v2' def test_keypairs_post(self): # NOTE(claudiub): overrides the method with the same name in