Merge "Enforce UUID of port/subnet ID for router interfaces" into stable/liberty
This commit is contained in:
commit
8ae106e04e
|
@ -518,6 +518,12 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase):
|
|||
if not (port_id_specified or subnet_id_specified):
|
||||
msg = _("Either subnet_id or port_id must be specified")
|
||||
raise n_exc.BadRequest(resource='router', msg=msg)
|
||||
for key in ('port_id', 'subnet_id'):
|
||||
if key not in interface_info:
|
||||
continue
|
||||
err = attributes._validate_uuid(interface_info[key])
|
||||
if err:
|
||||
raise n_exc.BadRequest(resource='router', msg=err)
|
||||
if not for_removal:
|
||||
if port_id_specified and subnet_id_specified:
|
||||
msg = _("Cannot specify both subnet-id and port-id")
|
||||
|
|
|
@ -379,9 +379,9 @@ class L3NatTestCaseMixin(object):
|
|||
tenant_id=None,
|
||||
msg=None):
|
||||
interface_data = {}
|
||||
if subnet_id:
|
||||
if subnet_id is not None:
|
||||
interface_data.update({'subnet_id': subnet_id})
|
||||
if port_id:
|
||||
if port_id is not None:
|
||||
interface_data.update({'port_id': port_id})
|
||||
|
||||
req = self.new_action_request('routers', interface_data, router_id,
|
||||
|
@ -960,6 +960,20 @@ class L3NatTestCaseBase(L3NatTestCaseMixin):
|
|||
# nsx metadata access case
|
||||
self.assertIn(payload['tenant_id'], [stid, ''], msg)
|
||||
|
||||
def test_router_add_interface_bad_values(self):
|
||||
with self.router() as r:
|
||||
exp_code = exc.HTTPBadRequest.code
|
||||
self._router_interface_action('add',
|
||||
r['router']['id'],
|
||||
False,
|
||||
None,
|
||||
expected_code=exp_code)
|
||||
self._router_interface_action('add',
|
||||
r['router']['id'],
|
||||
None,
|
||||
False,
|
||||
expected_code=exp_code)
|
||||
|
||||
def test_router_add_interface_subnet(self):
|
||||
fake_notifier.reset()
|
||||
with self.router() as r:
|
||||
|
|
Loading…
Reference in New Issue