Merge "Fix sharing a zone with the zone owner"
This commit is contained in:
commit
6591b53e50
@ -1209,6 +1209,10 @@ class Service(service.RPCService):
|
|||||||
|
|
||||||
policy.check('share_zone', context, target)
|
policy.check('share_zone', context, target)
|
||||||
|
|
||||||
|
if zone.tenant_id == shared_zone.target_project_id:
|
||||||
|
raise exceptions.BadRequest(
|
||||||
|
'Cannot share the zone with the zone owner.')
|
||||||
|
|
||||||
shared_zone['project_id'] = context.project_id
|
shared_zone['project_id'] = context.project_id
|
||||||
shared_zone['zone_id'] = zone_id
|
shared_zone['zone_id'] = zone_id
|
||||||
|
|
||||||
|
@ -3817,6 +3817,17 @@ class CentralServiceTest(CentralTestCase):
|
|||||||
self.assertEqual(context.project_id, shared_zone.project_id)
|
self.assertEqual(context.project_id, shared_zone.project_id)
|
||||||
self.assertEqual(zone.id, shared_zone.zone_id)
|
self.assertEqual(zone.id, shared_zone.zone_id)
|
||||||
|
|
||||||
|
def test_share_zone_with_zone_owner(self):
|
||||||
|
# Create a Shared Zone
|
||||||
|
context = self.get_context(project_id='1')
|
||||||
|
zone = self.create_zone(context=context)
|
||||||
|
exc = self.assertRaises(
|
||||||
|
rpc_dispatcher.ExpectedException, self.share_zone,
|
||||||
|
context=context, zone_id=zone.id,
|
||||||
|
target_project_id=zone.tenant_id)
|
||||||
|
|
||||||
|
self.assertEqual(exceptions.BadRequest, exc.exc_info[0])
|
||||||
|
|
||||||
def test_unshare_zone(self):
|
def test_unshare_zone(self):
|
||||||
context = self.get_context(project_id='1', roles=['member', 'reader'])
|
context = self.get_context(project_id='1', roles=['member', 'reader'])
|
||||||
zone = self.create_zone(context=context)
|
zone = self.create_zone(context=context)
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Fixed a bug that allowed users to create a zone share for the zone owner.
|
Loading…
Reference in New Issue
Block a user