Merge branch 'master' into ns1-cache

This commit is contained in:
Ross McFarland
2021-08-23 13:43:16 -07:00
committed by GitHub
5 changed files with 25 additions and 18 deletions
-6
View File
@@ -8,7 +8,6 @@ from __future__ import absolute_import, division, print_function, \
from collections import defaultdict
from requests import Session
from base64 import b64encode
from ipaddress import ip_address
from six import string_types
import hashlib
import hmac
@@ -138,11 +137,6 @@ class ConstellixClient(object):
v['value'] = self._absolutize_value(v['value'],
zone_name)
# compress IPv6 addresses
if record['type'] == 'AAAA':
for i, v in enumerate(value):
value[i] = str(ip_address(v))
return resp
def record_create(self, zone_name, record_type, params):
+5 -4
View File
@@ -1090,10 +1090,11 @@ class Route53Provider(BaseProvider):
health_check, value=None):
config = health_check['HealthCheckConfig']
# So interestingly Route53 normalizes IPAddress which will cause us to
# fail to find see things as equivalent. To work around this we'll
# ip_address's returned object for equivalence
# E.g 2001:4860:4860::8842 -> 2001:4860:4860:0:0:0:0:8842
# So interestingly Route53 normalizes IPv6 addresses to a funky, but
# valid, form which will cause us to fail to find see things as
# equivalent. To work around this we'll ip_address's returned objects
# for equivalence.
# E.g 2001:4860:4860:0:0:0:0:8842 -> 2001:4860:4860::8842
if value:
value = ip_address(text_type(value))
config_ip_address = ip_address(text_type(config['IPAddress']))
-3
View File
@@ -1,5 +1,4 @@
from collections import defaultdict
from ipaddress import ip_address
from logging import getLogger
from requests import Session
@@ -196,8 +195,6 @@ class UltraProvider(BaseProvider):
}
def _data_for_AAAA(self, _type, records):
for i, v in enumerate(records['rdata']):
records['rdata'][i] = str(ip_address(v))
return {
'ttl': records['ttl'],
'type': _type,
+7 -2
View File
@@ -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):
+13 -3
View File
@@ -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)