From 66d0cb1ce5c9d716ad93685ab6e6e86ddbd0b293 Mon Sep 17 00:00:00 2001 From: Michael Still Date: Thu, 27 Dec 2012 16:15:12 +1100 Subject: Invalid EC2 ids should make the entire request fail. Resolves bug 836978. I suspect there are many other cases where we should add this check. Change-Id: I027e44db2e27eb1ef913ddad8560cca08388906b --- nova/tests/api/ec2/test_cloud.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'nova/tests') diff --git a/nova/tests/api/ec2/test_cloud.py b/nova/tests/api/ec2/test_cloud.py index 831143326..2d2ecec9e 100644 --- a/nova/tests/api/ec2/test_cloud.py +++ b/nova/tests/api/ec2/test_cloud.py @@ -781,11 +781,30 @@ class CloudTestCase(test.TestCase): self.assertEqual(instance['privateIpAddress'], '192.168.0.3') self.assertEqual(instance['dnsNameV6'], 'fe80:b33f::a8bb:ccff:fedd:eeff') + + # A filter with even one invalid id should cause an exception to be + # raised + self.assertRaises(exception.InstanceNotFound, + self.cloud.describe_instances, self.context, + instance_id=[instance_id, '435679']) + db.instance_destroy(self.context, inst1['uuid']) db.instance_destroy(self.context, inst2['uuid']) db.service_destroy(self.context, comp1['id']) db.service_destroy(self.context, comp2['id']) + def test_describe_instances_all_invalid(self): + """Makes sure describe_instances works and filters results.""" + self.flags(use_ipv6=True) + + self._stub_instance_get_with_fixed_ips('get_all') + self._stub_instance_get_with_fixed_ips('get') + + instance_id = ec2utils.id_to_ec2_inst_id('435679') + self.assertRaises(exception.InstanceNotFound, + self.cloud.describe_instances, self.context, + instance_id=[instance_id]) + def test_describe_instances_sorting(self): """Makes sure describe_instances works and is sorted as expected.""" self.flags(use_ipv6=True) -- cgit