Skip to content

Commit

Permalink
Merge "Keep is_shared and global_access consistent in chmod API"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Sep 26, 2016
2 parents fd27e38 + 8787317 commit 6c1732b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/config/api-server/tests/test_perms2.py
Original file line number Diff line number Diff line change
Expand Up @@ -948,9 +948,18 @@ def test_chmod_api(self):
logger.info( 'alice: create VN in her project')
vn_fq_name = [self.domain_name, alice.project, self.vn_name]
vn = VirtualNetwork(self.vn_name, self.alice.project_obj)
vn.set_is_shared(False)
self.alice.vnc_lib.virtual_network_create(vn)
vn = vnc_read_obj(alice.vnc_lib, 'virtual-network', name = vn_fq_name)

# validate chmod of global perms reflected in is_shared flag
alice.vnc_lib.chmod(vn.get_uuid(), global_access=PERMS_R)
vn = vnc_read_obj(self.alice.vnc_lib, 'virtual-network', name = vn_fq_name)
self.assertEquals(vn.get_is_shared(), True)
alice.vnc_lib.chmod(vn.get_uuid(), global_access=0)
vn = vnc_read_obj(self.alice.vnc_lib, 'virtual-network', name = vn_fq_name)
self.assertEquals(vn.get_is_shared(), False)

logger.info( "Verify Bob cannot chmod Alice's virtual network")
self.assertRaises(PermissionDenied, bob.vnc_lib.chmod, vn.get_uuid(), owner=bob.project_uuid)

Expand Down
3 changes: 2 additions & 1 deletion src/config/api-server/vnc_cfg_api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1845,7 +1845,7 @@ def obj_chmod_http_post(self):
global_access = request_params.get('global_access')

(ok, obj_dict) = self._db_conn.dbe_read(obj_type, {'uuid':obj_uuid},
obj_fields=['perms2'])
obj_fields=['perms2', 'is_shared'])
obj_perms = obj_dict['perms2']
old_perms = '%s/%d %d %s' % (obj_perms['owner'],
obj_perms['owner_access'], obj_perms['global_access'],
Expand Down Expand Up @@ -1880,6 +1880,7 @@ def obj_chmod_http_post(self):
raise cfgm_common.exceptions.HttpError(
400, "Bad Request, invalid global_access value")
obj_perms['global_access'] = global_access
obj_dict['is_shared'] = (global_access != 0)

new_perms = '%s/%d %d %s' % (obj_perms['owner'],
obj_perms['owner_access'], obj_perms['global_access'],
Expand Down

0 comments on commit 6c1732b

Please sign in to comment.