diff options
| author | Russell Bryant <rbryant@redhat.com> | 2013-02-01 04:06:09 -0500 |
|---|---|---|
| committer | Russell Bryant <rbryant@redhat.com> | 2013-02-02 16:15:50 +0100 |
| commit | ed45c0b95d6eea0d4a40437dcbbc5920a72aa939 (patch) | |
| tree | d66e36d12540f4afb8e2c5fa90b99db2bc4116b7 /nova/tests | |
| parent | 795d1bcfd13aae2d07f52a2a1a51117e78a234c8 (diff) | |
Reimplement is_valid_ipv4().
This patch reimplements the is_valid_ipv4() function is nova.utils.
Instead of open-coding the validity check, just make use of the netaddr
module, which is already used elsewhere in nova.utils.
Also add a unit test for this code.
Part of indigoprint bored-on-an-airplane.
Change-Id: Ia89cbbd94a0ac4631d794d658b53c244237e1ca2
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/test_utils.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/nova/tests/test_utils.py b/nova/tests/test_utils.py index 5c5c226f9..dea6f12d9 100644 --- a/nova/tests/test_utils.py +++ b/nova/tests/test_utils.py @@ -476,6 +476,11 @@ class GenericUtilsTestCase(test.TestCase): self.assertFalse(utils.is_valid_boolstr('maybe')) self.assertFalse(utils.is_valid_boolstr('only on tuesdays')) + def test_is_valid_ipv4(self): + self.assertTrue(utils.is_valid_ipv4('127.0.0.1')) + self.assertFalse(utils.is_valid_ipv4('::1')) + self.assertFalse(utils.is_valid_ipv4('bacon')) + class MonkeyPatchTestCase(test.TestCase): """Unit test for utils.monkey_patch().""" |
