summaryrefslogtreecommitdiff
path: root/neutron/tests/unit/test_attributes.py
diff options
context:
space:
mode:
Diffstat (limited to 'neutron/tests/unit/test_attributes.py')
-rw-r--r--neutron/tests/unit/test_attributes.py22
1 files changed, 14 insertions, 8 deletions
diff --git a/neutron/tests/unit/test_attributes.py b/neutron/tests/unit/test_attributes.py
index f8cb462b3e..2707af27f9 100644
--- a/neutron/tests/unit/test_attributes.py
+++ b/neutron/tests/unit/test_attributes.py
@@ -279,9 +279,7 @@ class TestAttributes(base.BaseTestCase):
def test_validate_nameservers(self):
ns_pools = [['1.1.1.2', '1.1.1.2'],
['www.hostname.com', 'www.hostname.com'],
- ['77.hostname.com'],
['1000.0.0.1'],
- ['111111111111111111111111111111111111111111111111111111111111'], # noqa
None]
for ns in ns_pools:
@@ -292,6 +290,8 @@ class TestAttributes(base.BaseTestCase):
['www.hostname.com'],
['www.great.marathons.to.travel'],
['valid'],
+ ['77.hostname.com'],
+ ['1' * 59],
['www.internal.hostname.com']]
for ns in ns_pools:
@@ -342,13 +342,19 @@ class TestAttributes(base.BaseTestCase):
self.assertEqual(msg, "'%s' is not a valid IP address" % ip_addr)
def test_hostname_pattern(self):
- data = '@openstack'
- msg = attributes._validate_regex(data, attributes.HOSTNAME_PATTERN)
- self.assertIsNotNone(msg)
+ bad_values = ['@openstack', 'ffff.abcdefg' * 26, 'f' * 80, '-hello',
+ 'goodbye-', 'example..org']
+ for data in bad_values:
+ msg = attributes._validate_hostname(data)
+ self.assertIsNotNone(msg)
- data = 'www.openstack.org'
- msg = attributes._validate_regex(data, attributes.HOSTNAME_PATTERN)
- self.assertIsNone(msg)
+ # All numeric hostnames are allowed per RFC 1123 section 2.1
+ good_values = ['www.openstack.org', '1234x', '1234',
+ 'openstack-1', 'v.xyz', '1' * 50, 'a1a',
+ 'x.x1x', 'x.yz', 'example.org.']
+ for data in good_values:
+ msg = attributes._validate_hostname(data)
+ self.assertIsNone(msg)
def test_uuid_pattern(self):
data = 'garbage'