diff --git a/nova/tests/unit/api/openstack/compute/test_neutron_security_groups.py b/nova/tests/unit/api/openstack/compute/test_neutron_security_groups.py index bb12eb1812..ae50656013 100644 --- a/nova/tests/unit/api/openstack/compute/test_neutron_security_groups.py +++ b/nova/tests/unit/api/openstack/compute/test_neutron_security_groups.py @@ -472,13 +472,6 @@ class _TestNeutronSecurityGroupRulesBase(object): pass -class TestNeutronSecurityGroupRulesV2( - _TestNeutronSecurityGroupRulesBase, - test_security_groups.TestSecurityGroupRulesV2, - TestNeutronSecurityGroupRulesTestCase): - pass - - class TestNeutronSecurityGroupRulesV21( _TestNeutronSecurityGroupRulesBase, test_security_groups.TestSecurityGroupRulesV21, diff --git a/nova/tests/unit/api/openstack/compute/test_pause_server.py b/nova/tests/unit/api/openstack/compute/test_pause_server.py index 3ed1747124..8e96c6f994 100644 --- a/nova/tests/unit/api/openstack/compute/test_pause_server.py +++ b/nova/tests/unit/api/openstack/compute/test_pause_server.py @@ -13,8 +13,6 @@ # License for the specific language governing permissions and limitations # under the License. -from nova.api.openstack.compute.legacy_v2.contrib import admin_actions as \ - pause_server_v2 from nova.api.openstack.compute import pause_server as \ pause_server_v21 from nova import exception @@ -66,15 +64,6 @@ class PauseServerTestsV21(admin_only_action_common.CommonTests): self._test_actions_with_locked_instance(['_pause', '_unpause']) -class PauseServerTestsV2(PauseServerTestsV21): - pause_server = pause_server_v2 - controller_name = 'AdminActionsController' - _api_version = '2' - - def test_actions_raise_on_not_implemented(self): - pass - - class PauseServerPolicyEnforcementV21(test.NoDBTestCase): def setUp(self): diff --git a/nova/tests/unit/api/openstack/compute/test_quota_classes.py b/nova/tests/unit/api/openstack/compute/test_quota_classes.py index 9295f820f1..88a1d1a9eb 100644 --- a/nova/tests/unit/api/openstack/compute/test_quota_classes.py +++ b/nova/tests/unit/api/openstack/compute/test_quota_classes.py @@ -16,10 +16,8 @@ import webob from nova.api.openstack.compute import extension_info -from nova.api.openstack.compute.legacy_v2.contrib import quota_classes from nova.api.openstack.compute import quota_classes \ as quota_classes_v21 -from nova.api.openstack import extensions from nova import exception from nova import test from nova.tests.unit.api.openstack import fakes @@ -141,26 +139,6 @@ class QuotaClassSetsTestV21(test.TestCase): self.req, 'test_class', body=body) -class QuotaClassSetsTestV2(QuotaClassSetsTestV21): - validation_error = webob.exc.HTTPBadRequest - - def _setup(self): - ext_mgr = extensions.ExtensionManager() - ext_mgr.extensions = {} - self.req = fakes.HTTPRequest.blank('', use_admin_context=True) - self.non_admin_req = fakes.HTTPRequest.blank('') - self.controller = quota_classes.QuotaClassSetsController(ext_mgr) - - def test_quotas_show_as_unauthorized_user(self): - self.assertRaises(webob.exc.HTTPForbidden, self.controller.show, - self.non_admin_req, 'test_class') - - def test_quotas_update_as_user(self): - body = {'quota_class_set': {}} - self.assertRaises(webob.exc.HTTPForbidden, self.controller.update, - self.non_admin_req, 'test_class', body=body) - - class QuotaClassesPolicyEnforcementV21(test.NoDBTestCase): def setUp(self): diff --git a/nova/tests/unit/api/openstack/compute/test_quotas.py b/nova/tests/unit/api/openstack/compute/test_quotas.py index 019de2116c..090a8f9bc2 100644 --- a/nova/tests/unit/api/openstack/compute/test_quotas.py +++ b/nova/tests/unit/api/openstack/compute/test_quotas.py @@ -14,12 +14,9 @@ # License for the specific language governing permissions and limitations # under the License. -import copy - import mock import webob -from nova.api.openstack.compute.legacy_v2.contrib import quotas as quotas_v2 from nova.api.openstack.compute import quota_sets as quotas_v21 from nova.api.openstack import extensions from nova import db @@ -44,29 +41,10 @@ def quota_set(id, include_server_group_quotas=True): class BaseQuotaSetsTest(test.TestCase): - def _is_v20_api_test(self): - # NOTE(oomichi): If a test is for v2.0 API, this method returns - # True. Otherwise(v2.1 API test), returns False. - return (self.plugin == quotas_v2) - - def setup_mock_for_show(self): - if self._is_v20_api_test(): - self.ext_mgr.is_loaded('os-user-quotas').AndReturn(True) - self.mox.ReplayAll() - - def setup_mock_for_update(self): - if self._is_v20_api_test(): - self.ext_mgr.is_loaded('os-extended-quotas').AndReturn(True) - self.ext_mgr.is_loaded('os-user-quotas').AndReturn(True) - self.mox.ReplayAll() - def get_delete_status_int(self, res): - if self._is_v20_api_test(): - return res.status_int - else: - # NOTE: on v2.1, http status code is set as wsgi_code of API - # method instead of status_int in a response object. - return self.controller.delete.wsgi_code + # NOTE: on v2.1, http status code is set as wsgi_code of API + # method instead of status_int in a response object. + return self.controller.delete.wsgi_code class QuotaSetsTestV21(BaseQuotaSetsTest): @@ -184,7 +162,6 @@ class QuotaSetsTestV21(BaseQuotaSetsTest): self.assertEqual(res_dict, expected) def test_quotas_show(self): - self.setup_mock_for_show() req = self._get_http_request() res_dict = self.controller.show(req, 1234) @@ -192,7 +169,6 @@ class QuotaSetsTestV21(BaseQuotaSetsTest): self.assertEqual(res_dict, ref_quota_set) def test_quotas_update(self): - self.setup_mock_for_update() self.default_quotas.update({ 'instances': 50, 'cores': 50 @@ -204,7 +180,6 @@ class QuotaSetsTestV21(BaseQuotaSetsTest): @mock.patch('nova.objects.Quotas.create_limit') def test_quotas_update_with_good_data(self, mock_createlimit): - self.setup_mock_for_update() self.default_quotas.update({}) body = {'quota_set': self.default_quotas} req = self._get_http_request() @@ -216,7 +191,6 @@ class QuotaSetsTestV21(BaseQuotaSetsTest): @mock.patch('nova.objects.Quotas.create_limit') def test_quotas_update_with_bad_data(self, mock_createlimit, mock_validate): - self.setup_mock_for_update() self.default_quotas.update({ 'instances': 50, 'cores': -50 @@ -229,7 +203,6 @@ class QuotaSetsTestV21(BaseQuotaSetsTest): len(mock_createlimit.mock_calls)) def test_quotas_update_zero_value(self): - self.setup_mock_for_update() body = {'quota_set': {'instances': 0, 'cores': 0, 'ram': 0, 'floating_ips': 0, 'metadata_items': 0, @@ -248,7 +221,6 @@ class QuotaSetsTestV21(BaseQuotaSetsTest): self.assertEqual(body, res_dict) def _quotas_update_bad_request_case(self, body): - self.setup_mock_for_update() req = self._get_http_request() self.assertRaises(self.validation_error, self.controller.update, req, 'update_me', body=body) @@ -296,8 +268,6 @@ class QuotaSetsTestV21(BaseQuotaSetsTest): self._quotas_update_bad_request_case(body) def test_quotas_delete(self): - if self._is_v20_api_test(): - self.ext_mgr.is_loaded('os-extended-quotas').AndReturn(True) req = self._get_http_request() self.mox.StubOutWithMock(quota.QUOTAS, "destroy_all_by_project") @@ -315,7 +285,6 @@ class ExtendedQuotasTestV21(BaseQuotaSetsTest): def setUp(self): super(ExtendedQuotasTestV21, self).setUp() self._setup_controller() - self.setup_mock_for_update() fake_quotas = {'ram': {'limit': 51200, 'in_use': 12800, @@ -424,14 +393,12 @@ class UserQuotasTestV21(BaseQuotaSetsTest): self.controller = self.plugin.QuotaSetsController(self.ext_mgr) def test_user_quotas_show(self): - self.setup_mock_for_show() req = self._get_http_request('/v2/fake4/os-quota-sets/1234?user_id=1') res_dict = self.controller.show(req, 1234) ref_quota_set = quota_set('1234', self.include_server_group_quotas) self.assertEqual(res_dict, ref_quota_set) def test_user_quotas_update(self): - self.setup_mock_for_update() body = {'quota_set': {'instances': 10, 'cores': 20, 'ram': 51200, 'floating_ips': 10, 'fixed_ips': -1, 'metadata_items': 128, @@ -452,7 +419,6 @@ class UserQuotasTestV21(BaseQuotaSetsTest): self.assertEqual(body, res_dict) def test_user_quotas_update_exceed_project(self): - self.setup_mock_for_update() body = {'quota_set': {'instances': 20}} url = '/v2/fake4/os-quota-sets/update_me?user_id=1' @@ -461,9 +427,6 @@ class UserQuotasTestV21(BaseQuotaSetsTest): req, 'update_me', body=body) def test_user_quotas_delete(self): - if self._is_v20_api_test(): - self.ext_mgr.is_loaded('os-extended-quotas').AndReturn(True) - self.ext_mgr.is_loaded('os-user-quotas').AndReturn(True) url = '/v2/fake4/os-quota-sets/1234?user_id=1' req = self._get_http_request(url) self.mox.StubOutWithMock(quota.QUOTAS, @@ -477,7 +440,6 @@ class UserQuotasTestV21(BaseQuotaSetsTest): @mock.patch('nova.objects.Quotas.create_limit') def test_user_quotas_update_good_data(self, mock_createlimit): - self.setup_mock_for_update() body = {'quota_set': {'instances': 1, 'cores': 1}} @@ -489,7 +451,6 @@ class UserQuotasTestV21(BaseQuotaSetsTest): @mock.patch('nova.objects.Quotas.create_limit') def test_user_quotas_update_bad_data(self, mock_createlimit): - self.setup_mock_for_update() body = {'quota_set': {'instances': 20, 'cores': 1}} @@ -501,201 +462,6 @@ class UserQuotasTestV21(BaseQuotaSetsTest): len(mock_createlimit.mock_calls)) -class QuotaSetsTestV2(QuotaSetsTestV21): - plugin = quotas_v2 - validation_error = webob.exc.HTTPBadRequest - - def _setup_controller(self): - self.ext_mgr = self.mox.CreateMock(extensions.ExtensionManager) - self.ext_mgr.is_loaded('os-server-group-quotas').MultipleTimes().\ - AndReturn(self.include_server_group_quotas) - self.mox.ReplayAll() - self.controller = self.plugin.QuotaSetsController(self.ext_mgr) - self.mox.ResetAll() - - def _get_http_request(self, url=''): - return fakes.HTTPRequest.blank(url, use_admin_context=True) - - # NOTE: The following tests are tricky and v2.1 API does not allow - # this kind of input by strong input validation. Just for test coverage, - # we keep them now. - def test_quotas_update_invalid_value_json_fromat_empty_string(self): - self.setup_mock_for_update() - self.default_quotas.update({ - 'instances': 50, - 'cores': 50 - }) - expected_resp = {'quota_set': self.default_quotas} - - # when PUT JSON format with empty string for quota - body = copy.deepcopy(expected_resp) - body['quota_set']['ram'] = '' - req = fakes.HTTPRequest.blank('/v2/fake4/os-quota-sets/update_me', - use_admin_context=True) - res_dict = self.controller.update(req, 'update_me', body) - self.assertEqual(res_dict, expected_resp) - - def test_quotas_update_invalid_value_xml_fromat_empty_string(self): - self.default_quotas.update({ - 'instances': 50, - 'cores': 50 - }) - expected_resp = {'quota_set': self.default_quotas} - - # when PUT XML format with empty string for quota - body = copy.deepcopy(expected_resp) - body['quota_set']['ram'] = {} - req = fakes.HTTPRequest.blank('/v2/fake4/os-quota-sets/update_me', - use_admin_context=True) - self.setup_mock_for_update() - res_dict = self.controller.update(req, 'update_me', body) - self.assertEqual(res_dict, expected_resp) - - # NOTE: os-extended-quotas and os-user-quotas are only for v2.0. - # On v2.1, these features are always enable. So we need the following - # tests only for v2.0. - def test_delete_quotas_when_extension_not_loaded(self): - self.ext_mgr.is_loaded('os-extended-quotas').AndReturn(False) - self.mox.ReplayAll() - req = fakes.HTTPRequest.blank('/v2/fake4/os-quota-sets/1234') - self.assertRaises(webob.exc.HTTPNotFound, self.controller.delete, - req, 1234) - - def test_delete_user_quotas_when_extension_not_loaded(self): - self.ext_mgr.is_loaded('os-extended-quotas').AndReturn(True) - self.ext_mgr.is_loaded('os-user-quotas').AndReturn(False) - self.mox.ReplayAll() - req = fakes.HTTPRequest.blank('/v2/fake4/os-quota-sets/1234?user_id=1') - self.assertRaises(webob.exc.HTTPNotFound, self.controller.delete, - req, 1234) - - def test_quotas_delete_as_unauthorized_user(self): - if self._is_v20_api_test(): - self.ext_mgr.is_loaded('os-extended-quotas').AndReturn(True) - self.mox.ReplayAll() - req = fakes.HTTPRequest.blank('/v2/fake4/os-quota-sets/1234') - self.assertRaises(webob.exc.HTTPForbidden, self.controller.delete, - req, 1234) - - def test_quotas_show_as_unauthorized_user(self): - self.setup_mock_for_show() - req = fakes.HTTPRequest.blank('/v2/fake4/os-quota-sets/1234') - self.assertRaises(webob.exc.HTTPForbidden, self.controller.show, - req, 1234) - - def test_quotas_update_as_user(self): - self.default_quotas.update({ - 'instances': 50, - 'cores': 50 - }) - body = {'quota_set': self.default_quotas} - - req = fakes.HTTPRequest.blank('/v2/fake4/os-quota-sets/update_me') - self.assertRaises(webob.exc.HTTPForbidden, self.controller.update, - req, 'update_me', body=body) - - -class QuotaSetsTestV2WithoutServerGroupQuotas(QuotaSetsTestV2): - include_server_group_quotas = False - - # NOTE: os-server-group-quotas is only for v2.0. On v2.1 this feature - # is always enabled, so this test is only needed for v2.0 - def test_quotas_update_without_server_group_quotas_extenstion(self): - self.setup_mock_for_update() - self.default_quotas.update({ - 'server_groups': 50, - 'sever_group_members': 50 - }) - body = {'quota_set': self.default_quotas} - - req = fakes.HTTPRequest.blank('/v2/fake4/os-quota-sets/update_me', - use_admin_context=True) - self.assertRaises(webob.exc.HTTPBadRequest, self.controller.update, - req, 'update_me', body=body) - - -class ExtendedQuotasTestV2(ExtendedQuotasTestV21): - plugin = quotas_v2 - - def _setup_controller(self): - self.ext_mgr = self.mox.CreateMock(extensions.ExtensionManager) - self.ext_mgr.is_loaded('os-server-group-quotas').MultipleTimes().\ - AndReturn(False) - self.mox.ReplayAll() - self.controller = self.plugin.QuotaSetsController(self.ext_mgr) - self.mox.ResetAll() - - def _get_http_request(self, url=''): - return fakes.HTTPRequest.blank(url, use_admin_context=True) - - -class UserQuotasTestV2(UserQuotasTestV21): - plugin = quotas_v2 - - def _setup_controller(self): - self.ext_mgr = self.mox.CreateMock(extensions.ExtensionManager) - self.ext_mgr.is_loaded('os-server-group-quotas').MultipleTimes().\ - AndReturn(self.include_server_group_quotas) - self.mox.ReplayAll() - self.controller = self.plugin.QuotaSetsController(self.ext_mgr) - self.mox.ResetAll() - - def _get_http_request(self, url=''): - return fakes.HTTPRequest.blank(url, use_admin_context=True) - - def test_user_quotas_delete_with_non_admin(self): - self.setup_mock_for_update() - req = fakes.HTTPRequest.blank('/v2/fake4/os-quota-sets/1234?user_id=1') - self.assertRaises(webob.exc.HTTPForbidden, self.controller.delete, - req, '1234') - - def test_user_quotas_show_as_unauthorized_user(self): - self.setup_mock_for_show() - req = fakes.HTTPRequest.blank('/v2/fake4/os-quota-sets/1234?user_id=1') - self.assertRaises(webob.exc.HTTPForbidden, self.controller.show, - req, 1234) - - def test_user_quotas_update_as_user(self): - body = {'quota_set': {'instances': 10, 'cores': 20, - 'ram': 51200, 'floating_ips': 10, - 'fixed_ips': -1, 'metadata_items': 128, - 'injected_files': 5, - 'injected_file_content_bytes': 10240, - 'key_pairs': 100, - 'security_groups': 10, - 'security_group_rules': 20}} - - url = '/v2/fake4/os-quota-sets/update_me?user_id=1' - req = fakes.HTTPRequest.blank(url) - self.assertRaises(webob.exc.HTTPForbidden, self.controller.update, - req, 'update_me', body=body) - - -class UserQuotasTestV2WithoutServerGroupQuotas(UserQuotasTestV2): - include_server_group_quotas = False - - # NOTE: os-server-group-quotas is only for v2.0. On v2.1 this feature - # is always enabled, so this test is only needed for v2.0 - def test_user_quotas_update_as_admin_without_sg_quota_extension(self): - self.setup_mock_for_update() - body = {'quota_set': {'instances': 10, 'cores': 20, - 'ram': 51200, 'floating_ips': 10, - 'fixed_ips': -1, 'metadata_items': 128, - 'injected_files': 5, - 'injected_file_content_bytes': 10240, - 'injected_file_path_bytes': 255, - 'security_groups': 10, - 'security_group_rules': 20, - 'key_pairs': 100, - 'server_groups': 100, - 'server_group_members': 200}} - - url = '/v2/fake4/os-quota-sets/update_me?user_id=1' - req = fakes.HTTPRequest.blank(url, use_admin_context=True) - self.assertRaises(webob.exc.HTTPBadRequest, self.controller.update, - req, 'update_me', body=body) - - class QuotaSetsPolicyEnforcementV21(test.NoDBTestCase): def setUp(self): diff --git a/nova/tests/unit/api/openstack/compute/test_remote_consoles.py b/nova/tests/unit/api/openstack/compute/test_remote_consoles.py index b41c65f5a8..009b2d1a28 100644 --- a/nova/tests/unit/api/openstack/compute/test_remote_consoles.py +++ b/nova/tests/unit/api/openstack/compute/test_remote_consoles.py @@ -17,8 +17,6 @@ import mock import webob from nova.api.openstack import api_version_request -from nova.api.openstack.compute.legacy_v2.contrib import consoles \ - as console_v2 from nova.api.openstack.compute import remote_consoles \ as console_v21 from nova.compute import api as compute_api @@ -607,20 +605,6 @@ class ConsolesExtensionTestV28(ConsolesExtensionTestV26): 'webmks') -class ConsolesExtensionTestV2(ConsolesExtensionTestV21): - controller_class = console_v2.ConsolesController - validation_error = webob.exc.HTTPBadRequest - - def test_get_vnc_console_with_undefined_param(self): - pass - - def test_get_spice_console_with_undefined_param(self): - pass - - def test_get_rdp_console_with_undefined_param(self): - pass - - class TestRemoteConsolePolicyEnforcementV21(test.NoDBTestCase): def setUp(self): diff --git a/nova/tests/unit/api/openstack/compute/test_rescue.py b/nova/tests/unit/api/openstack/compute/test_rescue.py index 1ab3146d92..bd1a3dccae 100644 --- a/nova/tests/unit/api/openstack/compute/test_rescue.py +++ b/nova/tests/unit/api/openstack/compute/test_rescue.py @@ -15,9 +15,7 @@ import mock import webob -from nova.api.openstack.compute.legacy_v2.contrib import rescue as rescue_v2 from nova.api.openstack.compute import rescue as rescue_v21 -from nova.api.openstack import extensions from nova import compute import nova.conf from nova import exception @@ -198,24 +196,6 @@ class RescueTestV21(test.NoDBTestCase): self.fake_req, UUID, body=body) -class RescueTestV20(RescueTestV21): - - def _set_up_controller(self): - ext_mgr = extensions.ExtensionManager() - ext_mgr.extensions = {'os-extended-rescue-with-image': 'fake'} - return rescue_v2.RescueController(ext_mgr) - - def test_rescue_with_invalid_property(self): - # NOTE(cyeoh): input validation in original v2 code does not - # check for invalid properties. - pass - - def test_rescue_disable_password(self): - # NOTE(cyeoh): Original v2.0 code does not support disabling - # the admin password being returned through a conf setting - pass - - class RescuePolicyEnforcementV21(test.NoDBTestCase): def setUp(self): diff --git a/nova/tests/unit/api/openstack/compute/test_scheduler_hints.py b/nova/tests/unit/api/openstack/compute/test_scheduler_hints.py index e138cf368a..7a8e636661 100644 --- a/nova/tests/unit/api/openstack/compute/test_scheduler_hints.py +++ b/nova/tests/unit/api/openstack/compute/test_scheduler_hints.py @@ -15,18 +15,14 @@ import datetime -import mock from oslo_config import cfg from oslo_serialization import jsonutils from nova.api.openstack import compute from nova.api.openstack.compute import extension_info -from nova.api.openstack.compute.legacy_v2 import servers as servers_v2 from nova.api.openstack.compute import servers as servers_v21 -from nova.api.openstack import extensions import nova.compute.api from nova.compute import flavors -from nova import exception from nova import test from nova.tests.unit.api.openstack import fakes from nova.tests.unit import fake_instance @@ -144,36 +140,6 @@ class SchedulerHintsTestCaseV21(test.TestCase): self._create_server_with_scheduler_hints_bad_request(param) -class SchedulerHintsTestCaseV2(SchedulerHintsTestCaseV21): - - def _set_up_router(self): - self.flags( - osapi_compute_extension=[ - 'nova.api.openstack.compute.contrib.select_extensions'], - osapi_compute_ext_list=['Scheduler_hints']) - self.app = compute.APIRouter(init_only=('servers',)) - - def _get_request(self): - return fakes.HTTPRequest.blank('/fake/servers') - - def test_create_server_bad_hints_long_group(self): - # NOTE: v2.0 API cannot handle this bad request case now. - # We skip this test for v2.0. - pass - - def test_create_server_with_bad_different_host_hint(self): - # NOTE: v2.0 API cannot handle this bad request case now. - # We skip this test for v2.0. - pass - - @mock.patch( - 'nova.api.openstack.compute.legacy_v2.servers.Controller.create') - def test_create_server_with_non_uuid_group_hint(self, mock_create): - mock_create.side_effect = exception.InvalidInput(reason='') - self._create_server_with_scheduler_hints_bad_request( - {'group': 'non-uuid'}) - - class ServersControllerCreateTestV21(test.TestCase): def setUp(self): @@ -249,18 +215,3 @@ class ServersControllerCreateTestV21(test.TestCase): self.stubs.Set(nova.compute.api.API, 'create', create) self._test_create_extra(params) - - -class ServersControllerCreateTestV2(ServersControllerCreateTestV21): - - def _set_up_controller(self): - self.ext_mgr = extensions.ExtensionManager() - self.ext_mgr.extensions = {} - self.no_scheduler_hints_controller = servers_v2.Controller( - self.ext_mgr) - - def _verify_availability_zone(self, **kwargs): - self.assertEqual(kwargs['scheduler_hints'], {}) - - def _get_request(self): - return fakes.HTTPRequest.blank('/fake/servers') diff --git a/nova/tests/unit/api/openstack/compute/test_security_group_default_rules.py b/nova/tests/unit/api/openstack/compute/test_security_group_default_rules.py index 3f254892d5..0f35168cb0 100644 --- a/nova/tests/unit/api/openstack/compute/test_security_group_default_rules.py +++ b/nova/tests/unit/api/openstack/compute/test_security_group_default_rules.py @@ -15,8 +15,6 @@ import mock import webob -from nova.api.openstack.compute.legacy_v2.contrib import \ - security_group_default_rules as security_group_default_rules_v2 from nova.api.openstack.compute import \ security_group_default_rules as security_group_default_rules_v21 from nova import context @@ -82,11 +80,6 @@ class TestSecurityGroupDefaultRulesNeutronV21(test.TestCase): req, '602ed77c-a076-4f9b-a617-f93b847b62c5') -class TestSecurityGroupDefaultRulesNeutronV2(test.TestCase): - controller_cls = (security_group_default_rules_v2. - SecurityGroupDefaultRulesController) - - class TestSecurityGroupDefaultRulesV21(test.TestCase): controller_cls = (security_group_default_rules_v21. SecurityGroupDefaultRulesController) @@ -315,30 +308,6 @@ class TestSecurityGroupDefaultRulesV21(test.TestCase): self.assertEqual(sgr['cidr'], security_group_rule.cidr) -class TestSecurityGroupDefaultRulesV2(test.TestCase): - controller_cls = (security_group_default_rules_v2. - SecurityGroupDefaultRulesController) - - def setUp(self): - super(TestSecurityGroupDefaultRulesV2, self).setUp() - self.req = fakes.HTTPRequest.blank( - '/v2/fake/os-security-group-default-rules', use_admin_context=True) - self.non_admin_req = fakes.HTTPRequest.blank( - '/v2/fake/os-security-group-default-rules') - - def test_create_security_group_default_rules_with_non_admin(self): - self.controller = self.controller_cls() - sgr = security_group_default_rule_template() - sgr_dict = dict(security_group_default_rule=sgr) - self.assertRaises(exception.AdminRequired, self.controller.create, - self.non_admin_req, sgr_dict) - - def test_delete_security_group_default_rules_with_non_admin(self): - self.controller = self.controller_cls() - self.assertRaises(exception.AdminRequired, - self.controller.delete, self.non_admin_req, 1) - - class SecurityGroupDefaultRulesPolicyEnforcementV21(test.NoDBTestCase): def setUp(self): diff --git a/nova/tests/unit/api/openstack/compute/test_security_groups.py b/nova/tests/unit/api/openstack/compute/test_security_groups.py index 3ffec9b9b0..24d9f11ab5 100644 --- a/nova/tests/unit/api/openstack/compute/test_security_groups.py +++ b/nova/tests/unit/api/openstack/compute/test_security_groups.py @@ -19,8 +19,6 @@ from oslo_serialization import jsonutils from oslo_utils import encodeutils import webob -from nova.api.openstack.compute.legacy_v2.contrib import security_groups as \ - secgroups_v2 from nova.api.openstack.compute import security_groups as \ secgroups_v21 from nova.api.openstack import wsgi @@ -781,12 +779,6 @@ class TestSecurityGroupsV21(test.TestCase): mock.ANY) -class TestSecurityGroupsV2(TestSecurityGroupsV21): - secgrp_ctl_cls = secgroups_v2.SecurityGroupController - server_secgrp_ctl_cls = secgroups_v2.ServerSecurityGroupController - secgrp_act_ctl_cls = secgroups_v2.SecurityGroupActionController - - class TestSecurityGroupRulesV21(test.TestCase): secgrp_ctl_cls = secgroups_v21.SecurityGroupRulesController @@ -1262,10 +1254,6 @@ class TestSecurityGroupRulesV21(test.TestCase): self.req, {'security_group_rule': rule}) -class TestSecurityGroupRulesV2(TestSecurityGroupRulesV21): - secgrp_ctl_cls = secgroups_v2.SecurityGroupRulesController - - UUID1 = '00000000-0000-0000-0000-000000000001' UUID2 = '00000000-0000-0000-0000-000000000002' UUID3 = '00000000-0000-0000-0000-000000000003' @@ -1397,12 +1385,6 @@ class SecurityGroupsOutputTestV21(test.TestCase): self.assertEqual(res.status_int, 404) -class SecurityGroupsOutputTestV2(SecurityGroupsOutputTestV21): - - def _setup_app(self): - return fakes.wsgi_app(init_only=('servers',)) - - class SecurityGroupsOutputPolicyEnforcementV21(test.NoDBTestCase): def setUp(self): diff --git a/nova/tests/unit/api/openstack/compute/test_server_actions.py b/nova/tests/unit/api/openstack/compute/test_server_actions.py index 8367b56d47..b6af65ca6a 100644 --- a/nova/tests/unit/api/openstack/compute/test_server_actions.py +++ b/nova/tests/unit/api/openstack/compute/test_server_actions.py @@ -13,17 +13,14 @@ # License for the specific language governing permissions and limitations # under the License. -import base64 import uuid import mock from mox3 import mox -from oslo_policy import policy as oslo_policy from oslo_utils import uuidutils import webob from nova.api.openstack.compute import extension_info -from nova.api.openstack.compute.legacy_v2 import servers as servers_v2 from nova.api.openstack.compute import servers as servers_v21 from nova.compute import api as compute_api from nova.compute import task_states @@ -32,7 +29,6 @@ import nova.conf from nova import exception from nova.image import glance from nova import objects -from nova import policy from nova import test from nova.tests.unit.api.openstack import fakes from nova.tests.unit import fake_block_device @@ -180,10 +176,6 @@ class ServerActionsControllerTestV21(test.TestCase): '_action_rebuild': ((self.image_uuid, 'TNc53Dr8s7vw'), {})} - if self.servers == servers_v2: - args_map['_action_rebuild'] = ((self.image_uuid, 'TNc53Dr8s7vw'), - {'files_to_inject': None}) - for action in actions: method = method_translations.get(action) self.mox.StubOutWithMock(compute_api.API, method) @@ -1194,168 +1186,3 @@ class ServerActionsControllerTestV21(test.TestCase): self.assertRaises(webob.exc.HTTPConflict, self.controller._action_create_image, self.req, FAKE_UUID, body=body) - - -class ServerActionsControllerTestV2(ServerActionsControllerTestV21): - image_base_url = 'http://localhost/v2/fake/images/' - servers = servers_v2 - validation_error = webob.exc.HTTPBadRequest - request_too_large_error = webob.exc.HTTPRequestEntityTooLarge - image_url = 'http://localhost/v2/fake/images/' - - def _get_controller(self): - class FakeExtManager(object): - def is_loaded(self, ext): - return False - - return self.servers.Controller(ext_mgr=FakeExtManager()) - - def _set_fake_extension(self): - def fake_is_loaded(ext): - return ext == 'os-preserve-ephemeral-rebuild' - self.stubs.Set(self.controller.ext_mgr, 'is_loaded', fake_is_loaded) - - def _rebuild(self, context, image_ref, value=None): - if value is not None: - compute_api.API.rebuild(context, mox.IgnoreArg(), image_ref, - mox.IgnoreArg(), preserve_ephemeral=value, - files_to_inject=None) - else: - compute_api.API.rebuild(context, mox.IgnoreArg(), image_ref, - mox.IgnoreArg(), files_to_inject=None) - - def _stub_instance_get(self, uuid=None): - self.mox.StubOutWithMock(compute_api.API, 'get') - if uuid is None: - uuid = uuidutils.generate_uuid() - instance = fake_instance.fake_db_instance( - id=1, uuid=uuid, vm_state=vm_states.ACTIVE, task_state=None) - instance = objects.Instance._from_db_object( - self.context, objects.Instance(), instance) - - self.compute_api.get(self.context, uuid, - expected_attrs=['flavor'], - want_objects=True).AndReturn(instance) - return instance - - def test_rebuild_bad_personality(self): - body = { - "rebuild": { - "imageRef": self._image_href, - "personality": [{ - "path": "/path/to/file", - "contents": "INVALID b64", - }] - }, - } - - self.assertRaises(webob.exc.HTTPBadRequest, - self.controller._action_rebuild, - self.req, FAKE_UUID, body=body) - - def test_rebuild_personality(self): - body = { - "rebuild": { - "imageRef": self._image_href, - "personality": [{ - "path": "/path/to/file", - "contents": base64.b64encode("Test String"), - }] - }, - } - - body = self.controller._action_rebuild(self.req, FAKE_UUID, - body=body).obj - - self.assertNotIn('personality', body['server']) - - def test_resize_server_with_extra_arg(self): - # NOTE: v2.0 API cannot cover this case, skip this. - pass - - def test_resize_server_invalid_flavor_ref(self): - # NOTE: v2.0 API cannot cover this case, skip this. - pass - - def test_create_image_glance_link_prefix(self): - self.flags(osapi_glance_link_prefix='https://glancehost') - body = { - 'createImage': { - 'name': 'Snapshot 1', - }, - } - - response = self.controller._action_create_image(self.req, FAKE_UUID, - body=body) - - location = response.headers['Location'] - self.assertEqual('https://glancehost/v2/fake/images/123', location) - - def test_rebuild_preserve_ephemeral_is_ignored_when_ext_not_loaded(self): - return_server = fakes.fake_instance_get(image_ref='2', - vm_state=vm_states.ACTIVE, - host='fake_host') - self.stub_out('nova.db.instance_get_by_uuid', return_server) - - body = { - "rebuild": { - "imageRef": self._image_href, - "preserve_ephemeral": False, - }, - } - - self.mox.StubOutWithMock(compute_api.API, 'rebuild') - compute_api.API.rebuild(self.context, mox.IgnoreArg(), - self._image_href, - mox.IgnoreArg(), files_to_inject=None) - self.mox.ReplayAll() - - self.controller._action_rebuild(self.req, FAKE_UUID, body) - - def test_create_vol_backed_img_snapshotting_policy_blocks_project(self): - """Don't permit a snapshot of a volume backed instance if configured - not to based on project - """ - body = { - 'createImage': { - 'name': 'Snapshot 1', - }, - } - rule_name = "compute:snapshot_volume_backed" - rules = { - rule_name: "project_id:no_id", - "compute:get": "" - } - policy.set_rules(oslo_policy.Rules.from_dict(rules)) - with mock.patch.object(compute_api.API, 'is_volume_backed_instance', - return_value=True): - exc = self.assertRaises(exception.PolicyNotAuthorized, - self.controller._action_create_image, - self.req, FAKE_UUID, body=body) - self.assertEqual( - "Policy doesn't allow %s to be performed." % rule_name, - exc.format_message()) - - def test_create_vol_backed_img_snapshotting_policy_blocks_role(self): - """Don't permit a snapshot of a volume backed instance if configured - not to based on role - """ - body = { - 'createImage': { - 'name': 'Snapshot 1', - }, - } - rule_name = "compute:snapshot_volume_backed" - rules = { - rule_name: "role:no_role", - "compute:get": "" - } - policy.set_rules(oslo_policy.Rules.from_dict(rules)) - with mock.patch.object(compute_api.API, 'is_volume_backed_instance', - return_value=True): - exc = self.assertRaises(exception.PolicyNotAuthorized, - self.controller._action_create_image, - self.req, FAKE_UUID, body=body) - self.assertEqual( - "Policy doesn't allow %s to be performed." % rule_name, - exc.format_message()) diff --git a/nova/tests/unit/api/openstack/compute/test_server_external_events.py b/nova/tests/unit/api/openstack/compute/test_server_external_events.py index f2dddbfd3b..b40efda50f 100644 --- a/nova/tests/unit/api/openstack/compute/test_server_external_events.py +++ b/nova/tests/unit/api/openstack/compute/test_server_external_events.py @@ -15,8 +15,6 @@ import mock import webob -from nova.api.openstack.compute.legacy_v2.contrib import server_external_events \ - as server_external_events_v2 from nova.api.openstack.compute import server_external_events \ as server_external_events_v21 from nova import exception @@ -152,9 +150,3 @@ class ServerExternalEventsTestV21(test.NoDBTestCase): body = {'events': self.event_1} self.assertRaises(self.invalid_error, self.api.create, self.req, body=body) - - -@mock.patch('nova.objects.instance.Instance.get_by_uuid', fake_get_by_uuid) -class ServerExternalEventsTestV2(ServerExternalEventsTestV21): - server_external_events = server_external_events_v2 - invalid_error = webob.exc.HTTPBadRequest diff --git a/nova/tests/unit/api/openstack/compute/test_server_group_quotas.py b/nova/tests/unit/api/openstack/compute/test_server_group_quotas.py index 53519302c9..a889f6de5e 100644 --- a/nova/tests/unit/api/openstack/compute/test_server_group_quotas.py +++ b/nova/tests/unit/api/openstack/compute/test_server_group_quotas.py @@ -17,9 +17,7 @@ from oslo_config import cfg from oslo_utils import uuidutils import webob -from nova.api.openstack.compute.legacy_v2.contrib import server_groups from nova.api.openstack.compute import server_groups as sg_v21 -from nova.api.openstack import extensions from nova import context from nova import quota from nova import test @@ -161,15 +159,3 @@ class ServerGroupQuotasTestV21(test.TestCase): else: status_int = resp.status_int self.assertEqual(204, status_int) - - -class ServerGroupQuotasTestV2(ServerGroupQuotasTestV21): - - def _setup_controller(self): - self.ext_mgr = self.mox.CreateMock(extensions.ExtensionManager) - self.controller = server_groups.ServerGroupController(self.ext_mgr) - - def _setup_quotas(self): - self.ext_mgr.is_loaded('os-server-group-quotas').MultipleTimes()\ - .AndReturn(True) - self.mox.ReplayAll() diff --git a/nova/tests/unit/api/openstack/compute/test_server_groups.py b/nova/tests/unit/api/openstack/compute/test_server_groups.py index 3e08b01ee6..cb1d259cae 100644 --- a/nova/tests/unit/api/openstack/compute/test_server_groups.py +++ b/nova/tests/unit/api/openstack/compute/test_server_groups.py @@ -18,9 +18,7 @@ import webob import mock -from nova.api.openstack.compute.legacy_v2.contrib import server_groups from nova.api.openstack.compute import server_groups as sg_v21 -from nova.api.openstack import extensions from nova import context import nova.db from nova import exception @@ -424,15 +422,6 @@ class ServerGroupTestV21(test.TestCase): self.req, 'invalid') -class ServerGroupTestV2(ServerGroupTestV21): - validation_error = webob.exc.HTTPBadRequest - - def _setup_controller(self): - ext_mgr = extensions.ExtensionManager() - ext_mgr.extensions = {} - self.controller = server_groups.ServerGroupController(ext_mgr) - - class ServerGroupTestV213(ServerGroupTestV21): wsgi_api_version = '2.13' diff --git a/nova/tests/unit/api/openstack/compute/test_server_metadata.py b/nova/tests/unit/api/openstack/compute/test_server_metadata.py index 114f659588..1925f8aa0b 100644 --- a/nova/tests/unit/api/openstack/compute/test_server_metadata.py +++ b/nova/tests/unit/api/openstack/compute/test_server_metadata.py @@ -22,8 +22,6 @@ from oslo_utils import timeutils import six import webob -from nova.api.openstack.compute.legacy_v2 import server_metadata \ - as server_metadata_v2 from nova.api.openstack.compute import server_metadata \ as server_metadata_v21 from nova.compute import rpcapi as compute_rpcapi @@ -669,19 +667,6 @@ class ServerMetaDataTestV21(test.TestCase): body=data) -class ServerMetaDataTestV2(ServerMetaDataTestV21): - validation_ex = webob.exc.HTTPBadRequest - validation_ex_large = webob.exc.HTTPRequestEntityTooLarge - - def _set_up_resources(self): - self.controller = server_metadata_v2.Controller() - self.uuid = str(uuid.uuid4()) - self.url = '/v1.1/fake/servers/%s/metadata' % self.uuid - - def _get_request(self, param_url=''): - return fakes.HTTPRequest.blank(self.url + param_url) - - class BadStateServerMetaDataTestV21(test.TestCase): def setUp(self): @@ -762,16 +747,6 @@ class BadStateServerMetaDataTestV21(test.TestCase): req, self.uuid, body=expected) -class BadStateServerMetaDataTestV2(BadStateServerMetaDataTestV21): - def _set_up_resources(self): - self.controller = server_metadata_v2.Controller() - self.uuid = str(uuid.uuid4()) - self.url = '/v1.1/fake/servers/%s/metadata' % self.uuid - - def _get_request(self, param_url=''): - return fakes.HTTPRequest.blank(self.url + param_url) - - class ServerMetaPolicyEnforcementV21(test.NoDBTestCase): def setUp(self): diff --git a/nova/tests/unit/api/openstack/compute/test_server_password.py b/nova/tests/unit/api/openstack/compute/test_server_password.py index 5fe64a26cf..01d443e448 100644 --- a/nova/tests/unit/api/openstack/compute/test_server_password.py +++ b/nova/tests/unit/api/openstack/compute/test_server_password.py @@ -18,8 +18,6 @@ import mock from oslo_config import cfg from nova.api.metadata import password -from nova.api.openstack.compute.legacy_v2.contrib import server_password \ - as server_password_v2 from nova.api.openstack.compute import server_password \ as server_password_v21 from nova import compute @@ -30,8 +28,6 @@ from nova.tests.unit import fake_instance CONF = cfg.CONF -CONF.import_opt('osapi_compute_ext_list', - 'nova.api.openstack.compute.legacy_v2.contrib') class ServerPasswordTestV21(test.NoDBTestCase): @@ -76,11 +72,6 @@ class ServerPasswordTestV21(test.NoDBTestCase): self.assertEqual(res['password'], '') -class ServerPasswordTestV2(ServerPasswordTestV21): - server_password = server_password_v2 - delete_call = 'self.controller.delete' - - class ServerPasswordPolicyEnforcementV21(test.NoDBTestCase): def setUp(self): diff --git a/nova/tests/unit/api/openstack/compute/test_server_reset_state.py b/nova/tests/unit/api/openstack/compute/test_server_reset_state.py index 9da237df47..08748fba42 100644 --- a/nova/tests/unit/api/openstack/compute/test_server_reset_state.py +++ b/nova/tests/unit/api/openstack/compute/test_server_reset_state.py @@ -17,8 +17,6 @@ import webob from nova.api.openstack.compute import admin_actions \ as admin_actions_v21 -from nova.api.openstack.compute.legacy_v2.contrib import admin_actions \ - as admin_actions_v2 from nova.compute import vm_states from nova import exception from nova import objects @@ -120,8 +118,3 @@ class ResetStateTestsV21(test.NoDBTestCase): else: status_int = result.status_int self.assertEqual(202, status_int) - - -class ResetStateTestsV2(ResetStateTestsV21): - admin_act = admin_actions_v2 - bad_request = webob.exc.HTTPBadRequest diff --git a/nova/tests/unit/api/openstack/compute/test_server_start_stop.py b/nova/tests/unit/api/openstack/compute/test_server_start_stop.py index 526e7e5da5..6bfb031004 100644 --- a/nova/tests/unit/api/openstack/compute/test_server_start_stop.py +++ b/nova/tests/unit/api/openstack/compute/test_server_start_stop.py @@ -19,8 +19,6 @@ import webob from oslo_policy import policy as oslo_policy from nova.api.openstack.compute import extension_info -from nova.api.openstack.compute.legacy_v2.contrib import server_start_stop \ - as server_v2 from nova.api.openstack.compute import servers \ as server_v21 from nova.compute import api as compute_api @@ -164,11 +162,3 @@ class ServerStartStopTestV21(test.TestCase): body = dict(stop="") self.assertRaises(webob.exc.HTTPNotFound, self.controller._stop_server, self.req, uuids.instance, body) - - -class ServerStartStopTestV2(ServerStartStopTestV21): - start_policy = "compute:start" - stop_policy = "compute:stop" - - def _setup_controller(self): - self.controller = server_v2.ServerStartStopActionController() diff --git a/nova/tests/unit/api/openstack/compute/test_services.py b/nova/tests/unit/api/openstack/compute/test_services.py index d15d6989dd..a08461b7bc 100644 --- a/nova/tests/unit/api/openstack/compute/test_services.py +++ b/nova/tests/unit/api/openstack/compute/test_services.py @@ -22,8 +22,6 @@ from oslo_utils import fixture as utils_fixture import webob.exc from nova.api.openstack import api_version_request as api_version -from nova.api.openstack.compute.legacy_v2.contrib import services \ - as services_v2 from nova.api.openstack.compute import services as services_v21 from nova.api.openstack import extensions from nova.api.openstack import wsgi as os_wsgi @@ -860,44 +858,6 @@ class ServicesTestV211(ServicesTestV21): self.assertEqual(res_dict, response) -class ServicesTestV20(ServicesTestV21): - service_is_up_exc = KeyError - bad_request = webob.exc.HTTPBadRequest - - def setUp(self): - super(ServicesTestV20, self).setUp() - self.req = fakes.HTTPRequest.blank('', use_admin_context=True) - self.non_admin_req = fakes.HTTPRequest.blank('') - - def _set_up_controller(self): - self.controller = services_v2.ServiceController(self.ext_mgr) - - def test_services_delete_not_enabled(self): - self.assertRaises(webob.exc.HTTPMethodNotAllowed, - self.controller.delete, self.req, '300') - - def _process_output(self, services, has_disabled=False, has_id=False): - for service in services['services']: - if not has_disabled: - service.pop('disabled_reason') - if not has_id: - service.pop('id') - return services - - def test_update_with_non_admin(self): - self.assertRaises(exception.AdminRequired, self.controller.update, - self.non_admin_req, fakes.FAKE_UUID, body={}) - - def test_delete_with_non_admin(self): - self.ext_mgr.extensions['os-extended-services-delete'] = True - self.assertRaises(exception.AdminRequired, self.controller.delete, - self.non_admin_req, fakes.FAKE_UUID) - - def test_index_with_non_admin(self): - self.assertRaises(exception.AdminRequired, self.controller.index, - self.non_admin_req) - - class ServicesCellsTestV21(test.TestCase): def setUp(self): @@ -972,15 +932,6 @@ class ServicesCellsTestV21(test.TestCase): self.assertEqual(response, res_dict) -class ServicesCellsTestV20(ServicesCellsTestV21): - - def _set_up_controller(self): - self.controller = services_v2.ServiceController(self.ext_mgr) - - def _process_out(self, res_dict): - pass - - class ServicesPolicyEnforcementV21(test.NoDBTestCase): def setUp(self): diff --git a/nova/tests/unit/api/openstack/compute/test_shelve.py b/nova/tests/unit/api/openstack/compute/test_shelve.py index 9b9317fbd5..8b47c37a8c 100644 --- a/nova/tests/unit/api/openstack/compute/test_shelve.py +++ b/nova/tests/unit/api/openstack/compute/test_shelve.py @@ -18,7 +18,6 @@ import mock from oslo_policy import policy as oslo_policy import webob -from nova.api.openstack.compute.legacy_v2.contrib import shelve as shelve_v2 from nova.api.openstack.compute import shelve as shelve_v21 from nova.compute import api as compute_api from nova import exception @@ -91,46 +90,6 @@ class ShelvePolicyTestV21(test.NoDBTestCase): self.req, str(uuid.uuid4()), {}) -class ShelvePolicyTestV2(ShelvePolicyTestV21): - plugin = shelve_v2 - prefix = '' - offload = 'shelveOffload' - - def _get_instance_other_project(self): - context = self.req.environ['nova.context'] - project_id = '%s_unequal' % context.project_id - return objects.Instance(project_id=project_id) - - @mock.patch('nova.objects.instance.Instance.get_by_uuid') - def test_shelve_allowed(self, mock_instance_get): - mock_instance_get.return_value = self._get_instance_other_project() - rules = {'compute:get': '', - 'compute_extension:%sshelve' % self.prefix: ''} - policy.set_rules(oslo_policy.Rules.from_dict(rules)) - self.assertRaises(exception.Forbidden, self.controller._shelve, - self.req, str(uuid.uuid4()), {}) - - @mock.patch('nova.objects.instance.Instance.get_by_uuid') - def test_unshelve_allowed(self, mock_instance_get): - mock_instance_get.return_value = self._get_instance_other_project() - rules = {'compute:get': '', - 'compute_extension:%sunshelve' % self.prefix: ''} - policy.set_rules(oslo_policy.Rules.from_dict(rules)) - self.assertRaises(exception.Forbidden, self.controller._unshelve, - self.req, str(uuid.uuid4()), {}) - - @mock.patch('nova.objects.instance.Instance.get_by_uuid') - def test_shelve_offload_allowed(self, mock_instance_get): - mock_instance_get.return_value = self._get_instance_other_project() - rules = {'compute:get': '', - 'compute_extension:%s%s' % (self.prefix, self.offload): ''} - policy.set_rules(oslo_policy.Rules.from_dict(rules)) - self.assertRaises(exception.Forbidden, - self.controller._shelve_offload, - self.req, - str(uuid.uuid4()), {}) - - class ShelvePolicyEnforcementV21(test.NoDBTestCase): def setUp(self): diff --git a/nova/tests/unit/api/openstack/compute/test_simple_tenant_usage.py b/nova/tests/unit/api/openstack/compute/test_simple_tenant_usage.py index dfbffb8af3..a3aa1bb426 100644 --- a/nova/tests/unit/api/openstack/compute/test_simple_tenant_usage.py +++ b/nova/tests/unit/api/openstack/compute/test_simple_tenant_usage.py @@ -21,8 +21,6 @@ from oslo_utils import timeutils from six.moves import range import webob -from nova.api.openstack.compute.legacy_v2.contrib import simple_tenant_usage as \ - simple_tenant_usage_v2 from nova.api.openstack.compute import simple_tenant_usage as \ simple_tenant_usage_v21 from nova.compute import vm_states @@ -256,11 +254,6 @@ class SimpleTenantUsageTestV21(test.TestCase): 'start=%s' % (NOW - datetime.timedelta(5)).isoformat()) -class SimpleTenantUsageTestV2(SimpleTenantUsageTestV21): - policy_rule_prefix = "compute_extension:simple_tenant_usage" - controller = simple_tenant_usage_v2.SimpleTenantUsageController() - - class SimpleTenantUsageControllerTestV21(test.TestCase): controller = simple_tenant_usage_v21.SimpleTenantUsageController() @@ -308,10 +301,6 @@ class SimpleTenantUsageControllerTestV21(test.TestCase): self.assertIsNone(flavor) -class SimpleTenantUsageControllerTestV2(SimpleTenantUsageControllerTestV21): - controller = simple_tenant_usage_v2.SimpleTenantUsageController() - - class SimpleTenantUsageUtilsV21(test.NoDBTestCase): simple_tenant_usage = simple_tenant_usage_v21 @@ -327,7 +316,3 @@ class SimpleTenantUsageUtilsV21(test.NoDBTestCase): self.simple_tenant_usage.parse_strtime, "2014-02-21 13:47:20.824060", "%Y-%m-%dT%H:%M:%S.%f") - - -class SimpleTenantUsageUtilsV2(SimpleTenantUsageUtilsV21): - simple_tenant_usage = simple_tenant_usage_v2 diff --git a/nova/tests/unit/api/openstack/compute/test_snapshots.py b/nova/tests/unit/api/openstack/compute/test_snapshots.py index a077d0859b..0da352b3fe 100644 --- a/nova/tests/unit/api/openstack/compute/test_snapshots.py +++ b/nova/tests/unit/api/openstack/compute/test_snapshots.py @@ -16,7 +16,6 @@ import mock import webob -from nova.api.openstack.compute.legacy_v2.contrib import volumes as volumes_v2 from nova.api.openstack.compute import volumes as volumes_v21 from nova import exception from nova import test @@ -119,8 +118,3 @@ class SnapshotApiTestV21(test.NoDBTestCase): self.assertIn('snapshots', resp_dict) resp_snapshots = resp_dict['snapshots'] self.assertEqual(3, len(resp_snapshots)) - - -class SnapshotApiTestV2(SnapshotApiTestV21): - controller = volumes_v2.SnapshotController() - validation_error = webob.exc.HTTPBadRequest diff --git a/nova/tests/unit/api/openstack/compute/test_suspend_server.py b/nova/tests/unit/api/openstack/compute/test_suspend_server.py index a538b2d53d..533fa0bbd1 100644 --- a/nova/tests/unit/api/openstack/compute/test_suspend_server.py +++ b/nova/tests/unit/api/openstack/compute/test_suspend_server.py @@ -12,8 +12,6 @@ # License for the specific language governing permissions and limitations # under the License. -from nova.api.openstack.compute.legacy_v2.contrib import admin_actions as \ - suspend_server_v2 from nova.api.openstack.compute import suspend_server as \ suspend_server_v21 from nova import exception @@ -53,12 +51,6 @@ class SuspendServerTestsV21(admin_only_action_common.CommonTests): self._test_actions_with_locked_instance(['_suspend', '_resume']) -class SuspendServerTestsV2(SuspendServerTestsV21): - suspend_server = suspend_server_v2 - controller_name = 'AdminActionsController' - _api_version = '2' - - class SuspendServerPolicyEnforcementV21(test.NoDBTestCase): def setUp(self): diff --git a/nova/tests/unit/api/openstack/compute/test_tenant_networks.py b/nova/tests/unit/api/openstack/compute/test_tenant_networks.py index be657727ba..b8221bfef5 100644 --- a/nova/tests/unit/api/openstack/compute/test_tenant_networks.py +++ b/nova/tests/unit/api/openstack/compute/test_tenant_networks.py @@ -18,8 +18,6 @@ import mock from oslo_config import cfg import webob -from nova.api.openstack.compute.legacy_v2.contrib import os_tenant_networks \ - as networks from nova.api.openstack.compute import tenant_networks \ as networks_v21 from nova import exception @@ -259,19 +257,6 @@ class TenantNetworksTestV21(test.NoDBTestCase): self.controller.create, self.req, body=body) -class TenantNetworksTestV2(TenantNetworksTestV21): - ctrlr = networks.NetworkController - validation_error = webob.exc.HTTPBadRequest - - def setUp(self): - super(TenantNetworksTestV2, self).setUp() - self.req = fakes.HTTPRequest.blank('', use_admin_context=True) - - def test_network_create_empty_body(self): - self.assertRaises(webob.exc.HTTPUnprocessableEntity, - self.controller.create, self.req, {}) - - class TenantNetworksEnforcementV21(test.NoDBTestCase): def setUp(self): diff --git a/nova/tests/unit/api/openstack/compute/test_used_limits.py b/nova/tests/unit/api/openstack/compute/test_used_limits.py index 659b3e4a37..a80c27da6a 100644 --- a/nova/tests/unit/api/openstack/compute/test_used_limits.py +++ b/nova/tests/unit/api/openstack/compute/test_used_limits.py @@ -15,8 +15,6 @@ import six -from nova.api.openstack.compute.legacy_v2.contrib import used_limits \ - as used_limits_v2 from nova.api.openstack.compute import used_limits \ as used_limits_v21 from nova.api.openstack import extensions @@ -257,18 +255,3 @@ class UsedLimitsTestCaseV21(test.NoDBTestCase): self.controller.index(fake_req, res) abs_limits = res.obj['limits']['absolute'] self.assertNotIn('totalRAMUsed', abs_limits) - - -class UsedLimitsTestCaseV2(UsedLimitsTestCaseV21): - used_limit_extension = "compute_extension:used_limits_for_admin" - - def _set_up_controller(self): - self.ext_mgr = self.mox.CreateMock(extensions.ExtensionManager) - self.controller = used_limits_v2.UsedLimitsController(self.ext_mgr) - self.mox.StubOutWithMock(used_limits_v2, 'authorize_for_admin') - self.authorize = used_limits_v2.authorize_for_admin - - -class UsedLimitsTestCaseV2WithoutServerGroupQuotas(UsedLimitsTestCaseV2): - used_limit_extension = "compute_extension:used_limits_for_admin" - include_server_group_quotas = False diff --git a/nova/tests/unit/api/openstack/compute/test_virtual_interfaces.py b/nova/tests/unit/api/openstack/compute/test_virtual_interfaces.py index a8bdafcf62..653d6c781f 100644 --- a/nova/tests/unit/api/openstack/compute/test_virtual_interfaces.py +++ b/nova/tests/unit/api/openstack/compute/test_virtual_interfaces.py @@ -16,8 +16,6 @@ import webob from nova.api.openstack import api_version_request -from nova.api.openstack.compute.legacy_v2.contrib import virtual_interfaces \ - as vi20 from nova.api.openstack.compute import virtual_interfaces as vi21 from nova import compute from nova.compute import api as compute_api @@ -118,12 +116,6 @@ class ServerVirtualInterfaceTestV21(test.NoDBTestCase): self.controller.index, req, FAKE_UUID) -class ServerVirtualInterfaceTestV20(ServerVirtualInterfaceTestV21): - - def _set_controller(self): - self.controller = vi20.ServerVirtualInterfaceController() - - class ServerVirtualInterfaceTestV212(ServerVirtualInterfaceTestV21): wsgi_api_version = '2.12' diff --git a/nova/tests/unit/api/openstack/compute/test_volumes.py b/nova/tests/unit/api/openstack/compute/test_volumes.py index 8f560ecc6e..acec2592cf 100644 --- a/nova/tests/unit/api/openstack/compute/test_volumes.py +++ b/nova/tests/unit/api/openstack/compute/test_volumes.py @@ -25,11 +25,7 @@ from webob import exc from nova.api.openstack import common from nova.api.openstack.compute import assisted_volume_snapshots \ as assisted_snaps_v21 -from nova.api.openstack.compute.legacy_v2.contrib import \ - assisted_volume_snapshots as assisted_snaps_v2 -from nova.api.openstack.compute.legacy_v2.contrib import volumes from nova.api.openstack.compute import volumes as volumes_v21 -from nova.api.openstack import extensions from nova.compute import api as compute_api from nova.compute import flavors from nova.compute import vm_states @@ -352,13 +348,6 @@ class VolumeApiTestV21(test.NoDBTestCase): self.assertIn('Volume 456 could not be found.', resp.body) -class VolumeApiTestV2(VolumeApiTestV21): - - @property - def app(self): - return fakes.wsgi_app(init_only=('os-volumes', 'servers')) - - class VolumeAttachTestsV21(test.NoDBTestCase): validation_error = exception.ValidationError @@ -749,47 +738,6 @@ class VolumeAttachTestsV21(test.NoDBTestCase): body=body) -class VolumeAttachTestsV2(VolumeAttachTestsV21): - validation_error = webob.exc.HTTPBadRequest - - def _set_up_controller(self): - ext_mgr = extensions.ExtensionManager() - ext_mgr.extensions = {'os-volume-attachment-update'} - self.attachments = volumes.VolumeAttachmentController(ext_mgr) - ext_mgr_no_update = extensions.ExtensionManager() - ext_mgr_no_update.extensions = {} - self.attachments_no_update = volumes.VolumeAttachmentController( - ext_mgr_no_update) - - def test_swap_volume_no_extension(self): - self.assertRaises(webob.exc.HTTPBadRequest, self._test_swap, - self.attachments_no_update) - - @mock.patch.object(compute_api.API, 'attach_volume', - return_value=[]) - def test_attach_volume_with_extra_arg(self, mock_attach): - # NOTE(gmann): V2 does not perform strong input validation - # so volume is attached successfully even with extra arg in - # request body. - body = {'volumeAttachment': {'volumeId': FAKE_UUID_A, - 'device': '/dev/fake', - 'extra': 'extra_arg'}} - req = fakes.HTTPRequest.blank('/v2/servers/id/os-volume_attachments') - req.method = 'POST' - req.body = jsonutils.dump_as_bytes({}) - req.headers['content-type'] = 'application/json' - req.environ['nova.context'] = self.context - result = self.attachments.create(req, FAKE_UUID, body=body) - self.assertEqual('00000000-aaaa-aaaa-aaaa-000000000000', - result['volumeAttachment']['id']) - - def test_swap_volume_with_extra_arg(self): - # NOTE(gmann): V2 does not perform strong input validation. - # Volume is swapped successfully even with extra arg in - # request body. So 'pass' this test for V2. - pass - - class CommonBadRequestTestCase(object): resource = None @@ -836,19 +784,6 @@ class BadRequestVolumeTestCaseV21(CommonBadRequestTestCase, bad_request = exception.ValidationError -class BadRequestVolumeTestCaseV2(BadRequestVolumeTestCaseV21): - controller_cls = volumes.VolumeController - bad_request = exc.HTTPBadRequest - - -class BadRequestAttachmentTestCase(CommonBadRequestTestCase, - test.NoDBTestCase): - resource = 'servers/' + FAKE_UUID + '/os-volume_attachments' - entity_name = 'volumeAttachment' - controller_cls = volumes.VolumeAttachmentController - kwargs = {'server_id': FAKE_UUID} - - class BadRequestSnapshotTestCaseV21(CommonBadRequestTestCase, test.NoDBTestCase): @@ -858,11 +793,6 @@ class BadRequestSnapshotTestCaseV21(CommonBadRequestTestCase, bad_request = exception.ValidationError -class BadRequestSnapshotTestCaseV2(BadRequestSnapshotTestCaseV21): - controller_cls = volumes.SnapshotController - bad_request = exc.HTTPBadRequest - - class AssistedSnapshotCreateTestCaseV21(test.NoDBTestCase): assisted_snaps = assisted_snaps_v21 bad_request = exception.ValidationError @@ -910,16 +840,6 @@ class AssistedSnapshotCreateTestCaseV21(test.NoDBTestCase): req, body=body) -class AssistedSnapshotCreateTestCaseV2(AssistedSnapshotCreateTestCaseV21): - assisted_snaps = assisted_snaps_v2 - bad_request = webob.exc.HTTPBadRequest - - def test_assisted_create_with_unexpected_attr(self): - # NOTE: legacy v2.0 API cannot handle this kind of invalid requests. - # So we need to skip the test on legacy v2.0 API. - pass - - class AssistedSnapshotDeleteTestCaseV21(test.NoDBTestCase): assisted_snaps = assisted_snaps_v21 @@ -952,13 +872,6 @@ class AssistedSnapshotDeleteTestCaseV21(test.NoDBTestCase): req, '5') -class AssistedSnapshotDeleteTestCaseV2(AssistedSnapshotDeleteTestCaseV21): - assisted_snaps = assisted_snaps_v2 - - def _check_status(self, expected_status, res, controller_method): - self.assertEqual(expected_status, res.status_int) - - class TestAssistedVolumeSnapshotsPolicyEnforcementV21(test.NoDBTestCase): def setUp(self):