From 849a97f1619c21c70ace47cba7a537063b77f3f5 Mon Sep 17 00:00:00 2001 From: Ross McFarland Date: Sat, 31 Mar 2018 13:22:28 -0700 Subject: [PATCH] Add healthcheck protocol validation, HTTP or HTTPS --- octodns/record.py | 10 ++++++++-- tests/test_octodns_record.py | 6 +++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/octodns/record.py b/octodns/record.py index 795ad71..201488c 100644 --- a/octodns/record.py +++ b/octodns/record.py @@ -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 diff --git a/tests/test_octodns_record.py b/tests/test_octodns_record.py index e23808b..494a286 100644 --- a/tests/test_octodns_record.py +++ b/tests/test_octodns_record.py @@ -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):