Skip to content

Commit 00dc6b7

Browse files
author
Anton Arefiev
committed
Fix tempest test_associate_floating_ip_with_port_from_another_project
Return 400 instead of 404 on floatingip update with port from another project. Closes-Bug: #1807447 Change-Id: Icb58b681fa89b36552ac65f22ad3612ad7dd6958
1 parent b98a061 commit 00dc6b7

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/config/vnc_openstack/vnc_openstack/neutron_plugin_db.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2388,7 +2388,10 @@ def _floatingip_neutron_to_vnc(self, context, fip_q, oper):
23882388
port_tenant_id = self._get_obj_tenant_id('port', port_id)
23892389
if context and not context['is_admin']:
23902390
if port_tenant_id != context['tenant'].replace('-', ''):
2391-
raise NoIdError(port_id)
2391+
self._raise_contrail_exception(
2392+
'BadRequest',
2393+
resource='floatingip',
2394+
msg='Port %s is from another project' % port_id)
23922395

23932396
fip_proj_list = fip_obj.get_project_refs()
23942397
if fip_proj_list:

src/config/vnc_openstack/vnc_openstack/tests/test_vnc_plugin_db.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
from flexmock import flexmock
77
import sys
88

9+
import bottle
10+
911
from . import fake_neutron
1012
from vnc_openstack import neutron_plugin_db as db
1113
from cfgm_common.tests.test_utils import FakeKazooClient
@@ -208,3 +210,27 @@ def _sg_delete(id):
208210
'%s/%s' %
209211
(dbi.security_group_lock_prefix, sg_uuid))
210212
dbi.security_group_delete(context, sg_uuid)
213+
214+
def test_floating_update_port_from_another_project(self):
215+
dbi = MockDbInterface()
216+
dbi._get_obj_tenant_id=lambda r, id: 'Another project'
217+
218+
dbi._vnc_lib = flexmock(
219+
fq_name_to_id=lambda res, name: 'fip_pool_uuid',
220+
floating_ip_read=lambda id: 'fip_obj',
221+
virtual_machine_interface_read=lambda id, fq_name, fields: None,
222+
logical_routers_list=lambda parent_id, detail: [
223+
flexmock(uuid='router_uuid',
224+
get_virtual_machine_interface_refs=lambda: [{'uuid': 'router_port_uuid'}])])
225+
226+
id_perms_obj = flexmock(
227+
uuid='id_perms_uuid',
228+
get_created=lambda: 'create_time',
229+
get_last_modified=lambda: 'last_modified_time',
230+
get_description=lambda: 'description')
231+
232+
with self.assertRaises(bottle.HTTPError):
233+
fip_neutron = dbi._floatingip_neutron_to_vnc(
234+
{'tenant': 'tenant', 'is_admin': False},
235+
{'id': 1, 'port_id': 11},
236+
db.UPDATE)

0 commit comments

Comments
 (0)