From 0fdbea56baaef08575b98e8a553ceac9876e4962 Mon Sep 17 00:00:00 2001 From: Ken Pepple Date: Sun, 21 Aug 2011 17:52:14 -0700 Subject: added exception catch and test for bad prefix --- nova/ipv6/rfc2462.py | 2 ++ nova/tests/test_ipv6.py | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/nova/ipv6/rfc2462.py b/nova/ipv6/rfc2462.py index 351df742e..acf42d201 100644 --- a/nova/ipv6/rfc2462.py +++ b/nova/ipv6/rfc2462.py @@ -32,6 +32,8 @@ def to_global(prefix, mac, project_id): format() except netaddr.AddrFormatError: raise TypeError(_('Bad mac for to_global_ipv6: %s') % mac) + except TypeError: + raise TypeError(_('Bad prefix for to_global_ipv6: %s') % prefix) def to_mac(ipv6_address): diff --git a/nova/tests/test_ipv6.py b/nova/tests/test_ipv6.py index 891d52358..6e72b7330 100644 --- a/nova/tests/test_ipv6.py +++ b/nova/tests/test_ipv6.py @@ -45,6 +45,13 @@ class IPv6RFC2462TestCase(test.TestCase): self.assertRaises(TypeError, ipv6.to_global, '2001:db8::', bad_mac, 'test') + def test_to_global_with_bad_prefix(self): + bad_prefix = '82' + self.assertRaises(TypeError, ipv6.to_global, + bad_prefix, + '2001:db8::216:3eff:fe33:4455', + 'test') + class IPv6AccountIdentiferTestCase(test.TestCase): """Unit tests for IPv6 account_identifier backend operations.""" -- cgit