Merge "Remove legacy v2 unit tests[f-n]"
This commit is contained in:
@@ -16,8 +16,6 @@ import webob
|
||||
|
||||
from nova.api.openstack import api_version_request
|
||||
from nova.api.openstack.compute import fixed_ips as fixed_ips_v21
|
||||
from nova.api.openstack.compute.legacy_v2.contrib import fixed_ips \
|
||||
as fixed_ips_v2
|
||||
from nova.api.openstack import wsgi as os_wsgi
|
||||
from nova import context
|
||||
from nova import exception
|
||||
@@ -240,20 +238,6 @@ class FixedIpTestV21(test.NoDBTestCase):
|
||||
'10.0.0.2', body=body)
|
||||
|
||||
|
||||
class FixedIpTestV2(FixedIpTestV21):
|
||||
|
||||
fixed_ips = fixed_ips_v2
|
||||
|
||||
def _assert_equal(self, ret, exp):
|
||||
self.assertEqual(ret.status, '202 Accepted')
|
||||
|
||||
def _get_reserve_action(self):
|
||||
return self.controller.action
|
||||
|
||||
def _get_unreserve_action(self):
|
||||
return self.controller.action
|
||||
|
||||
|
||||
class FixedIpTestV24(FixedIpTestV21):
|
||||
|
||||
wsgi_api_version = '2.4'
|
||||
|
||||
@@ -22,9 +22,7 @@ from webob import exc
|
||||
from nova.api.openstack import api_version_request as api_version
|
||||
from nova.api.openstack.compute import flavor_access \
|
||||
as flavor_access_v21
|
||||
from nova.api.openstack.compute.legacy_v2.contrib import flavor_access \
|
||||
as flavor_access_v2
|
||||
from nova.api.openstack.compute.legacy_v2 import flavors as flavors_api
|
||||
from nova.api.openstack.compute import flavors as flavors_api
|
||||
from nova import context
|
||||
from nova import exception
|
||||
from nova import test
|
||||
@@ -138,7 +136,7 @@ class FlavorAccessTestV21(test.NoDBTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(FlavorAccessTestV21, self).setUp()
|
||||
self.flavor_controller = flavors_api.Controller()
|
||||
self.flavor_controller = flavors_api.FlavorsController()
|
||||
self.req = FakeRequest()
|
||||
self.req.environ = {"nova.context": context.RequestContext('fake_user',
|
||||
'fake')}
|
||||
@@ -387,63 +385,6 @@ class FlavorAccessTestV21(test.NoDBTestCase):
|
||||
remove_access, req, '2', body=body)
|
||||
|
||||
|
||||
class FlavorAccessTestV20(FlavorAccessTestV21):
|
||||
api_version = "2.0"
|
||||
FlavorAccessController = flavor_access_v2.FlavorAccessController
|
||||
FlavorActionController = flavor_access_v2.FlavorActionController
|
||||
validation_ex = exc.HTTPBadRequest
|
||||
|
||||
def setUp(self):
|
||||
super(FlavorAccessTestV20, self).setUp()
|
||||
self.req = FakeRequest()
|
||||
self.req.environ = {"nova.context": context.get_admin_context()}
|
||||
|
||||
def test_remove_tenant_access_with_no_admin_user(self):
|
||||
req = fakes.HTTPRequest.blank(self._prefix + '/flavors/2/action',
|
||||
use_admin_context=False)
|
||||
body = {'removeTenantAccess': {'tenant': 'proj2'}}
|
||||
remove_access = self._get_remove_access()
|
||||
self.assertRaises(exception.AdminRequired,
|
||||
remove_access, req, '2', body=body)
|
||||
|
||||
def test_add_tenant_access_with_no_admin_user(self):
|
||||
req = fakes.HTTPRequest.blank(self._prefix + '/flavors/2/action',
|
||||
use_admin_context=False)
|
||||
body = {'addTenantAccess': {'tenant': 'proj2'}}
|
||||
add_access = self._get_add_access()
|
||||
self.assertRaises(exception.AdminRequired,
|
||||
add_access, req, '2', body=body)
|
||||
|
||||
def test_list_with_no_admin(self):
|
||||
req = fakes.HTTPRequest.blank(self._prefix + '/flavors/fake/flavors')
|
||||
self.assertRaises(exception.AdminRequired,
|
||||
self.flavor_access_controller.index,
|
||||
req, 'fake')
|
||||
|
||||
@mock.patch('nova.objects.Flavor.add_access')
|
||||
def test_add_tenant_access_is_public(self, mock_add):
|
||||
# V2 don't test public before add access
|
||||
expected = {'flavor_access':
|
||||
[{'flavor_id': '3', 'tenant_id': 'proj3'}]}
|
||||
body = {'addTenantAccess': {'tenant': 'proj2'}}
|
||||
req = fakes.HTTPRequest.blank(self._prefix + '/flavors/2/action',
|
||||
use_admin_context=True)
|
||||
|
||||
add_access = self._get_add_access()
|
||||
result = add_access(req, '3', body=body)
|
||||
mock_add.assert_called_once_with('proj2')
|
||||
self.assertEqual(result, expected)
|
||||
|
||||
@mock.patch('nova.objects.Flavor.add_access')
|
||||
def test_add_tenant_access_with_flavor_not_found(self, mock_add):
|
||||
body = {'addTenantAccess': {'tenant': 'proj2'}}
|
||||
req = fakes.HTTPRequest.blank(self._prefix + '/flavors/2/action',
|
||||
use_admin_context=True)
|
||||
add_access = self._get_add_access()
|
||||
add_access(req, '1000', body=body)
|
||||
mock_add.assert_called_once_with('proj2')
|
||||
|
||||
|
||||
class FlavorAccessPolicyEnforcementV21(test.NoDBTestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
||||
@@ -22,10 +22,6 @@ import webob
|
||||
|
||||
from nova.api.openstack.compute import flavor_access as flavor_access_v21
|
||||
from nova.api.openstack.compute import flavor_manage as flavormanage_v21
|
||||
from nova.api.openstack.compute.legacy_v2.contrib import flavor_access \
|
||||
as flavor_access_v2
|
||||
from nova.api.openstack.compute.legacy_v2.contrib import flavormanage \
|
||||
as flavormanage_v2
|
||||
from nova.compute import flavors
|
||||
from nova import exception
|
||||
from nova import test
|
||||
@@ -426,60 +422,6 @@ class PrivateFlavorManageTestV21(test.TestCase):
|
||||
self.assertEqual(body["flavor"][key], self.expected["flavor"][key])
|
||||
|
||||
|
||||
class FlavorManageTestV2(FlavorManageTestV21):
|
||||
controller = flavormanage_v2.FlavorManageController()
|
||||
validation_error = webob.exc.HTTPBadRequest
|
||||
|
||||
def setUp(self):
|
||||
super(FlavorManageTestV2, self).setUp()
|
||||
self.flags(
|
||||
osapi_compute_extension=[
|
||||
'nova.api.openstack.compute.contrib.select_extensions'],
|
||||
osapi_compute_ext_list=['Flavormanage', 'Flavorextradata',
|
||||
'Flavor_access', 'Flavor_rxtx', 'Flavor_swap'])
|
||||
|
||||
@property
|
||||
def app(self):
|
||||
return fakes.wsgi_app(init_only=('flavors',),
|
||||
fake_auth_context=self._get_http_request().
|
||||
environ['nova.context'])
|
||||
|
||||
def _get_http_request(self, url=''):
|
||||
return fakes.HTTPRequest.blank(url, use_admin_context=False)
|
||||
|
||||
def test_create_with_name_leading_trailing_spaces(self):
|
||||
req = self._get_http_request(url=self.base_url)
|
||||
self.request_body['flavor']['name'] = ' test '
|
||||
body = self._create_flavor_success_case(self.request_body, req)
|
||||
self.assertEqual('test', body['flavor']['name'])
|
||||
|
||||
def test_create_with_name_leading_trailing_spaces_compat_mode(self):
|
||||
pass
|
||||
|
||||
|
||||
class PrivateFlavorManageTestV2(PrivateFlavorManageTestV21):
|
||||
controller = flavormanage_v2.FlavorManageController()
|
||||
|
||||
def setUp(self):
|
||||
super(PrivateFlavorManageTestV2, self).setUp()
|
||||
self.flags(
|
||||
osapi_compute_extension=[
|
||||
'nova.api.openstack.compute.contrib.select_extensions'],
|
||||
osapi_compute_ext_list=['Flavormanage', 'Flavorextradata',
|
||||
'Flavor_access', 'Flavor_rxtx', 'Flavor_swap'])
|
||||
self.flavor_access_controller = (flavor_access_v2.
|
||||
FlavorAccessController())
|
||||
|
||||
@property
|
||||
def app(self):
|
||||
return fakes.wsgi_app(init_only=('flavors',),
|
||||
fake_auth_context=self._get_http_request().
|
||||
environ['nova.context'])
|
||||
|
||||
def _get_http_request(self, url=''):
|
||||
return fakes.HTTPRequest.blank(url, use_admin_context=False)
|
||||
|
||||
|
||||
class FlavorManagerPolicyEnforcementV21(test.NoDBTestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
||||
@@ -18,7 +18,6 @@ import webob
|
||||
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack.compute import flavors as flavors_v21
|
||||
from nova.api.openstack.compute.legacy_v2 import flavors as flavors_v2
|
||||
import nova.compute.flavors
|
||||
from nova import context
|
||||
from nova import exception
|
||||
@@ -564,14 +563,6 @@ class FlavorsTestV21(test.TestCase):
|
||||
self.assertEqual(expected, flavor)
|
||||
|
||||
|
||||
class FlavorsTestV20(FlavorsTestV21):
|
||||
Controller = flavors_v2.Controller
|
||||
fake_request = fakes.HTTPRequest
|
||||
|
||||
def _set_expected_body(self, expected, ephemeral, swap, disabled):
|
||||
pass
|
||||
|
||||
|
||||
class DisabledFlavorsWithRealDBTestV21(test.TestCase):
|
||||
"""Tests that disabled flavors should not be shown nor listed."""
|
||||
Controller = flavors_v21.FlavorsController
|
||||
@@ -649,13 +640,6 @@ class DisabledFlavorsWithRealDBTestV21(test.TestCase):
|
||||
self.assertEqual(flavor['name'], self.disabled_type['name'])
|
||||
|
||||
|
||||
class DisabledFlavorsWithRealDBTestV20(DisabledFlavorsWithRealDBTestV21):
|
||||
"""Tests that disabled flavors should not be shown nor listed."""
|
||||
Controller = flavors_v2.Controller
|
||||
_prefix = "/v2/fake"
|
||||
fake_request = fakes.HTTPRequest
|
||||
|
||||
|
||||
class ParseIsPublicTestV21(test.TestCase):
|
||||
Controller = flavors_v21.FlavorsController
|
||||
|
||||
@@ -691,7 +675,3 @@ class ParseIsPublicTestV21(test.TestCase):
|
||||
def test_other(self):
|
||||
self.assertRaises(
|
||||
webob.exc.HTTPBadRequest, self.assertPublic, None, 'other')
|
||||
|
||||
|
||||
class ParseIsPublicTestV20(ParseIsPublicTestV21):
|
||||
Controller = flavors_v2.Controller
|
||||
|
||||
@@ -18,8 +18,6 @@ import webob
|
||||
|
||||
from nova.api.openstack.compute import flavors_extraspecs \
|
||||
as flavorextraspecs_v21
|
||||
from nova.api.openstack.compute.legacy_v2.contrib import flavorextraspecs \
|
||||
as flavorextraspecs_v2
|
||||
from nova import exception
|
||||
from nova import objects
|
||||
from nova import test
|
||||
@@ -341,8 +339,3 @@ class FlavorsExtraSpecsTestV21(test.TestCase):
|
||||
use_admin_context=True)
|
||||
self.assertRaises(webob.exc.HTTPBadRequest, self.controller.update,
|
||||
req, 1, 'key1', body={"key1": value})
|
||||
|
||||
|
||||
class FlavorsExtraSpecsTestV2(FlavorsExtraSpecsTestV21):
|
||||
bad_request = webob.exc.HTTPBadRequest
|
||||
flavorextraspecs = flavorextraspecs_v2
|
||||
|
||||
@@ -21,8 +21,6 @@ import webob
|
||||
|
||||
from nova.api.openstack.compute import floating_ip_dns \
|
||||
as fipdns_v21
|
||||
from nova.api.openstack.compute.legacy_v2.contrib import floating_ip_dns \
|
||||
as fipdns_v2
|
||||
from nova import context
|
||||
from nova import db
|
||||
from nova import exception
|
||||
@@ -362,38 +360,6 @@ class FloatingIpDNSTestV21(test.TestCase):
|
||||
self.domain_controller.index, self.req)
|
||||
|
||||
|
||||
class FloatingIpDNSTestV2(FloatingIpDNSTestV21):
|
||||
floating_ip_dns = fipdns_v2
|
||||
|
||||
def _check_status(self, expected_status, res, controller_methord):
|
||||
self.assertEqual(expected_status, res.status_int)
|
||||
|
||||
def _bad_request(self):
|
||||
return webob.exc.HTTPUnprocessableEntity
|
||||
|
||||
def test_update_dns_domain_with_non_admin(self):
|
||||
body = {'domain_entry':
|
||||
{'scope': 'private',
|
||||
'project': 'testproject'}}
|
||||
self.assertRaises(exception.AdminRequired,
|
||||
self.domain_controller.update,
|
||||
self.req, _quote_domain(domain), body=body)
|
||||
|
||||
def test_delete_dns_domain_with_non_admin(self):
|
||||
self.assertRaises(exception.AdminRequired,
|
||||
self.domain_controller.delete,
|
||||
self.req, _quote_domain(domain))
|
||||
|
||||
def test_create_domain(self):
|
||||
self._test_create_domain(self.admin_req)
|
||||
|
||||
def test_delete_domain(self):
|
||||
self._test_delete_domain(self.admin_req)
|
||||
|
||||
def test_delete_domain_notfound(self):
|
||||
self._test_delete_domain_notfound(self.admin_req)
|
||||
|
||||
|
||||
class FloatingIPDNSDomainPolicyEnforcementV21(test.NoDBTestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
|
||||
from nova.api.openstack.compute import floating_ip_pools \
|
||||
as fipp_v21
|
||||
from nova.api.openstack.compute.legacy_v2.contrib import floating_ip_pools \
|
||||
as fipp_v2
|
||||
from nova import context
|
||||
from nova import exception
|
||||
from nova import network
|
||||
@@ -57,10 +55,6 @@ class FloatingIpPoolTestV21(test.NoDBTestCase):
|
||||
self.assertEqual(res_dict, response)
|
||||
|
||||
|
||||
class FloatingIpPoolTestV2(FloatingIpPoolTestV21):
|
||||
floating_ip_pools = fipp_v2
|
||||
|
||||
|
||||
class FloatingIPPoolsPolicyEnforcementV21(test.NoDBTestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
||||
@@ -21,8 +21,6 @@ import six
|
||||
import webob
|
||||
|
||||
from nova.api.openstack.compute import floating_ips as fips_v21
|
||||
from nova.api.openstack.compute.legacy_v2.contrib import floating_ips \
|
||||
as fips_v2
|
||||
from nova.api.openstack import extensions
|
||||
from nova import compute
|
||||
from nova.compute import utils as compute_utils
|
||||
@@ -163,14 +161,6 @@ class FloatingIpTestNeutronV21(test.NoDBTestCase):
|
||||
self._test_floatingip_delete_not_found(ex, webob.exc.HTTPBadRequest)
|
||||
|
||||
|
||||
class FloatingIpTestNeutronV2(FloatingIpTestNeutronV21):
|
||||
floating_ips = fips_v2
|
||||
|
||||
def test_floatingip_delete_invalid_id(self):
|
||||
ex = exception.InvalidID(id=1)
|
||||
self._test_floatingip_delete_not_found(ex, webob.exc.HTTPNotFound)
|
||||
|
||||
|
||||
class FloatingIpTestV21(test.TestCase):
|
||||
floating_ip = "10.10.10.10"
|
||||
floating_ip_2 = "10.10.10.11"
|
||||
@@ -720,33 +710,6 @@ class FloatingIpTestV21(test.TestCase):
|
||||
TEST_INST, body=body)
|
||||
|
||||
|
||||
class FloatingIpTestV2(FloatingIpTestV21):
|
||||
floating_ips = fips_v2
|
||||
validation_error = webob.exc.HTTPBadRequest
|
||||
|
||||
def test_not_extended_floating_ip_associate_fixed(self):
|
||||
# Check that fixed_address is ignored if os-extended-floating-ips
|
||||
# is not loaded
|
||||
fixed_address_requested = '192.168.1.101'
|
||||
fixed_address_allocated = '192.168.1.100'
|
||||
|
||||
def fake_associate_floating_ip(*args, **kwargs):
|
||||
self.assertEqual(fixed_address_allocated,
|
||||
kwargs['fixed_address'])
|
||||
|
||||
self.stubs.Set(network.api.API, "associate_floating_ip",
|
||||
fake_associate_floating_ip)
|
||||
body = dict(addFloatingIp=dict(address=self.floating_ip,
|
||||
fixed_address=fixed_address_requested))
|
||||
|
||||
rsp = self.manager._add_floating_ip(self.fake_req, TEST_INST, body)
|
||||
self.assertEqual(202, rsp.status_int)
|
||||
|
||||
def test_floatingip_delete_invalid_id(self):
|
||||
ex = exception.InvalidID(id=1)
|
||||
self._test_floatingip_delete_not_found(ex, webob.exc.HTTPNotFound)
|
||||
|
||||
|
||||
class ExtendedFloatingIpTestV21(test.TestCase):
|
||||
floating_ip = "10.10.10.10"
|
||||
floating_ip_2 = "10.10.10.11"
|
||||
@@ -838,10 +801,6 @@ class ExtendedFloatingIpTestV21(test.TestCase):
|
||||
ex.explanation)
|
||||
|
||||
|
||||
class ExtendedFloatingIpTestV2(ExtendedFloatingIpTestV21):
|
||||
floating_ips = fips_v2
|
||||
|
||||
|
||||
class FloatingIPPolicyEnforcementV21(test.NoDBTestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
||||
@@ -19,8 +19,6 @@ import webob
|
||||
|
||||
from nova.api.openstack.compute import floating_ips_bulk \
|
||||
as fipbulk_v21
|
||||
from nova.api.openstack.compute.legacy_v2.contrib import floating_ips_bulk \
|
||||
as fipbulk_v2
|
||||
from nova import context
|
||||
from nova import exception
|
||||
from nova import objects
|
||||
@@ -167,40 +165,6 @@ class FloatingIPBulkV21(test.TestCase):
|
||||
self.req, body=body)
|
||||
|
||||
|
||||
class FloatingIPBulkV2(FloatingIPBulkV21):
|
||||
floating_ips_bulk = fipbulk_v2
|
||||
bad_request = webob.exc.HTTPBadRequest
|
||||
|
||||
def setUp(self):
|
||||
super(FloatingIPBulkV2, self).setUp()
|
||||
self.non_admin_req = fakes.HTTPRequest.blank('')
|
||||
self.admin_req = fakes.HTTPRequest.blank('', use_admin_context=True)
|
||||
|
||||
def test_list_ips_with_non_admin(self):
|
||||
ip_range = '192.168.1.1/28'
|
||||
self._setup_floating_ips(ip_range)
|
||||
self.assertRaises(exception.AdminRequired,
|
||||
self.controller.index, self.non_admin_req)
|
||||
|
||||
def test_list_ip_with_non_admin(self):
|
||||
ip_range = '192.168.1.1/28'
|
||||
self._setup_floating_ips(ip_range)
|
||||
self.assertRaises(exception.AdminRequired, self.controller.show,
|
||||
self.non_admin_req, "host")
|
||||
|
||||
def test_delete_ips(self):
|
||||
self._test_delete_ips(self.admin_req)
|
||||
|
||||
def test_list_ip_by_host(self):
|
||||
self._test_list_ip_by_host(self.admin_req)
|
||||
|
||||
def test_list_ips_associated(self):
|
||||
self._test_list_ips_associated(self.admin_req)
|
||||
|
||||
def test_list_ips(self):
|
||||
self._test_list_ips(self.admin_req)
|
||||
|
||||
|
||||
class FloatingIPBulkPolicyEnforcementV21(test.NoDBTestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
||||
@@ -18,7 +18,6 @@ import mock
|
||||
import webob
|
||||
|
||||
from nova.api.openstack.compute import fping as fping_v21
|
||||
from nova.api.openstack.compute.legacy_v2.contrib import fping
|
||||
from nova import exception
|
||||
from nova import test
|
||||
from nova.tests.unit.api.openstack import fakes
|
||||
@@ -111,10 +110,6 @@ class FpingTestV21(test.TestCase):
|
||||
self.controller.show, req, FAKE_UUID)
|
||||
|
||||
|
||||
class FpingTestV2(FpingTestV21):
|
||||
controller_cls = fping.FpingController
|
||||
|
||||
|
||||
class FpingPolicyEnforcementV21(test.NoDBTestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
||||
@@ -17,7 +17,6 @@ import testtools
|
||||
import webob.exc
|
||||
|
||||
from nova.api.openstack.compute import hosts as os_hosts_v21
|
||||
from nova.api.openstack.compute.legacy_v2.contrib import hosts as os_hosts_v2
|
||||
from nova.compute import power_state
|
||||
from nova.compute import vm_states
|
||||
from nova import context as context_maker
|
||||
@@ -377,43 +376,6 @@ class HostTestCaseV21(test.TestCase):
|
||||
self.assertEqual(fake_hosts.HOST_LIST_NOVA_ZONE, hosts)
|
||||
|
||||
|
||||
class HostTestCaseV20(HostTestCaseV21):
|
||||
validation_ex = webob.exc.HTTPBadRequest
|
||||
policy_ex = webob.exc.HTTPForbidden
|
||||
Controller = os_hosts_v2.HostController
|
||||
|
||||
def test_list_hosts_with_non_admin(self):
|
||||
self.assertRaises(exception.AdminRequired,
|
||||
self.controller.index, fakes.HTTPRequest.blank(''))
|
||||
|
||||
def test_host_maintenance_with_non_admin(self):
|
||||
self.assertRaises(exception.AdminRequired,
|
||||
self.controller.update, fakes.HTTPRequest.blank(''),
|
||||
'host_c1', {'maintenance_mode': 'enable'})
|
||||
|
||||
def test_startup_with_non_admin(self):
|
||||
self.assertRaises(exception.AdminRequired,
|
||||
self.controller.startup, fakes.HTTPRequest.blank(''),
|
||||
'host_c1')
|
||||
|
||||
def test_reboot_with_non_admin(self):
|
||||
self.assertRaises(exception.AdminRequired,
|
||||
self.controller.reboot, fakes.HTTPRequest.blank(''),
|
||||
'host_c1')
|
||||
|
||||
def test_shutdown_with_non_admin(self):
|
||||
self.assertRaises(exception.AdminRequired,
|
||||
self.controller.shutdown,
|
||||
fakes.HTTPRequest.blank(''),
|
||||
'host_c1')
|
||||
|
||||
def test_show_non_admin(self):
|
||||
self.assertRaises(exception.AdminRequired,
|
||||
self.controller.show,
|
||||
fakes.HTTPRequest.blank(''),
|
||||
1)
|
||||
|
||||
|
||||
class HostsPolicyEnforcementV21(test.NoDBTestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
||||
@@ -18,9 +18,6 @@ import mock
|
||||
|
||||
from nova.api.openstack.compute import hypervisors \
|
||||
as hypervisors_v21
|
||||
from nova.api.openstack.compute.legacy_v2.contrib import hypervisors \
|
||||
as hypervisors_v2
|
||||
from nova.api.openstack import extensions
|
||||
from nova import objects
|
||||
from nova import test
|
||||
from nova.tests.unit.api.openstack.compute import test_hypervisors
|
||||
@@ -84,13 +81,3 @@ class HypervisorStatusTestV21(test.NoDBTestCase):
|
||||
result = self.controller._view_hypervisor(hyper, service, True)
|
||||
self.assertEqual('disabled', result['status'],)
|
||||
self.assertEqual('fake', result['service']['disabled_reason'])
|
||||
|
||||
|
||||
class HypervisorStatusTestV2(HypervisorStatusTestV21):
|
||||
def _prepare_extension(self):
|
||||
ext_mgr = extensions.ExtensionManager()
|
||||
ext_mgr.extensions = {}
|
||||
ext_mgr.extensions['os-hypervisor-status'] = True
|
||||
self.controller = hypervisors_v2.HypervisorsController(ext_mgr)
|
||||
self.controller.servicegroup_api.service_is_up = mock.MagicMock(
|
||||
return_value=True)
|
||||
|
||||
@@ -20,11 +20,7 @@ from webob import exc
|
||||
|
||||
from nova.api.openstack.compute import hypervisors \
|
||||
as hypervisors_v21
|
||||
from nova.api.openstack.compute.legacy_v2.contrib import hypervisors \
|
||||
as hypervisors_v2
|
||||
from nova.api.openstack import extensions
|
||||
from nova.cells import utils as cells_utils
|
||||
from nova import context
|
||||
from nova import exception
|
||||
from nova import objects
|
||||
from nova import test
|
||||
@@ -436,62 +432,6 @@ class HypervisorsTestV21(test.NoDBTestCase):
|
||||
self.controller.statistics, req)
|
||||
|
||||
|
||||
class HypervisorsTestV2(HypervisorsTestV21):
|
||||
DETAIL_HYPERS_DICTS = copy.deepcopy(
|
||||
HypervisorsTestV21.DETAIL_HYPERS_DICTS)
|
||||
del DETAIL_HYPERS_DICTS[0]['state']
|
||||
del DETAIL_HYPERS_DICTS[1]['state']
|
||||
del DETAIL_HYPERS_DICTS[0]['status']
|
||||
del DETAIL_HYPERS_DICTS[1]['status']
|
||||
del DETAIL_HYPERS_DICTS[0]['service']['disabled_reason']
|
||||
del DETAIL_HYPERS_DICTS[1]['service']['disabled_reason']
|
||||
del DETAIL_HYPERS_DICTS[0]['host_ip']
|
||||
del DETAIL_HYPERS_DICTS[1]['host_ip']
|
||||
|
||||
INDEX_HYPER_DICTS = copy.deepcopy(HypervisorsTestV21.INDEX_HYPER_DICTS)
|
||||
del INDEX_HYPER_DICTS[0]['state']
|
||||
del INDEX_HYPER_DICTS[1]['state']
|
||||
del INDEX_HYPER_DICTS[0]['status']
|
||||
del INDEX_HYPER_DICTS[1]['status']
|
||||
|
||||
def setUp(self):
|
||||
super(HypervisorsTestV2, self).setUp()
|
||||
self.rule_hyp_show = "compute_extension:hypervisors"
|
||||
self.rule = {self.rule_hyp_show: ""}
|
||||
|
||||
def _set_up_controller(self):
|
||||
self.context = context.get_admin_context()
|
||||
self.ext_mgr = extensions.ExtensionManager()
|
||||
self.ext_mgr.extensions = {}
|
||||
self.controller = hypervisors_v2.HypervisorsController(self.ext_mgr)
|
||||
|
||||
def test_index_non_admin_back_compatible_db(self):
|
||||
self.policy.set_rules(self.rule)
|
||||
req = self._get_request(False)
|
||||
self.assertRaises(exception.AdminRequired,
|
||||
self.controller.index, req)
|
||||
|
||||
def test_detail_non_admin_back_compatible_db(self):
|
||||
self.policy.set_rules(self.rule)
|
||||
req = self._get_request(False)
|
||||
self.assertRaises(exception.AdminRequired,
|
||||
self.controller.detail, req)
|
||||
|
||||
def test_search_non_admin_back_compatible_db(self):
|
||||
self.policy.set_rules(self.rule)
|
||||
req = self._get_request(False)
|
||||
self.assertRaises(exception.AdminRequired,
|
||||
self.controller.search, req,
|
||||
self.TEST_HYPERS_OBJ[0].id)
|
||||
|
||||
def test_servers_non_admin_back_compatible_db(self):
|
||||
self.policy.set_rules(self.rule)
|
||||
req = self._get_request(False)
|
||||
self.assertRaises(exception.AdminRequired,
|
||||
self.controller.servers, req,
|
||||
self.TEST_HYPERS_OBJ[0].id)
|
||||
|
||||
|
||||
_CELL_PATH = 'cell1'
|
||||
|
||||
|
||||
@@ -571,25 +511,3 @@ class CellHypervisorsTestV21(HypervisorsTestV21):
|
||||
fake_compute_node_statistics)
|
||||
self.stubs.Set(self.controller.host_api, 'instance_get_all_by_host',
|
||||
self.fake_instance_get_all_by_host)
|
||||
|
||||
|
||||
class CellHypervisorsTestV2(HypervisorsTestV2, CellHypervisorsTestV21):
|
||||
DETAIL_HYPERS_DICTS = copy.deepcopy(HypervisorsTestV2.DETAIL_HYPERS_DICTS)
|
||||
DETAIL_HYPERS_DICTS = [dict(hyp, id=cells_utils.cell_with_item(_CELL_PATH,
|
||||
hyp['id']),
|
||||
service=dict(hyp['service'],
|
||||
id=cells_utils.cell_with_item(
|
||||
_CELL_PATH,
|
||||
hyp['service']['id']),
|
||||
host=cells_utils.cell_with_item(
|
||||
_CELL_PATH,
|
||||
hyp['service']['host'])))
|
||||
for hyp in DETAIL_HYPERS_DICTS]
|
||||
|
||||
INDEX_HYPER_DICTS = copy.deepcopy(HypervisorsTestV2.INDEX_HYPER_DICTS)
|
||||
INDEX_HYPER_DICTS = [dict(hyp, id=cells_utils.cell_with_item(_CELL_PATH,
|
||||
hyp['id']))
|
||||
for hyp in INDEX_HYPER_DICTS]
|
||||
|
||||
def setUp(self):
|
||||
super(CellHypervisorsTestV2, self).setUp()
|
||||
|
||||
@@ -20,7 +20,6 @@ from oslo_serialization import jsonutils
|
||||
import webob
|
||||
|
||||
from nova.api.openstack.compute import image_metadata as image_metadata_v21
|
||||
from nova.api.openstack.compute.legacy_v2 import image_metadata
|
||||
from nova import exception
|
||||
from nova import test
|
||||
from nova.tests.unit.api.openstack import fakes
|
||||
@@ -349,23 +348,3 @@ class ImageMetaDataTestV21(test.NoDBTestCase):
|
||||
self.assertRaises(webob.exc.HTTPForbidden,
|
||||
self.controller.create, req, image_id,
|
||||
body=body)
|
||||
|
||||
|
||||
class ImageMetaDataTestV2(ImageMetaDataTestV21):
|
||||
controller_class = image_metadata.Controller
|
||||
invalid_request = webob.exc.HTTPBadRequest
|
||||
|
||||
# NOTE(cyeoh): This duplicate unittest is necessary for a race condition
|
||||
# with the V21 unittests. It's mock issue.
|
||||
@mock.patch('nova.image.api.API.update')
|
||||
@mock.patch('nova.image.api.API.get', return_value=get_image_123())
|
||||
def test_delete(self, _get_mocked, update_mocked):
|
||||
req = fakes.HTTPRequest.blank('/v2/fake/images/123/metadata/key1')
|
||||
req.method = 'DELETE'
|
||||
res = self.controller.delete(req, '123', 'key1')
|
||||
expected = copy.deepcopy(get_image_123())
|
||||
expected['properties'] = {}
|
||||
update_mocked.assert_called_once_with(mock.ANY, '123', expected,
|
||||
data=None, purge_props=True)
|
||||
|
||||
self.assertIsNone(res)
|
||||
|
||||
@@ -25,7 +25,6 @@ import six.moves.urllib.parse as urlparse
|
||||
import webob
|
||||
|
||||
from nova.api.openstack.compute import images as images_v21
|
||||
from nova.api.openstack.compute.legacy_v2 import images
|
||||
from nova.api.openstack.compute.views import images as images_view
|
||||
from nova import exception
|
||||
from nova.image import glance
|
||||
@@ -407,11 +406,3 @@ class ImagesControllerTestV21(test.NoDBTestCase):
|
||||
params = urlparse.parse_qs(href_parts.query)
|
||||
self.assertThat({'limit': ['1'], 'marker': [IMAGE_FIXTURES[0]['id']]},
|
||||
matchers.DictMatches(params))
|
||||
|
||||
|
||||
class ImagesControllerTestV2(ImagesControllerTestV21):
|
||||
image_controller_class = images.Controller
|
||||
http_request = fakes.HTTPRequest
|
||||
|
||||
def _check_response(self, controller_method, response, expected_code):
|
||||
self.assertEqual(expected_code, response.status_int)
|
||||
|
||||
@@ -22,8 +22,6 @@ import six
|
||||
from webob import exc
|
||||
|
||||
from nova.api.openstack.compute import instance_actions as instance_actions_v21
|
||||
from nova.api.openstack.compute.legacy_v2.contrib import instance_actions \
|
||||
as instance_actions_v2
|
||||
from nova.api.openstack import wsgi as os_wsgi
|
||||
from nova.compute import api as compute_api
|
||||
from nova.db.sqlalchemy import models
|
||||
@@ -108,16 +106,6 @@ class InstanceActionsPolicyTestV21(test.NoDBTestCase):
|
||||
str(uuid.uuid4()), '1')
|
||||
|
||||
|
||||
class InstanceActionsPolicyTestV2(InstanceActionsPolicyTestV21):
|
||||
instance_actions = instance_actions_v2
|
||||
|
||||
def _set_policy_rules(self):
|
||||
rules = {'compute:get': '',
|
||||
'compute_extension:instance_actions':
|
||||
'project_id:%(project_id)s'}
|
||||
policy.set_rules(oslo_policy.Rules.from_dict(rules))
|
||||
|
||||
|
||||
class InstanceActionsTestV21(test.NoDBTestCase):
|
||||
instance_actions = instance_actions_v21
|
||||
wsgi_api_version = os_wsgi.DEFAULT_API_VERSION
|
||||
@@ -238,13 +226,3 @@ class InstanceActionsTestV221(InstanceActionsTestV21):
|
||||
want_objects=False):
|
||||
self.assertEqual('yes', context.read_deleted)
|
||||
return objects.Instance(uuid=instance_uuid)
|
||||
|
||||
|
||||
class InstanceActionsTestV2(InstanceActionsTestV21):
|
||||
instance_actions = instance_actions_v2
|
||||
|
||||
def _set_policy_rules(self):
|
||||
rules = {'compute:get': '',
|
||||
'compute_extension:instance_actions': '',
|
||||
'compute_extension:instance_actions:events': 'is_admin:True'}
|
||||
policy.set_rules(oslo_policy.Rules.from_dict(rules))
|
||||
|
||||
@@ -20,8 +20,6 @@ import webob
|
||||
from oslo_policy import policy as oslo_policy
|
||||
|
||||
from nova.api.openstack.compute import keypairs as keypairs_v21
|
||||
from nova.api.openstack.compute.legacy_v2.contrib import keypairs \
|
||||
as keypairs_v2
|
||||
from nova.api.openstack import wsgi as os_wsgi
|
||||
from nova.compute import api as compute_api
|
||||
from nova import exception
|
||||
@@ -429,45 +427,6 @@ class KeypairPolicyTestV21(test.NoDBTestCase):
|
||||
self.KeyPairController.delete(self.req, 'FAKE')
|
||||
|
||||
|
||||
class KeypairsTestV2(KeypairsTestV21):
|
||||
validation_error = webob.exc.HTTPBadRequest
|
||||
|
||||
def _setup_app_and_controller(self):
|
||||
self.app_server = fakes.wsgi_app(init_only=('servers',))
|
||||
self.controller = keypairs_v2.KeypairController()
|
||||
|
||||
def test_keypair_create_with_name_leading_trailing_spaces(
|
||||
self):
|
||||
body = {'keypair': {'name': ' test '}}
|
||||
self.req.set_legacy_v2()
|
||||
res_dict = self.controller.create(self.req, body=body)
|
||||
self.assertEqual(' test ', res_dict['keypair']['name'])
|
||||
|
||||
def test_keypair_create_with_name_leading_trailing_spaces_compat_mode(
|
||||
self):
|
||||
pass
|
||||
|
||||
def test_create_server_keypair_name_with_leading_trailing(self):
|
||||
pass
|
||||
|
||||
@mock.patch.object(compute_api.API, 'create')
|
||||
def test_create_server_keypair_name_with_leading_trailing_compat_mode(
|
||||
self, mock_create):
|
||||
mock_create.return_value = (
|
||||
objects.InstanceList(objects=[
|
||||
fakes.stub_instance_obj(ctxt=None, id=1)]),
|
||||
None)
|
||||
req = fakes.HTTPRequest.blank(self.base_url + '/servers')
|
||||
req.method = 'POST'
|
||||
req.headers["content-type"] = "application/json"
|
||||
req.body = jsonutils.dump_as_bytes({'server': {'name': 'test',
|
||||
'flavorRef': 1,
|
||||
'keypair_name': ' abc ',
|
||||
'imageRef': FAKE_UUID}})
|
||||
res = req.get_response(self.app_server)
|
||||
self.assertEqual(202, res.status_code)
|
||||
|
||||
|
||||
class KeypairsTestV22(KeypairsTestV21):
|
||||
wsgi_api_version = '2.2'
|
||||
|
||||
@@ -594,11 +553,3 @@ class KeypairsTestV210(KeypairsTestV22):
|
||||
self.assertRaises(exception.PolicyNotAuthorized,
|
||||
self.controller.create,
|
||||
req, body=body)
|
||||
|
||||
|
||||
class KeypairPolicyTestV2(KeypairPolicyTestV21):
|
||||
KeyPairController = keypairs_v2.KeypairController()
|
||||
policy_path = 'compute_extension:keypairs'
|
||||
|
||||
def _assert_keypair_create(self, mock_create, req):
|
||||
mock_create.assert_called_with(req, 'fake_user', 'create_test')
|
||||
|
||||
@@ -13,13 +13,9 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import webob
|
||||
|
||||
import mock
|
||||
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack.compute.legacy_v2.contrib import admin_actions \
|
||||
as lock_server_v2
|
||||
from nova.api.openstack.compute import lock_server as lock_server_v21
|
||||
from nova import context
|
||||
from nova import exception
|
||||
@@ -68,13 +64,6 @@ class LockServerTestsV21(admin_only_action_common.CommonTests):
|
||||
self.req, instance.uuid, body)
|
||||
|
||||
|
||||
class LockServerTestsV2(LockServerTestsV21):
|
||||
lock_server = lock_server_v2
|
||||
controller_name = 'AdminActionsController'
|
||||
authorization_error = webob.exc.HTTPForbidden
|
||||
_api_version = '2'
|
||||
|
||||
|
||||
class LockServerPolicyEnforcementV21(test.NoDBTestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
||||
@@ -18,8 +18,6 @@ import six
|
||||
import webob
|
||||
|
||||
from nova.api.openstack import api_version_request
|
||||
from nova.api.openstack.compute.legacy_v2.contrib import admin_actions as \
|
||||
migrate_server_v2
|
||||
from nova.api.openstack.compute import migrate_server as \
|
||||
migrate_server_v21
|
||||
from nova import exception
|
||||
@@ -271,13 +269,6 @@ class MigrateServerTestsV21(admin_only_action_common.CommonTests):
|
||||
check_response=False)
|
||||
|
||||
|
||||
class MigrateServerTestsV2(MigrateServerTestsV21):
|
||||
migrate_server = migrate_server_v2
|
||||
controller_name = 'AdminActionsController'
|
||||
validation_error = webob.exc.HTTPBadRequest
|
||||
_api_version = '2'
|
||||
|
||||
|
||||
class MigrateServerTestsV225(MigrateServerTestsV21):
|
||||
|
||||
# We don't have disk_over_commit in v2.25
|
||||
|
||||
@@ -17,8 +17,6 @@ import mock
|
||||
|
||||
from oslotest import moxstubout
|
||||
|
||||
from nova.api.openstack.compute.legacy_v2.contrib import migrations \
|
||||
as migrations_v2
|
||||
from nova.api.openstack.compute import migrations as migrations_v21
|
||||
from nova import context
|
||||
from nova import exception
|
||||
@@ -183,28 +181,6 @@ class MigrationsTestCaseV21(test.NoDBTestCase):
|
||||
self.assertEqual(migrations_in_progress, response)
|
||||
|
||||
|
||||
class MigrationsTestCaseV2(MigrationsTestCaseV21):
|
||||
migrations = migrations_v2
|
||||
|
||||
def _migrations_output(self):
|
||||
return self.migrations.output(migrations_obj)
|
||||
|
||||
def setUp(self):
|
||||
super(MigrationsTestCaseV2, self).setUp()
|
||||
self.context = self.req.environ['nova.context']
|
||||
|
||||
def test_index_needs_authorization(self):
|
||||
user_context = context.RequestContext(user_id=None,
|
||||
project_id=None,
|
||||
is_admin=False,
|
||||
read_deleted="no",
|
||||
overwrite=False)
|
||||
self.req.environ['nova.context'] = user_context
|
||||
|
||||
self.assertRaises(exception.PolicyNotAuthorized, self.controller.index,
|
||||
self.req)
|
||||
|
||||
|
||||
class MigrationsTestCaseV223(MigrationsTestCaseV21):
|
||||
wsgi_api_version = '2.23'
|
||||
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
import mock
|
||||
import webob
|
||||
|
||||
from nova.api.openstack.compute.legacy_v2.contrib import multinic \
|
||||
as multinic_v2
|
||||
from nova.api.openstack.compute import multinic as multinic_v21
|
||||
from nova import compute
|
||||
from nova import exception
|
||||
@@ -164,16 +162,6 @@ class FixedIpTestV21(test.NoDBTestCase):
|
||||
UUID, body=body)
|
||||
|
||||
|
||||
class FixedIpTestV2(FixedIpTestV21):
|
||||
controller_class = multinic_v2
|
||||
validation_error = webob.exc.HTTPBadRequest
|
||||
|
||||
def test_remove_fixed_ip_invalid_address(self):
|
||||
# NOTE(cyeoh): This test is disabled for the V2 API because it is
|
||||
# has poorer input validation.
|
||||
pass
|
||||
|
||||
|
||||
class MultinicPolicyEnforcementV21(test.NoDBTestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
||||
@@ -20,10 +20,8 @@ import webob
|
||||
from nova.api.openstack.compute import block_device_mapping \
|
||||
as block_device_mapping_v21
|
||||
from nova.api.openstack.compute import extension_info
|
||||
from nova.api.openstack.compute.legacy_v2 import servers as servers_v20
|
||||
from nova.api.openstack.compute import multiple_create as multiple_create_v21
|
||||
from nova.api.openstack.compute import servers as servers_v21
|
||||
from nova.api.openstack import extensions as extensions_v20
|
||||
from nova.compute import api as compute_api
|
||||
from nova.compute import flavors
|
||||
import nova.conf
|
||||
@@ -496,82 +494,3 @@ class MultiCreateExtensionTestV21(test.TestCase):
|
||||
|
||||
self.assertRaises(self.validation_error,
|
||||
self.controller.create, self.req, body=body)
|
||||
|
||||
|
||||
class MultiCreateExtensionTestV2(MultiCreateExtensionTestV21):
|
||||
validation_error = webob.exc.HTTPBadRequest
|
||||
|
||||
def setUp(self):
|
||||
"""Shared implementation for tests below that create instance."""
|
||||
super(MultiCreateExtensionTestV2, self).setUp()
|
||||
|
||||
self.flags(verbose=True,
|
||||
enable_instance_password=True)
|
||||
self.instance_cache_num = 0
|
||||
self.instance_cache_by_id = {}
|
||||
self.instance_cache_by_uuid = {}
|
||||
|
||||
fakes.stub_out_nw_api(self)
|
||||
|
||||
self.ext_mgr = extensions_v20.ExtensionManager()
|
||||
self.ext_mgr.extensions = {
|
||||
'os-volumes': 'fake',
|
||||
'os-multiple-create': 'fake',
|
||||
'os-block-device-mapping-v2-boot': 'fake'
|
||||
}
|
||||
self.controller = servers_v20.Controller(self.ext_mgr)
|
||||
|
||||
no_mult_ext_mgr = extensions_v20.ExtensionManager()
|
||||
no_mult_ext_mgr.extensions = {
|
||||
'os-volumes': 'fake',
|
||||
'os-block-device-mapping-v2-boot': 'fake'
|
||||
}
|
||||
self.no_mult_create_controller = servers_v20.Controller(
|
||||
no_mult_ext_mgr)
|
||||
|
||||
def instance_create(context, inst):
|
||||
inst_type = flavors.get_flavor_by_flavor_id(3)
|
||||
image_uuid = '76fa36fc-c930-4bf3-8c8a-ea2a2420deb6'
|
||||
def_image_ref = 'http://localhost/images/%s' % image_uuid
|
||||
self.instance_cache_num += 1
|
||||
instance = fake_instance.fake_db_instance(**{
|
||||
'id': self.instance_cache_num,
|
||||
'display_name': inst['display_name'] or 'test',
|
||||
'uuid': inst['uuid'],
|
||||
'instance_type': inst_type,
|
||||
'access_ip_v4': '1.2.3.4',
|
||||
'access_ip_v6': 'fead::1234',
|
||||
'image_ref': inst.get('image_ref', def_image_ref),
|
||||
'user_id': 'fake',
|
||||
'project_id': 'fake',
|
||||
'reservation_id': inst['reservation_id'],
|
||||
"created_at": datetime.datetime(2010, 10, 10, 12, 0, 0),
|
||||
"updated_at": datetime.datetime(2010, 11, 11, 11, 0, 0),
|
||||
"config_drive": None,
|
||||
"progress": 0,
|
||||
"fixed_ips": [],
|
||||
"task_state": "",
|
||||
"vm_state": "",
|
||||
"root_device_name": inst.get('root_device_name', 'vda'),
|
||||
"security_groups": inst['security_groups'],
|
||||
})
|
||||
|
||||
self.instance_cache_by_id[instance['id']] = instance
|
||||
self.instance_cache_by_uuid[instance['uuid']] = instance
|
||||
return instance
|
||||
|
||||
def instance_get(context, instance_id):
|
||||
"""Stub for compute/api create() pulling in instance after
|
||||
scheduling
|
||||
"""
|
||||
return self.instance_cache_by_id[instance_id]
|
||||
|
||||
fakes.stub_out_rate_limiting(self.stubs)
|
||||
fakes.stub_out_key_pair_funcs(self.stubs)
|
||||
fake.stub_out_image_service(self)
|
||||
self.stub_out('nova.db.instance_create', instance_create)
|
||||
self.stub_out('nova.db.instance_get', instance_get)
|
||||
|
||||
def _check_multiple_create_extension_disabled(self, **kwargs):
|
||||
self.assertEqual(kwargs['min_count'], 1)
|
||||
self.assertEqual(kwargs['max_count'], 1)
|
||||
|
||||
@@ -25,13 +25,9 @@ import netaddr
|
||||
from oslo_config import cfg
|
||||
import webob
|
||||
|
||||
from nova.api.openstack.compute.legacy_v2.contrib import networks_associate
|
||||
from nova.api.openstack.compute.legacy_v2.contrib import os_networks \
|
||||
as networks
|
||||
from nova.api.openstack.compute import networks as networks_v21
|
||||
from nova.api.openstack.compute import networks_associate \
|
||||
as networks_associate_v21
|
||||
from nova.api.openstack import extensions
|
||||
import nova.context
|
||||
from nova import exception
|
||||
from nova.network import manager
|
||||
@@ -311,23 +307,6 @@ class NetworkCreateExceptionsTestV21(test.TestCase):
|
||||
body=self.new_network)
|
||||
|
||||
|
||||
class NetworkCreateExceptionsTestV2(NetworkCreateExceptionsTestV21):
|
||||
validation_error = webob.exc.HTTPBadRequest
|
||||
|
||||
def _setup(self):
|
||||
ext_mgr = extensions.ExtensionManager()
|
||||
ext_mgr.extensions = {'os-extended-networks': 'fake'}
|
||||
self.req = fakes.HTTPRequest.blank('', use_admin_context=True)
|
||||
|
||||
self.controller = networks.NetworkController(
|
||||
self.PassthroughAPI(), ext_mgr)
|
||||
|
||||
def test_network_create_with_both_cidr_and_cidr_v6(self):
|
||||
# NOTE: v2.0 API cannot handle this case, so we need to just
|
||||
# skip it on the API.
|
||||
pass
|
||||
|
||||
|
||||
class NetworksTestV21(test.NoDBTestCase):
|
||||
validation_error = exception.ValidationError
|
||||
|
||||
@@ -496,64 +475,6 @@ class NetworksTestV21(test.NoDBTestCase):
|
||||
self.req, uuid, {'disassociate': None})
|
||||
|
||||
|
||||
class NetworksTestV2(NetworksTestV21):
|
||||
validation_error = webob.exc.HTTPUnprocessableEntity
|
||||
|
||||
def _setup(self):
|
||||
ext_mgr = extensions.ExtensionManager()
|
||||
ext_mgr.extensions = {'os-extended-networks': 'fake'}
|
||||
self.controller = networks.NetworkController(self.fake_network_api,
|
||||
ext_mgr)
|
||||
self.neutron_ctrl = networks.NetworkController(
|
||||
neutron.API(skip_policy_check=False))
|
||||
self.req = fakes.HTTPRequest.blank('',
|
||||
project_id=fakes.FAKE_PROJECT_ID,
|
||||
use_admin_context=True)
|
||||
|
||||
def _check_status(self, res, method, code):
|
||||
self.assertEqual(res.status_int, code)
|
||||
|
||||
def test_network_create_not_extended(self):
|
||||
self.stubs.Set(self.controller, 'extended', False)
|
||||
# NOTE(vish): Verify that new params are not passed through if
|
||||
# extension is not enabled.
|
||||
|
||||
def no_mtu(*args, **kwargs):
|
||||
if 'mtu' in kwargs:
|
||||
raise test.TestingException("mtu should not pass through")
|
||||
return [{}]
|
||||
|
||||
self.stubs.Set(self.controller.network_api, 'create', no_mtu)
|
||||
self.new_network['network']['mtu'] = 9000
|
||||
self.controller.create(self.req, body=self.new_network)
|
||||
|
||||
def test_network_add_network_with_invalid_id(self):
|
||||
pass
|
||||
|
||||
def test_network_add_network_with_extra_arg(self):
|
||||
pass
|
||||
|
||||
def test_disassociate_host_and_project_with_non_admin(self):
|
||||
uuid = FAKE_NETWORKS[0]['uuid']
|
||||
self.assertRaises(
|
||||
exception.AdminRequired,
|
||||
self.controller._disassociate_host_and_project,
|
||||
self.non_admin_req, uuid, {'disassociate': None})
|
||||
|
||||
def test_network_add_with_non_admin(self):
|
||||
uuid = FAKE_NETWORKS[1]['uuid']
|
||||
self.assertRaises(
|
||||
exception.AdminRequired,
|
||||
self.controller.add,
|
||||
self.non_admin_req, body={'id': uuid})
|
||||
|
||||
def test_network_create_with_non_admin(self):
|
||||
self.assertRaises(
|
||||
exception.AdminRequired,
|
||||
self.controller.create,
|
||||
self.non_admin_req, body=self.new_network)
|
||||
|
||||
|
||||
class NetworksAssociateTestV21(test.NoDBTestCase):
|
||||
|
||||
def setUp(self):
|
||||
@@ -565,7 +486,7 @@ class NetworksAssociateTestV21(test.NoDBTestCase):
|
||||
self.admin_req = fakes.HTTPRequest.blank('', use_admin_context=True)
|
||||
|
||||
def _setup(self):
|
||||
self.controller = networks.NetworkController(self.fake_network_api)
|
||||
self.controller = networks_v21.NetworkController(self.fake_network_api)
|
||||
self.associate_controller = networks_associate_v21\
|
||||
.NetworkAssociateActionController(self.fake_network_api)
|
||||
self.neutron_assoc_ctrl = (
|
||||
@@ -603,7 +524,11 @@ class NetworksAssociateTestV21(test.NoDBTestCase):
|
||||
res, self.associate_controller._disassociate_project_only, 202)
|
||||
self.assertIsNone(self.fake_network_api.networks[1]['project_id'])
|
||||
res = self.controller.delete(self.req, 1)
|
||||
self.assertEqual(202, res.status_int)
|
||||
|
||||
# NOTE: On v2.1 code, delete method doesn't return anything and
|
||||
# the status code is decorated on wsgi_code of the method.
|
||||
self.assertIsNone(res)
|
||||
self.assertEqual(202, self.controller.delete.wsgi_code)
|
||||
|
||||
def test_network_associate_project_delete_fail(self):
|
||||
uuid = FAKE_NETWORKS[0]['uuid']
|
||||
@@ -661,50 +586,6 @@ class NetworksAssociateTestV21(test.NoDBTestCase):
|
||||
self.req, uuid, {'disassociate_host': None})
|
||||
|
||||
|
||||
class NetworksAssociateTestV2(NetworksAssociateTestV21):
|
||||
|
||||
def _setup(self):
|
||||
ext_mgr = extensions.ExtensionManager()
|
||||
ext_mgr.extensions = {'os-extended-networks': 'fake'}
|
||||
self.controller = networks.NetworkController(
|
||||
self.fake_network_api,
|
||||
ext_mgr)
|
||||
self.associate_controller = networks_associate\
|
||||
.NetworkAssociateActionController(self.fake_network_api)
|
||||
self.neutron_assoc_ctrl = (
|
||||
networks_associate.NetworkAssociateActionController(
|
||||
neutron.API(skip_policy_check=False)))
|
||||
self.req = fakes.HTTPRequest.blank('', use_admin_context=True)
|
||||
self.non_admin_req = fakes.HTTPRequest.blank('')
|
||||
|
||||
def _check_status(self, res, method, code):
|
||||
self.assertEqual(res.status_int, code)
|
||||
|
||||
def _test_network_neutron_associate_host_validation_failed(self, body):
|
||||
pass
|
||||
|
||||
def test_network_associate_host_with_non_admin(self):
|
||||
uuid = FAKE_NETWORKS[1]['uuid']
|
||||
self.assertRaises(
|
||||
exception.AdminRequired,
|
||||
self.associate_controller._associate_host,
|
||||
self.non_admin_req, uuid, body={'associate_host': "TestHost"})
|
||||
|
||||
def test_network_disassociate_host_only_with_non_admin(self):
|
||||
uuid = FAKE_NETWORKS[0]['uuid']
|
||||
self.assertRaises(
|
||||
exception.AdminRequired,
|
||||
self.associate_controller._disassociate_host_only,
|
||||
self.non_admin_req, uuid, {'disassociate_host': None})
|
||||
|
||||
def test_network_disassociate_project_only_with_non_admin(self):
|
||||
uuid = FAKE_NETWORKS[0]['uuid']
|
||||
self.assertRaises(
|
||||
exception.AdminRequired,
|
||||
self.associate_controller._disassociate_project_only,
|
||||
self.non_admin_req, uuid, {'disassociate_project': None})
|
||||
|
||||
|
||||
class NetworksEnforcementV21(test.NoDBTestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
||||
@@ -23,7 +23,7 @@ from oslo_serialization import jsonutils
|
||||
from oslo_utils import encodeutils
|
||||
import webob
|
||||
|
||||
from nova.api.openstack.compute.legacy_v2.contrib import security_groups
|
||||
from nova.api.openstack.compute import security_groups
|
||||
from nova import compute
|
||||
from nova import context
|
||||
import nova.db
|
||||
@@ -412,12 +412,6 @@ class TestNeutronSecurityGroupsV21(
|
||||
device_id=test_security_groups.FAKE_UUID1)
|
||||
|
||||
|
||||
class TestNeutronSecurityGroupsV2(TestNeutronSecurityGroupsV21):
|
||||
secgrp_ctl_cls = security_groups.SecurityGroupController
|
||||
server_secgrp_ctl_cls = security_groups.ServerSecurityGroupController
|
||||
secgrp_act_ctl_cls = security_groups.SecurityGroupActionController
|
||||
|
||||
|
||||
class TestNeutronSecurityGroupRulesTestCase(TestNeutronSecurityGroupsTestCase):
|
||||
def setUp(self):
|
||||
super(TestNeutronSecurityGroupRulesTestCase, self).setUp()
|
||||
|
||||
Reference in New Issue
Block a user