Skip to content

Commit

Permalink
Merge "While returning list collection ensure shared objects are not …
Browse files Browse the repository at this point in the history
…sent twice"
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Jul 23, 2016
2 parents 81ff67e + e01cbdb commit 0cf0c01
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/config/api-server/tests/test_perms2.py
Expand Up @@ -967,6 +967,31 @@ def test_chmod_api(self):
alice.vnc_lib.chmod(vn.get_uuid(), owner=valid_uuid_2)
admin.vnc_lib.chmod(vn.get_uuid(), owner=alice.project_uuid)

def test_bug_1604986(self):
"""
1) Create a VN
2) Make is globally shared
3) list of virtual-networks should not return VN information twice
"""
admin = self.admin
vn_name = "test-vn-1604986"
vn_fq_name = [self.domain_name, admin.project, vn_name]

test_vn = VirtualNetwork(vn_name, admin.project_obj)
self.admin.vnc_lib.virtual_network_create(test_vn)

z = self.admin.vnc_lib.resource_list('virtual-network')
test_vn_list = [vn for vn in z['virtual-networks'] if vn['fq_name'][-1] == vn_name]
self.assertEquals(len(test_vn_list), 1)

test_vn = vnc_read_obj(self.admin.vnc_lib, 'virtual-network', name = vn_fq_name)
set_perms(test_vn, global_access = PERMS_RWX)
admin.vnc_lib.virtual_network_update(test_vn)

z = self.admin.vnc_lib.resource_list('virtual-network')
test_vn_list = [vn for vn in z['virtual-networks'] if vn['fq_name'][-1] == vn_name]
self.assertEquals(len(test_vn_list), 1)

def tearDown(self):
super(TestPermissions, self).tearDown()
# end tearDown
4 changes: 4 additions & 0 deletions src/config/api-server/vnc_cfg_api_server.py
Expand Up @@ -2865,7 +2865,11 @@ def _list_collection(self, obj_type, parent_uuids=None,
shares = self._db_conn.get_shared_objects(obj_type, tenant_uuid)
except NoIdError:
shares = []
owned_objs = set([obj_uuid for (fq_name, obj_uuid) in result])
for (obj_uuid, obj_perm) in shares:
# skip owned objects already included in results
if obj_uuid in owned_objs:
continue
try:
fq_name = self._db_conn.uuid_to_fq_name(obj_uuid)
result.append((fq_name, obj_uuid))
Expand Down

0 comments on commit 0cf0c01

Please sign in to comment.