Browse Source

Add healthcheck protocol validation, HTTP or HTTPS

pull/67/head
Ross McFarland 8 years ago
parent
commit
849a97f161
No known key found for this signature in database GPG Key ID: 61C10C4FC8FE4A89
2 changed files with 11 additions and 5 deletions
  1. +8
    -2
      octodns/record.py
  2. +3
    -3
      tests/test_octodns_record.py

+ 8
- 2
octodns/record.py View File

@ -115,6 +115,12 @@ class Record(object):
reasons.append('invalid ttl')
except KeyError:
reasons.append('missing ttl')
try:
if data['octodns']['healthcheck']['protocol'] \
not in ('HTTP', 'HTTPS'):
reasons.append('invalid healthcheck protocol')
except KeyError:
pass
return reasons
def __init__(self, zone, name, data, source=None):
@ -172,12 +178,12 @@ class Record(object):
try:
return self._octodns['healthcheck']['protocol']
except KeyError:
return 'https'
return 'HTTPS'
@property
def healthcheck_port(self):
try:
return self._octodns['healthcheck']['port']
return int(self._octodns['healthcheck']['port'])
except KeyError:
return 443


+ 3
- 3
tests/test_octodns_record.py View File

@ -755,14 +755,14 @@ class TestRecord(TestCase):
'healthcheck': {
'path': '/_ready',
'host': 'bleep.bloop',
'protocol': 'http',
'protocol': 'HTTP',
'port': 8080,
}
}
})
self.assertEquals('/_ready', new.healthcheck_path)
self.assertEquals('bleep.bloop', new.healthcheck_host)
self.assertEquals('http', new.healthcheck_protocol)
self.assertEquals('HTTP', new.healthcheck_protocol)
self.assertEquals(8080, new.healthcheck_port)
new = Record.new(self.zone, 'a', {
@ -772,7 +772,7 @@ class TestRecord(TestCase):
})
self.assertEquals('/_dns', new.healthcheck_path)
self.assertEquals('a.unit.tests', new.healthcheck_host)
self.assertEquals('https', new.healthcheck_protocol)
self.assertEquals('HTTPS', new.healthcheck_protocol)
self.assertEquals(443, new.healthcheck_port)
def test_inored(self):


Loading…
Cancel
Save