From f4cd3a72fa2a3630ccab2c0224777c3eff05380e Mon Sep 17 00:00:00 2001 From: Ken Pepple Date: Sat, 20 Aug 2011 14:55:41 -0700 Subject: added rainy day test for ipv6 tests. fixed ipv6.to_global to trap correct exception. --- nova/ipv6/rfc2462.py | 2 +- nova/tests/test_ipv6.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/nova/ipv6/rfc2462.py b/nova/ipv6/rfc2462.py index 0074efe98..351df742e 100644 --- a/nova/ipv6/rfc2462.py +++ b/nova/ipv6/rfc2462.py @@ -30,7 +30,7 @@ def to_global(prefix, mac, project_id): maskIP = netaddr.IPNetwork(prefix).ip return (mac64_addr ^ netaddr.IPAddress('::0200:0:0:0') | maskIP).\ format() - except TypeError: + except netaddr.AddrFormatError: raise TypeError(_('Bad mac for to_global_ipv6: %s') % mac) diff --git a/nova/tests/test_ipv6.py b/nova/tests/test_ipv6.py index d123df6f1..12d64f776 100644 --- a/nova/tests/test_ipv6.py +++ b/nova/tests/test_ipv6.py @@ -23,6 +23,7 @@ from nova import test LOG = logging.getLogger('nova.tests.test_ipv6') import sys +import netaddr class IPv6RFC2462TestCase(test.TestCase): @@ -40,6 +41,11 @@ class IPv6RFC2462TestCase(test.TestCase): mac = ipv6.to_mac('2001:db8::216:3eff:fe33:4455') self.assertEquals(mac, '00:16:3e:33:44:55') + def test_to_global_with_bad_mac(self): + bad_mac = '02:16:3e:33:44:5Z' + self.assertRaises(TypeError, ipv6.to_global, + '2001:db8::', bad_mac, 'test') + class IPv6AccountIdentiferTestCase(test.TestCase): """Unit tests for IPv6 account_identifier backend operations.""" -- cgit