mirror of
https://github.com/ansible/awx.git
synced 2026-05-14 21:07:39 -02:30
Fixes AC-470. Disable host name validation for now.
This commit is contained in:
@@ -447,7 +447,7 @@ class HostSerializer(BaseSerializerWithVariables):
|
|||||||
d['groups'] = [{'id': g.id, 'name': g.name} for g in obj.groups.all()]
|
d['groups'] = [{'id': g.id, 'name': g.name} for g in obj.groups.all()]
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def validate_name(self, attrs, source):
|
def _validate_name(self, attrs, source):
|
||||||
name = unicode(attrs.get(source, ''))
|
name = unicode(attrs.get(source, ''))
|
||||||
# Allow hostname (except IPv6 for now) to specify the port # inline.
|
# Allow hostname (except IPv6 for now) to specify the port # inline.
|
||||||
if name.count(':') == 1:
|
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, host_data3['variables'])
|
||||||
self.assertEqual(Host.objects.get(id=host_data3['id']).variables_dict, {'angry': 'penguin'})
|
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
|
# GROUPS
|
||||||
|
|
||||||
@@ -353,7 +336,6 @@ class InventoryTest(BaseTest):
|
|||||||
with self.current_user(self.super_django_user):
|
with self.current_user(self.super_django_user):
|
||||||
response = self.post(groups, data=data, expect=400)
|
response = self.post(groups, data=data, expect=400)
|
||||||
|
|
||||||
|
|
||||||
#################################################
|
#################################################
|
||||||
# HOSTS->inventories POST via subcollection
|
# HOSTS->inventories POST via subcollection
|
||||||
|
|
||||||
@@ -687,6 +669,25 @@ class InventoryTest(BaseTest):
|
|||||||
self.assertFalse(gx3 in gx2.children.all())
|
self.assertFalse(gx3 in gx2.children.all())
|
||||||
self.assertTrue(gx4 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
|
# FIXME: TAGS
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user