Fixes AC-470. Disable host name validation for now.

This commit is contained in:
Chris Church 2013-09-13 12:29:34 -04:00
parent c557ba6681
commit ac7c300948
2 changed files with 20 additions and 19 deletions

View File

@ -447,7 +447,7 @@ class HostSerializer(BaseSerializerWithVariables):
d['groups'] = [{'id': g.id, 'name': g.name} for g in obj.groups.all()]
return d
def validate_name(self, attrs, source):
def _validate_name(self, attrs, source):
name = unicode(attrs.get(source, ''))
# Allow hostname (except IPv6 for now) to specify the port # inline.
if name.count(':') == 1:

View File

@ -296,23 +296,6 @@ class InventoryTest(BaseTest):
self.assertEqual(Host.objects.get(id=host_data3['id']).variables, host_data3['variables'])
self.assertEqual(Host.objects.get(id=host_data3['id']).variables_dict, {'angry': 'penguin'})
# Try with invalid hostnames and invalid IPs.
data = dict(name='', inventory=inv.pk)
with self.current_user(self.super_django_user):
response = self.post(hosts, data=data, expect=400)
data = dict(name='not a valid host name', inventory=inv.pk)
with self.current_user(self.super_django_user):
response = self.post(hosts, data=data, expect=400)
data = dict(name='validhost:99999', inventory=inv.pk)
with self.current_user(self.super_django_user):
response = self.post(hosts, data=data, expect=400)
data = dict(name='123.234.345.456', inventory=inv.pk)
with self.current_user(self.super_django_user):
response = self.post(hosts, data=data, expect=400)
data = dict(name='2001::1::3F', inventory=inv.pk)
with self.current_user(self.super_django_user):
response = self.post(hosts, data=data, expect=400)
###########################################
# GROUPS
@ -353,7 +336,6 @@ class InventoryTest(BaseTest):
with self.current_user(self.super_django_user):
response = self.post(groups, data=data, expect=400)
#################################################
# HOSTS->inventories POST via subcollection
@ -687,6 +669,25 @@ class InventoryTest(BaseTest):
self.assertFalse(gx3 in gx2.children.all())
self.assertTrue(gx4 in gx2.children.all())
# Try with invalid hostnames and invalid IPs.
hosts = reverse('main:host_list')
invalid_expect = 201 # hostname validation is disabled for now.
data = dict(name='', inventory=inv.pk)
with self.current_user(self.super_django_user):
response = self.post(hosts, data=data, expect=400)
data = dict(name='not a valid host name', inventory=inv.pk)
with self.current_user(self.super_django_user):
response = self.post(hosts, data=data, expect=invalid_expect)
data = dict(name='validhost:99999', inventory=inv.pk)
with self.current_user(self.super_django_user):
response = self.post(hosts, data=data, expect=invalid_expect)
data = dict(name='123.234.345.456', inventory=inv.pk)
with self.current_user(self.super_django_user):
response = self.post(hosts, data=data, expect=invalid_expect)
data = dict(name='2001::1::3F', inventory=inv.pk)
with self.current_user(self.super_django_user):
response = self.post(hosts, data=data, expect=invalid_expect)
#########################################################
# FIXME: TAGS