mirror of
https://github.com/ansible/awx.git
synced 2026-01-20 22:18:01 -03:30
Fixes AC-470. Disable host name validation for now.
This commit is contained in:
parent
c557ba6681
commit
ac7c300948
@ -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:
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user