From 07105cb78e366d35dd8c8a046c951780c274e9a2 Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Mon, 23 Jul 2012 08:20:37 -0700 Subject: Return 404 when attempting to remove a non-existent floating ip This fixes bug 993774 and returns 404 instead of 202 when trying to delete a floating ip from an instance to which it is not allocated. Change-Id: I9538a8a71cbbb9d19e9ebb76f93b180dbf619764 --- .../api/openstack/compute/contrib/test_floating_ips.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'nova/tests') diff --git a/nova/tests/api/openstack/compute/contrib/test_floating_ips.py b/nova/tests/api/openstack/compute/contrib/test_floating_ips.py index bd752b6e5..8a3a2ece1 100644 --- a/nova/tests/api/openstack/compute/contrib/test_floating_ips.py +++ b/nova/tests/api/openstack/compute/contrib/test_floating_ips.py @@ -99,6 +99,10 @@ def stub_nw_info(stubs): return get_nw_info_for_instance +def get_instance_by_floating_ip_addr(self, context, address): + return None + + class FloatingIpTest(test.TestCase): floating_ip = "10.10.10.10" @@ -129,6 +133,8 @@ class FloatingIpTest(test.TestCase): network_api_release) self.stubs.Set(network.api.API, "disassociate_floating_ip", network_api_disassociate) + self.stubs.Set(network.api.API, "get_instance_id_by_floating_address", + get_instance_by_floating_ip_addr) self.stubs.Set(compute_utils, "get_nw_info_for_instance", stub_nw_info(self.stubs)) @@ -275,6 +281,13 @@ class FloatingIpTest(test.TestCase): req = fakes.HTTPRequest.blank('/v2/fake/servers/test_inst/action') self.manager._remove_floating_ip(req, 'test_inst', body) + def test_floating_ip_disassociate_missing(self): + body = dict(removeFloatingIp=dict(address='10.10.10.10')) + + req = fakes.HTTPRequest.blank('/v2/fake/servers/test_inst/action') + rsp = self.manager._remove_floating_ip(req, 'test_inst', body) + self.assertTrue(rsp.status_int == 404) + # these are a few bad param tests def test_bad_address_param_in_remove_floating_ip(self): -- cgit