FirewallGroupPortInvalidProject can be raised now

Earlier 'tenant_id' was passed instead of 'project_id'
which resulted in AttributeError.
This patch fixes the issue and also adds a covering unit test.

Change-Id: I64ce925537823644176753952d00c41b16c26924
Closes-Bug: #1711127
This commit is contained in:
Inessa Vasilevskaya 2017-08-16 12:48:35 +00:00
parent a6b0f95241
commit c76e12cf64
2 changed files with 29 additions and 1 deletions

View File

@ -231,7 +231,7 @@ class FirewallPluginV2(
raise f_exc.FirewallGroupPortInvalid(port_id=port_id)
if port_db['tenant_id'] != tenant_id:
raise f_exc.FirewallGroupPortInvalidProject(
port_id=port_id, tenant_id=port_db['tenant_id'])
port_id=port_id, project_id=port_db['tenant_id'])
return
def _check_no_need_pending(self, context, fwg_id, fwg_body):

View File

@ -670,6 +670,34 @@ class TestFirewallPluginBasev2(TestFirewallRouterPortBase,
s['subnet']['id'],
None)
def test_update_firewall_group_with_invalid_project(self):
with self.router(name='router1',
admin_state_up=True,
tenant_id=self._tenant_id) as r, \
self.subnet(cidr='30.0.0.0/24') as s:
body = self._router_interface_action('add',
r['router']['id'],
s['subnet']['id'],
None)
port_id = body['port_id']
with self.firewall_group(name='test',
default_policy=False,
ports=[],
admin_state_up=True) as fwg1:
data = {'firewall_group': {'ports': [port_id]}}
req = self.new_update_request(
'firewall_groups', data, fwg1['firewall_group']['id'],
context=context.get_admin_context())
res = self.deserialize(self.fmt,
req.get_response(self.ext_api))
self.assertEqual('FirewallGroupPortInvalidProject',
res['NeutronError']['type'])
self._router_interface_action('remove',
r['router']['id'],
s['subnet']['id'],
None)
def test_update_firewall_group_with_ports_and_polcy(self):
"""neutron firewall_group create test-policy """
with self.router(name='router1', admin_state_up=True,