diff --git a/octodns/record/__init__.py b/octodns/record/__init__.py index 77663a5..a8dd834 100644 --- a/octodns/record/__init__.py +++ b/octodns/record/__init__.py @@ -749,8 +749,13 @@ class _IpList(object): @classmethod def process(cls, values): - # Translating None into '' so that the list will be sortable in python3 - return [v if v is not None else '' for v in values] + # Translating None into '' so that the list will be sortable in + # python3, get everything to str first + values = [text_type(v) if v is not None else '' for v in values] + # Now round trip all non-'' through the address type and back to a str + # to normalize the address representation. + return [text_type(cls._address_type(v)) if v != '' else '' + for v in values] class Ipv4List(_IpList): diff --git a/tests/test_octodns_record.py b/tests/test_octodns_record.py index 886dbfb..c848853 100644 --- a/tests/test_octodns_record.py +++ b/tests/test_octodns_record.py @@ -259,11 +259,21 @@ class TestRecord(TestCase): self.assertEquals(b_data, b.data) def test_aaaa(self): - a_values = ['2001:0db8:3c4d:0015:0000:0000:1a2f:1a2b', - '2001:0db8:3c4d:0015:0000:0000:1a2f:1a3b'] - b_value = '2001:0db8:3c4d:0015:0000:0000:1a2f:1a4b' + a_values = ['2001:db8:3c4d:15::1a2f:1a2b', + '2001:db8:3c4d:15::1a2f:1a3b'] + b_value = '2001:db8:3c4d:15::1a2f:1a4b' self.assertMultipleValues(AaaaRecord, a_values, b_value) + # Specifically validate that we normalize IPv6 addresses + values = ['2001:db8:3c4d:15:0000:0000:1a2f:1a2b', + '2001:0db8:3c4d:0015::1a2f:1a3b'] + data = { + 'ttl': 30, + 'values': values, + } + record = AaaaRecord(self.zone, 'aaaa', data) + self.assertEquals(a_values, record.values) + def assertSingleValue(self, _type, a_value, b_value): a_data = {'ttl': 30, 'value': a_value} a = _type(self.zone, 'a', a_data)