1
0
mirror of https://github.com/github/octodns.git synced 2024-05-11 05:55:00 +00:00

Allow the option to not pass Host header in healthchecks

This commit is contained in:
Sham
2021-05-24 19:01:17 -07:00
parent ae37d17250
commit eb14873abb
4 changed files with 38 additions and 2 deletions

View File

@@ -929,7 +929,9 @@ class Ns1Provider(BaseProvider):
if record.healthcheck_protocol != 'TCP':
# IF it's HTTP we need to send the request string
path = record.healthcheck_path
host = record.healthcheck_host
# if host header is explicitly set to null in the yaml,
# just pass the domain (value) as the host header
host = record.healthcheck_host or value
request = r'GET {path} HTTP/1.0\r\nHost: {host}\r\n' \
r'User-agent: NS1\r\n\r\n'.format(path=path, host=host)
ret['config']['send'] = request

View File

@@ -1131,7 +1131,7 @@ class Route53Provider(BaseProvider):
'Type': healthcheck_protocol,
}
if healthcheck_protocol != 'TCP':
config['FullyQualifiedDomainName'] = healthcheck_host
config['FullyQualifiedDomainName'] = healthcheck_host or value
config['ResourcePath'] = healthcheck_path
if value:
config['IPAddress'] = value

View File

@@ -757,6 +757,10 @@ class TestNs1ProviderDynamic(TestCase):
self.assertFalse(monitor['config']['ssl'])
self.assertEquals('host:unit.tests type:A', monitor['notes'])
record._octodns['healthcheck']['host'] = None
monitor = provider._monitor_gen(record, value)
self.assertTrue(r'\nHost: 3.4.5.6\r' in monitor['config']['send'])
record._octodns['healthcheck']['protocol'] = 'HTTPS'
monitor = provider._monitor_gen(record, value)
self.assertTrue(monitor['config']['ssl'])

View File

@@ -1166,6 +1166,31 @@ class TestRoute53Provider(TestCase):
})
stubber.add_response('change_tags_for_resource', {})
health_check_config = {
'EnableSNI': False,
'FailureThreshold': 6,
'FullyQualifiedDomainName': '4.2.3.4',
'IPAddress': '4.2.3.4',
'MeasureLatency': True,
'Port': 8080,
'RequestInterval': 10,
'ResourcePath': '/_status',
'Type': 'HTTP'
}
stubber.add_response('create_health_check', {
'HealthCheck': {
'Id': '43',
'CallerReference': self.caller_ref,
'HealthCheckConfig': health_check_config,
'HealthCheckVersion': 1,
},
'Location': 'http://url',
}, {
'CallerReference': ANY,
'HealthCheckConfig': health_check_config,
})
stubber.add_response('change_tags_for_resource', {})
record = Record.new(self.expected, '', {
'ttl': 61,
'type': 'A',
@@ -1191,6 +1216,11 @@ class TestRoute53Provider(TestCase):
# when allowed to create we do
id = provider.get_health_check_id(record, value, True)
self.assertEquals('42', id)
# when allowed to create and when host is None
record._octodns['healthcheck']['host'] = None
id = provider.get_health_check_id(record, value, True)
self.assertEquals('43', id)
stubber.assert_no_pending_responses()
# A CNAME style healthcheck, without a value