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

Handle and test for old-style NS1 catchall naming pattern

This commit is contained in:
Ross McFarland
2020-06-23 14:54:40 -07:00
parent 2938c7bf6a
commit 0830b9c114
2 changed files with 14 additions and 1 deletions

View File

@@ -455,6 +455,9 @@ class Ns1Provider(BaseProvider):
return data
def _parse_dynamic_pool_name(self, pool_name):
if pool_name.startswith('catchall__'):
# Special case for the old-style catchall prefix
return pool_name[10:]
try:
pool_name, _ = pool_name.rsplit('__', 1)
except ValueError:

View File

@@ -1305,7 +1305,7 @@ class TestNs1ProviderDynamic(TestCase):
# Test out a small, but realistic setup that covers all the options
# We have country and region in the test config
filters = provider._get_updated_filter_chain(True, True)
catchall_pool_name = '{}__catchall'.format('iad')
catchall_pool_name = 'iad__catchall'
ns1_record = {
'answers': [{
'answer': ['3.4.5.6'],
@@ -1444,6 +1444,16 @@ class TestNs1ProviderDynamic(TestCase):
data2 = provider._data_for_A('A', ns1_record)
self.assertEquals(data, data2)
# Same answer if we have an old-style catchall name
old_style_catchall_pool_name = 'catchall__iad'
ns1_record['answers'][-2]['region'] = old_style_catchall_pool_name
ns1_record['answers'][-1]['region'] = old_style_catchall_pool_name
ns1_record['regions'][old_style_catchall_pool_name] = \
ns1_record['regions'][catchall_pool_name]
del ns1_record['regions'][catchall_pool_name]
data3 = provider._data_for_dynamic_A('A', ns1_record)
self.assertEquals(data, data2)
# Oceania test cases
# 1. Full list of countries should return 'OC' in geos
oc_countries = Ns1Provider._CONTINENT_TO_LIST_OF_COUNTRIES['OC']