From ac7c300948682e163d1a7bb48150626cf7a0132e Mon Sep 17 00:00:00 2001 From: Chris Church Date: Fri, 13 Sep 2013 12:29:34 -0400 Subject: [PATCH] Fixes AC-470. Disable host name validation for now. --- awx/main/serializers.py | 2 +- awx/main/tests/inventory.py | 37 +++++++++++++++++++------------------ 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/awx/main/serializers.py b/awx/main/serializers.py index e30748ca55..1e4cb67530 100644 --- a/awx/main/serializers.py +++ b/awx/main/serializers.py @@ -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: diff --git a/awx/main/tests/inventory.py b/awx/main/tests/inventory.py index cf4b605b09..21ddc4b0a3 100644 --- a/awx/main/tests/inventory.py +++ b/awx/main/tests/inventory.py @@ -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