'Makes sure that we cannot deallocaate or disassociate
a public IP of other project.'

@mock.patch('nova.db.fixed_ip_get_by_address')
@mock.patch('nova.db.network_get')
def test_ip_association_and_allocation_of_other_project(self, net_get, fixed_get):

    net_get.return_value = dict(test_network.fake_network, **networks[1])
    context1 = context.RequestContext('user', fakes.FAKE_PROJECT_ID)
    context2 = context.RequestContext('user', 'project2')
    float_ip = db.floating_ip_create(context1.elevated(), {'address': '1.2.3.4', 'project_id': context1.project_id})
    float_addr = float_ip['address']
    instance = db.instance_create(context1, {'project_id': fakes.FAKE_PROJECT_ID})
    fix_addr = db.fixed_ip_associate_pool(context1.elevated(), 1, instance['uuid']).address
    fixed_get.return_value = dict(test_fixed_ip.fake_fixed_ip, address=fix_addr, instance_uuid=instance.uuid, network=dict(test_network.fake_network, **networks[1]))
    self.assertRaises(exception.Forbidden, self.network.associate_floating_ip, context2, float_addr, fix_addr)
    self.assertRaises(exception.Forbidden, self.network.deallocate_floating_ip, context2, float_addr)
    self.network.associate_floating_ip(context1, float_addr, fix_addr)
    self.assertRaises(exception.Forbidden, self.network.disassociate_floating_ip, context2, float_addr)
    self.network.disassociate_floating_ip(context1, float_addr)
    self.network.deallocate_floating_ip(context1, float_addr)
    self.network.deallocate_fixed_ip(context1, fix_addr, 'fake')
    db.floating_ip_destroy(context1.elevated(), float_addr)
    db.fixed_ip_disassociate(context1.elevated(), fix_addr)
