mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
Merge remote-tracking branch 'origin/master' into extract-cloudflare
This commit is contained in:
@@ -7,7 +7,11 @@
|
||||
https://github.com/octodns/octodns/pull/822 for more information. Providers
|
||||
that have been extracted in this release include:
|
||||
* [CloudflareProvider](https://github.com/octodns/octodns-cloudflare/)
|
||||
* [ConstellixProvider](https://github.com/octodns/octodns-constellix/)
|
||||
* [DigitalOceanProvider](https://github.com/octodns/octodns-digitalocean/)
|
||||
* [DnsimpleProvider](https://github.com/octodns/octodns-dnsimple/)
|
||||
* [DnsMadeEasyProvider](https://github.com/octodns/octodns-dnsmadeeasy/)
|
||||
* [DynProvider](https://github.com/octodns/octodns-dynprovider/)
|
||||
* [Ns1Provider](https://github.com/octodns/octodns-ns1/)
|
||||
* [PowerDnsProvider](https://github.com/octodns/octodns-powerdns/)
|
||||
* [Route53Provider](https://github.com/octodns/octodns-route53/) also
|
||||
|
||||
@@ -195,11 +195,11 @@ The table below lists the providers octoDNS supports. We're currently in the pro
|
||||
| [AzureProvider](/octodns/provider/azuredns.py) | | azure-identity, azure-mgmt-dns, azure-mgmt-trafficmanager | A, AAAA, CAA, CNAME, MX, NS, PTR, SRV, TXT | Alpha (A, AAAA, CNAME) | |
|
||||
| [Akamai](/octodns/provider/edgedns.py) | | edgegrid-python | A, AAAA, CNAME, MX, NAPTR, NS, PTR, SPF, SRV, SSHFP, TXT | No | |
|
||||
| [CloudflareProvider](https://github.com/octodns/octodns-cloudflare/) | [octodns_cloudflare](https://github.com/octodns/octodns-cloudflare/) | | | | |
|
||||
| [ConstellixProvider](/octodns/provider/constellix.py) | | | A, AAAA, ALIAS (ANAME), CAA, CNAME, MX, NS, PTR, SPF, SRV, TXT | Yes | CAA tags restricted |
|
||||
| [DigitalOceanProvider](/octodns/provider/digitalocean.py) | | | A, AAAA, CAA, CNAME, MX, NS, TXT, SRV | No | CAA tags restricted |
|
||||
| [DnsMadeEasyProvider](/octodns/provider/dnsmadeeasy.py) | | | A, AAAA, ALIAS (ANAME), CAA, CNAME, MX, NS, PTR, SPF, SRV, TXT | No | CAA tags restricted |
|
||||
| [ConstellixProvider](https://github.com/octodns/octodns-constellix/) | [octodns_constellix](https://github.com/octodns/octodns-constellix/) | | | | |
|
||||
| [DigitalOceanProvider](https://github.com/octodns/octodns-digitalocean/) | [octodns_digitalocean](https://github.com/octodns/octodns-digitalocean/) | | | | |
|
||||
| [DnsMadeEasyProvider](https://github.com/octodns/octodns-dnsmadeeasy/) | [octodns_dnsmadeeasy](https://github.com/octodns/octodns-dnsmadeeasy/) | | | | |
|
||||
| [DnsimpleProvider](https://github.com/octodns/octodns-dnsimple/) | [octodns_dnsimple](https://github.com/octodns/octodns-dnsimple/) | | | | |
|
||||
| [DynProvider](/octodns/provider/dyn.py) | | dyn | All | Both | |
|
||||
| [DynProvider](https://github.com/octodns/octodns-dyn/) (deprecated) | [octodns_dyn](https://github.com/octodns/octodns-dyn/) | | | | |
|
||||
| [EasyDNSProvider](/octodns/provider/easydns.py) | | | A, AAAA, CAA, CNAME, MX, NAPTR, NS, SRV, TXT | No | |
|
||||
| [EtcHostsProvider](/octodns/provider/etc_hosts.py) | | | A, AAAA, ALIAS, CNAME | No | |
|
||||
| [EnvVarSource](/octodns/source/envvar.py) | | | TXT | No | read-only environment variable injection |
|
||||
|
||||
+16
-1110
File diff suppressed because it is too large
Load Diff
@@ -5,345 +5,18 @@
|
||||
from __future__ import absolute_import, division, print_function, \
|
||||
unicode_literals
|
||||
|
||||
from collections import defaultdict
|
||||
from requests import Session
|
||||
import logging
|
||||
from logging import getLogger
|
||||
|
||||
from ..record import Record
|
||||
from . import ProviderException
|
||||
from .base import BaseProvider
|
||||
|
||||
|
||||
class DigitalOceanClientException(ProviderException):
|
||||
pass
|
||||
|
||||
|
||||
class DigitalOceanClientNotFound(DigitalOceanClientException):
|
||||
|
||||
def __init__(self):
|
||||
super(DigitalOceanClientNotFound, self).__init__('Not Found')
|
||||
|
||||
|
||||
class DigitalOceanClientUnauthorized(DigitalOceanClientException):
|
||||
|
||||
def __init__(self):
|
||||
super(DigitalOceanClientUnauthorized, self).__init__('Unauthorized')
|
||||
|
||||
|
||||
class DigitalOceanClient(object):
|
||||
BASE = 'https://api.digitalocean.com/v2'
|
||||
|
||||
def __init__(self, token):
|
||||
sess = Session()
|
||||
sess.headers.update({'Authorization': f'Bearer {token}'})
|
||||
self._sess = sess
|
||||
|
||||
def _request(self, method, path, params=None, data=None):
|
||||
url = f'{self.BASE}{path}'
|
||||
resp = self._sess.request(method, url, params=params, json=data)
|
||||
if resp.status_code == 401:
|
||||
raise DigitalOceanClientUnauthorized()
|
||||
if resp.status_code == 404:
|
||||
raise DigitalOceanClientNotFound()
|
||||
resp.raise_for_status()
|
||||
return resp
|
||||
|
||||
def domain(self, name):
|
||||
path = f'/domains/{name}'
|
||||
return self._request('GET', path).json()
|
||||
|
||||
def domain_create(self, name):
|
||||
# Digitalocean requires an IP on zone creation
|
||||
self._request('POST', '/domains', data={'name': name,
|
||||
'ip_address': '192.0.2.1'})
|
||||
|
||||
# After the zone is created, immediately delete the record
|
||||
records = self.records(name)
|
||||
for record in records:
|
||||
if record['name'] == '' and record['type'] == 'A':
|
||||
self.record_delete(name, record['id'])
|
||||
|
||||
def records(self, zone_name):
|
||||
path = f'/domains/{zone_name}/records'
|
||||
ret = []
|
||||
|
||||
page = 1
|
||||
while True:
|
||||
data = self._request('GET', path, {'page': page}).json()
|
||||
|
||||
ret += data['domain_records']
|
||||
links = data['links']
|
||||
|
||||
# https://developers.digitalocean.com/documentation/v2/#links
|
||||
# pages exists if there is more than 1 page
|
||||
# last doesn't exist if you're on the last page
|
||||
try:
|
||||
links['pages']['last']
|
||||
page += 1
|
||||
except KeyError:
|
||||
break
|
||||
|
||||
for record in ret:
|
||||
# change any apex record to empty string
|
||||
if record['name'] == '@':
|
||||
record['name'] = ''
|
||||
|
||||
# change any apex value to zone name
|
||||
if record['data'] == '@':
|
||||
record['data'] = zone_name
|
||||
|
||||
return ret
|
||||
|
||||
def record_create(self, zone_name, params):
|
||||
path = f'/domains/{zone_name}/records'
|
||||
# change empty name string to @, DO uses @ for apex record names
|
||||
if params['name'] == '':
|
||||
params['name'] = '@'
|
||||
|
||||
self._request('POST', path, data=params)
|
||||
|
||||
def record_delete(self, zone_name, record_id):
|
||||
path = f'/domains/{zone_name}/records/{record_id}'
|
||||
self._request('DELETE', path)
|
||||
|
||||
|
||||
class DigitalOceanProvider(BaseProvider):
|
||||
'''
|
||||
DigitalOcean DNS provider using API v2
|
||||
|
||||
digitalocean:
|
||||
class: octodns.provider.digitalocean.DigitalOceanProvider
|
||||
# Your DigitalOcean API token (required)
|
||||
token: foo
|
||||
'''
|
||||
SUPPORTS_GEO = False
|
||||
SUPPORTS_DYNAMIC = False
|
||||
SUPPORTS = set(('A', 'AAAA', 'CAA', 'CNAME', 'MX', 'NS', 'TXT', 'SRV'))
|
||||
|
||||
def __init__(self, id, token, *args, **kwargs):
|
||||
self.log = logging.getLogger(f'DigitalOceanProvider[{id}]')
|
||||
self.log.debug('__init__: id=%s, token=***', id)
|
||||
super(DigitalOceanProvider, self).__init__(id, *args, **kwargs)
|
||||
self._client = DigitalOceanClient(token)
|
||||
|
||||
self._zone_records = {}
|
||||
|
||||
def _data_for_multiple(self, _type, records):
|
||||
return {
|
||||
'ttl': records[0]['ttl'],
|
||||
'type': _type,
|
||||
'values': [r['data'] for r in records]
|
||||
}
|
||||
|
||||
_data_for_A = _data_for_multiple
|
||||
_data_for_AAAA = _data_for_multiple
|
||||
|
||||
def _data_for_CAA(self, _type, records):
|
||||
values = []
|
||||
for record in records:
|
||||
values.append({
|
||||
'flags': record['flags'],
|
||||
'tag': record['tag'],
|
||||
'value': record['data'],
|
||||
})
|
||||
return {
|
||||
'ttl': records[0]['ttl'],
|
||||
'type': _type,
|
||||
'values': values
|
||||
}
|
||||
|
||||
def _data_for_CNAME(self, _type, records):
|
||||
record = records[0]
|
||||
return {
|
||||
'ttl': record['ttl'],
|
||||
'type': _type,
|
||||
'value': f'{record["data"]}.'
|
||||
}
|
||||
|
||||
def _data_for_MX(self, _type, records):
|
||||
values = []
|
||||
for record in records:
|
||||
values.append({
|
||||
'preference': record['priority'],
|
||||
'exchange': f'{record["data"]}.'
|
||||
})
|
||||
return {
|
||||
'ttl': records[0]['ttl'],
|
||||
'type': _type,
|
||||
'values': values
|
||||
}
|
||||
|
||||
def _data_for_NS(self, _type, records):
|
||||
values = []
|
||||
for record in records:
|
||||
values.append(f'{record["data"]}.')
|
||||
return {
|
||||
'ttl': records[0]['ttl'],
|
||||
'type': _type,
|
||||
'values': values,
|
||||
}
|
||||
|
||||
def _data_for_SRV(self, _type, records):
|
||||
values = []
|
||||
for record in records:
|
||||
target = f'{record["data"]}.' if record['data'] != "." else "."
|
||||
values.append({
|
||||
'port': record['port'],
|
||||
'priority': record['priority'],
|
||||
'target': target,
|
||||
'weight': record['weight']
|
||||
})
|
||||
return {
|
||||
'type': _type,
|
||||
'ttl': records[0]['ttl'],
|
||||
'values': values
|
||||
}
|
||||
|
||||
def _data_for_TXT(self, _type, records):
|
||||
values = [value['data'].replace(';', '\\;') for value in records]
|
||||
return {
|
||||
'ttl': records[0]['ttl'],
|
||||
'type': _type,
|
||||
'values': values
|
||||
}
|
||||
|
||||
def zone_records(self, zone):
|
||||
if zone.name not in self._zone_records:
|
||||
try:
|
||||
self._zone_records[zone.name] = \
|
||||
self._client.records(zone.name[:-1])
|
||||
except DigitalOceanClientNotFound:
|
||||
return []
|
||||
|
||||
return self._zone_records[zone.name]
|
||||
|
||||
def populate(self, zone, target=False, lenient=False):
|
||||
self.log.debug('populate: name=%s, target=%s, lenient=%s', zone.name,
|
||||
target, lenient)
|
||||
|
||||
values = defaultdict(lambda: defaultdict(list))
|
||||
for record in self.zone_records(zone):
|
||||
_type = record['type']
|
||||
if _type not in self.SUPPORTS:
|
||||
self.log.warning('populate: skipping unsupported %s record',
|
||||
_type)
|
||||
continue
|
||||
values[record['name']][record['type']].append(record)
|
||||
|
||||
before = len(zone.records)
|
||||
for name, types in values.items():
|
||||
for _type, records in types.items():
|
||||
data_for = getattr(self, f'_data_for_{_type}')
|
||||
record = Record.new(zone, name, data_for(_type, records),
|
||||
source=self, lenient=lenient)
|
||||
zone.add_record(record, lenient=lenient)
|
||||
|
||||
exists = zone.name in self._zone_records
|
||||
self.log.info('populate: found %s records, exists=%s',
|
||||
len(zone.records) - before, exists)
|
||||
return exists
|
||||
|
||||
def _params_for_multiple(self, record):
|
||||
for value in record.values:
|
||||
yield {
|
||||
'data': value,
|
||||
'name': record.name,
|
||||
'ttl': record.ttl,
|
||||
'type': record._type
|
||||
}
|
||||
|
||||
_params_for_A = _params_for_multiple
|
||||
_params_for_AAAA = _params_for_multiple
|
||||
_params_for_NS = _params_for_multiple
|
||||
|
||||
def _params_for_CAA(self, record):
|
||||
for value in record.values:
|
||||
yield {
|
||||
'data': value.value,
|
||||
'flags': value.flags,
|
||||
'name': record.name,
|
||||
'tag': value.tag,
|
||||
'ttl': record.ttl,
|
||||
'type': record._type
|
||||
}
|
||||
|
||||
def _params_for_single(self, record):
|
||||
yield {
|
||||
'data': record.value,
|
||||
'name': record.name,
|
||||
'ttl': record.ttl,
|
||||
'type': record._type
|
||||
}
|
||||
|
||||
_params_for_CNAME = _params_for_single
|
||||
|
||||
def _params_for_MX(self, record):
|
||||
for value in record.values:
|
||||
yield {
|
||||
'data': value.exchange,
|
||||
'name': record.name,
|
||||
'priority': value.preference,
|
||||
'ttl': record.ttl,
|
||||
'type': record._type
|
||||
}
|
||||
|
||||
def _params_for_SRV(self, record):
|
||||
for value in record.values:
|
||||
yield {
|
||||
'data': value.target,
|
||||
'name': record.name,
|
||||
'port': value.port,
|
||||
'priority': value.priority,
|
||||
'ttl': record.ttl,
|
||||
'type': record._type,
|
||||
'weight': value.weight
|
||||
}
|
||||
|
||||
def _params_for_TXT(self, record):
|
||||
# DigitalOcean doesn't want things escaped in values so we
|
||||
# have to strip them here and add them when going the other way
|
||||
for value in record.values:
|
||||
yield {
|
||||
'data': value.replace('\\;', ';'),
|
||||
'name': record.name,
|
||||
'ttl': record.ttl,
|
||||
'type': record._type
|
||||
}
|
||||
|
||||
def _apply_Create(self, change):
|
||||
new = change.new
|
||||
params_for = getattr(self, f'_params_for_{new._type}')
|
||||
for params in params_for(new):
|
||||
self._client.record_create(new.zone.name[:-1], params)
|
||||
|
||||
def _apply_Update(self, change):
|
||||
self._apply_Delete(change)
|
||||
self._apply_Create(change)
|
||||
|
||||
def _apply_Delete(self, change):
|
||||
existing = change.existing
|
||||
zone = existing.zone
|
||||
for record in self.zone_records(zone):
|
||||
if existing.name == record['name'] and \
|
||||
existing._type == record['type']:
|
||||
self._client.record_delete(zone.name[:-1], record['id'])
|
||||
|
||||
def _apply(self, plan):
|
||||
desired = plan.desired
|
||||
changes = plan.changes
|
||||
self.log.debug('_apply: zone=%s, len(changes)=%d', desired.name,
|
||||
len(changes))
|
||||
|
||||
domain_name = desired.name[:-1]
|
||||
try:
|
||||
self._client.domain(domain_name)
|
||||
except DigitalOceanClientNotFound:
|
||||
self.log.debug('_apply: no matching zone, creating domain')
|
||||
self._client.domain_create(domain_name)
|
||||
|
||||
for change in changes:
|
||||
class_name = change.__class__.__name__
|
||||
getattr(self, f'_apply_{class_name}')(change)
|
||||
|
||||
# Clear out the cache if any
|
||||
self._zone_records.pop(desired.name, None)
|
||||
logger = getLogger('DigitalOcean')
|
||||
try:
|
||||
logger.warn('octodns_digitalocean shimmed. Update your provider class to '
|
||||
'octodns_digitalocean.DigitalOceanProvider. '
|
||||
'Shim will be removed in 1.0')
|
||||
from octodns_digitalocean import DigitalOceanProvider
|
||||
DigitalOceanProvider # pragma: no cover
|
||||
except ModuleNotFoundError:
|
||||
logger.exception('DigitalOceanProvider has been moved into a seperate '
|
||||
'module, octodns_digitalocean is now required. Provider '
|
||||
'class should be updated to '
|
||||
'octodns_digitalocean.DigitalOceanProvider')
|
||||
raise
|
||||
|
||||
+15
-414
@@ -5,417 +5,18 @@
|
||||
from __future__ import absolute_import, division, print_function, \
|
||||
unicode_literals
|
||||
|
||||
from collections import defaultdict
|
||||
from requests import Session
|
||||
from time import strftime, gmtime, sleep
|
||||
import hashlib
|
||||
import hmac
|
||||
import logging
|
||||
|
||||
from ..record import Record
|
||||
from . import ProviderException
|
||||
from .base import BaseProvider
|
||||
|
||||
|
||||
class DnsMadeEasyClientException(ProviderException):
|
||||
pass
|
||||
|
||||
|
||||
class DnsMadeEasyClientBadRequest(DnsMadeEasyClientException):
|
||||
|
||||
def __init__(self, resp):
|
||||
errors = '\n - '.join(resp.json()['error'])
|
||||
super(DnsMadeEasyClientBadRequest, self).__init__(f'\n - {errors}')
|
||||
|
||||
|
||||
class DnsMadeEasyClientUnauthorized(DnsMadeEasyClientException):
|
||||
|
||||
def __init__(self):
|
||||
super(DnsMadeEasyClientUnauthorized, self).__init__('Unauthorized')
|
||||
|
||||
|
||||
class DnsMadeEasyClientNotFound(DnsMadeEasyClientException):
|
||||
|
||||
def __init__(self):
|
||||
super(DnsMadeEasyClientNotFound, self).__init__('Not Found')
|
||||
|
||||
|
||||
class DnsMadeEasyClient(object):
|
||||
PRODUCTION = 'https://api.dnsmadeeasy.com/V2.0/dns/managed'
|
||||
SANDBOX = 'https://api.sandbox.dnsmadeeasy.com/V2.0/dns/managed'
|
||||
|
||||
def __init__(self, api_key, secret_key, sandbox=False,
|
||||
ratelimit_delay=0.0):
|
||||
self.api_key = api_key
|
||||
self.secret_key = secret_key
|
||||
self._base = self.SANDBOX if sandbox else self.PRODUCTION
|
||||
self.ratelimit_delay = ratelimit_delay
|
||||
self._sess = Session()
|
||||
self._sess.headers.update({'x-dnsme-apiKey': self.api_key})
|
||||
self._domains = None
|
||||
|
||||
def _current_time(self):
|
||||
return strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime())
|
||||
|
||||
def _hmac_hash(self, now):
|
||||
return hmac.new(self.secret_key.encode(), now.encode(),
|
||||
hashlib.sha1).hexdigest()
|
||||
|
||||
def _request(self, method, path, params=None, data=None):
|
||||
now = self._current_time()
|
||||
hmac_hash = self._hmac_hash(now)
|
||||
|
||||
headers = {
|
||||
'x-dnsme-hmac': hmac_hash,
|
||||
'x-dnsme-requestDate': now
|
||||
}
|
||||
|
||||
url = f'{self._base}{path}'
|
||||
resp = self._sess.request(method, url, headers=headers,
|
||||
params=params, json=data)
|
||||
if resp.status_code == 400:
|
||||
raise DnsMadeEasyClientBadRequest(resp)
|
||||
if resp.status_code in [401, 403]:
|
||||
raise DnsMadeEasyClientUnauthorized()
|
||||
if resp.status_code == 404:
|
||||
raise DnsMadeEasyClientNotFound()
|
||||
resp.raise_for_status()
|
||||
sleep(self.ratelimit_delay)
|
||||
return resp
|
||||
|
||||
@property
|
||||
def domains(self):
|
||||
if self._domains is None:
|
||||
zones = []
|
||||
|
||||
# has pages in resp, do we need paging?
|
||||
resp = self._request('GET', '/').json()
|
||||
zones += resp['data']
|
||||
|
||||
self._domains = {f'{z["name"]}.': z['id'] for z in zones}
|
||||
|
||||
return self._domains
|
||||
|
||||
def domain(self, name):
|
||||
path = f'/id/{name}'
|
||||
return self._request('GET', path).json()
|
||||
|
||||
def domain_create(self, name):
|
||||
self._request('POST', '/', data={'name': name})
|
||||
|
||||
def records(self, zone_name):
|
||||
zone_id = self.domains.get(zone_name, False)
|
||||
path = f'/{zone_id}/records'
|
||||
ret = []
|
||||
|
||||
# has pages in resp, do we need paging?
|
||||
resp = self._request('GET', path).json()
|
||||
ret += resp['data']
|
||||
|
||||
for record in ret:
|
||||
# change ANAME records to ALIAS
|
||||
if record['type'] == 'ANAME':
|
||||
record['type'] = 'ALIAS'
|
||||
|
||||
# change relative values to absolute
|
||||
value = record['value']
|
||||
if record['type'] in ['ALIAS', 'CNAME', 'MX', 'NS', 'SRV']:
|
||||
if value == '':
|
||||
record['value'] = zone_name
|
||||
elif not value.endswith('.'):
|
||||
record['value'] = f'{value}.{zone_name}'
|
||||
|
||||
return ret
|
||||
|
||||
def record_create(self, zone_name, params):
|
||||
zone_id = self.domains.get(zone_name, False)
|
||||
path = f'/{zone_id}/records'
|
||||
|
||||
# change ALIAS records to ANAME
|
||||
if params['type'] == 'ALIAS':
|
||||
params['type'] = 'ANAME'
|
||||
|
||||
self._request('POST', path, data=params)
|
||||
|
||||
def record_delete(self, zone_name, record_id):
|
||||
zone_id = self.domains.get(zone_name, False)
|
||||
path = f'/{zone_id}/records/{record_id}'
|
||||
self._request('DELETE', path)
|
||||
|
||||
|
||||
class DnsMadeEasyProvider(BaseProvider):
|
||||
'''
|
||||
DNSMadeEasy DNS provider using v2.0 API
|
||||
|
||||
dnsmadeeasy:
|
||||
class: octodns.provider.dnsmadeeasy.DnsMadeEasyProvider
|
||||
# Your DnsMadeEasy api key (required)
|
||||
api_key: env/DNSMADEEASY_API_KEY
|
||||
# Your DnsMadeEasy secret key (required)
|
||||
secret_key: env/DNSMADEEASY_SECRET_KEY
|
||||
# Whether or not to use Sandbox environment
|
||||
# (optional, default is false)
|
||||
sandbox: true
|
||||
'''
|
||||
SUPPORTS_GEO = False
|
||||
SUPPORTS_DYNAMIC = False
|
||||
SUPPORTS = set(('A', 'AAAA', 'ALIAS', 'CAA', 'CNAME', 'MX',
|
||||
'NS', 'PTR', 'SPF', 'SRV', 'TXT'))
|
||||
|
||||
def __init__(self, id, api_key, secret_key, sandbox=False,
|
||||
ratelimit_delay=0.0, *args, **kwargs):
|
||||
self.log = logging.getLogger(f'DnsMadeEasyProvider[{id}]')
|
||||
self.log.debug('__init__: id=%s, api_key=***, secret_key=***, '
|
||||
'sandbox=%s', id, sandbox)
|
||||
super(DnsMadeEasyProvider, self).__init__(id, *args, **kwargs)
|
||||
self._client = DnsMadeEasyClient(api_key, secret_key, sandbox,
|
||||
ratelimit_delay)
|
||||
|
||||
self._zone_records = {}
|
||||
|
||||
def _data_for_multiple(self, _type, records):
|
||||
return {
|
||||
'ttl': records[0]['ttl'],
|
||||
'type': _type,
|
||||
'values': [r['value'] for r in records]
|
||||
}
|
||||
|
||||
_data_for_A = _data_for_multiple
|
||||
_data_for_AAAA = _data_for_multiple
|
||||
_data_for_NS = _data_for_multiple
|
||||
|
||||
def _data_for_CAA(self, _type, records):
|
||||
values = []
|
||||
for record in records:
|
||||
values.append({
|
||||
'flags': record['issuerCritical'],
|
||||
'tag': record['caaType'],
|
||||
'value': record['value'][1:-1]
|
||||
})
|
||||
return {
|
||||
'ttl': records[0]['ttl'],
|
||||
'type': _type,
|
||||
'values': values
|
||||
}
|
||||
|
||||
def _data_for_TXT(self, _type, records):
|
||||
values = [value['value'].replace(';', '\\;') for value in records]
|
||||
return {
|
||||
'ttl': records[0]['ttl'],
|
||||
'type': _type,
|
||||
'values': values
|
||||
}
|
||||
|
||||
_data_for_SPF = _data_for_TXT
|
||||
|
||||
def _data_for_MX(self, _type, records):
|
||||
values = []
|
||||
for record in records:
|
||||
values.append({
|
||||
'preference': record['mxLevel'],
|
||||
'exchange': record['value']
|
||||
})
|
||||
return {
|
||||
'ttl': records[0]['ttl'],
|
||||
'type': _type,
|
||||
'values': values
|
||||
}
|
||||
|
||||
def _data_for_single(self, _type, records):
|
||||
record = records[0]
|
||||
return {
|
||||
'ttl': record['ttl'],
|
||||
'type': _type,
|
||||
'value': record['value']
|
||||
}
|
||||
|
||||
_data_for_CNAME = _data_for_single
|
||||
_data_for_PTR = _data_for_single
|
||||
_data_for_ALIAS = _data_for_single
|
||||
|
||||
def _data_for_SRV(self, _type, records):
|
||||
values = []
|
||||
for record in records:
|
||||
values.append({
|
||||
'port': record['port'],
|
||||
'priority': record['priority'],
|
||||
'target': record['value'],
|
||||
'weight': record['weight']
|
||||
})
|
||||
return {
|
||||
'type': _type,
|
||||
'ttl': records[0]['ttl'],
|
||||
'values': values
|
||||
}
|
||||
|
||||
def zone_records(self, zone):
|
||||
if zone.name not in self._zone_records:
|
||||
try:
|
||||
self._zone_records[zone.name] = \
|
||||
self._client.records(zone.name)
|
||||
except DnsMadeEasyClientNotFound:
|
||||
return []
|
||||
|
||||
return self._zone_records[zone.name]
|
||||
|
||||
def populate(self, zone, target=False, lenient=False):
|
||||
self.log.debug('populate: name=%s, target=%s, lenient=%s', zone.name,
|
||||
target, lenient)
|
||||
|
||||
values = defaultdict(lambda: defaultdict(list))
|
||||
for record in self.zone_records(zone):
|
||||
_type = record['type']
|
||||
if _type not in self.SUPPORTS:
|
||||
self.log.warning('populate: skipping unsupported %s record',
|
||||
_type)
|
||||
continue
|
||||
values[record['name']][record['type']].append(record)
|
||||
|
||||
before = len(zone.records)
|
||||
for name, types in values.items():
|
||||
for _type, records in types.items():
|
||||
data_for = getattr(self, f'_data_for_{_type}')
|
||||
record = Record.new(zone, name, data_for(_type, records),
|
||||
source=self, lenient=lenient)
|
||||
zone.add_record(record, lenient=lenient)
|
||||
|
||||
exists = zone.name in self._zone_records
|
||||
self.log.info('populate: found %s records, exists=%s',
|
||||
len(zone.records) - before, exists)
|
||||
return exists
|
||||
|
||||
def supports(self, record):
|
||||
# DNS Made Easy does not support empty/NULL SRV records
|
||||
#
|
||||
# Attempting to sync such a record would generate the following error
|
||||
#
|
||||
# octodns.provider.dnsmadeeasy.DnsMadeEasyClientBadRequest:
|
||||
# - Record value may not be a standalone dot.
|
||||
#
|
||||
# Skip the record and continue
|
||||
if record._type == "SRV":
|
||||
if 'value' in record.data:
|
||||
targets = (record.data['value']['target'],)
|
||||
else:
|
||||
targets = [value['target'] for value in record.data['values']]
|
||||
|
||||
if "." in targets:
|
||||
self.log.warning(
|
||||
'supports: unsupported %s record with target (%s)',
|
||||
record._type, targets
|
||||
)
|
||||
return False
|
||||
|
||||
return super(DnsMadeEasyProvider, self).supports(record)
|
||||
|
||||
def _params_for_multiple(self, record):
|
||||
for value in record.values:
|
||||
yield {
|
||||
'value': value,
|
||||
'name': record.name,
|
||||
'ttl': record.ttl,
|
||||
'type': record._type
|
||||
}
|
||||
|
||||
_params_for_A = _params_for_multiple
|
||||
_params_for_AAAA = _params_for_multiple
|
||||
|
||||
# An A record with this name must exist in this domain for
|
||||
# this NS record to be valid. Need to handle checking if
|
||||
# there is an A record before creating NS
|
||||
_params_for_NS = _params_for_multiple
|
||||
|
||||
def _params_for_single(self, record):
|
||||
yield {
|
||||
'value': record.value,
|
||||
'name': record.name,
|
||||
'ttl': record.ttl,
|
||||
'type': record._type
|
||||
}
|
||||
|
||||
_params_for_CNAME = _params_for_single
|
||||
_params_for_PTR = _params_for_single
|
||||
_params_for_ALIAS = _params_for_single
|
||||
|
||||
def _params_for_MX(self, record):
|
||||
for value in record.values:
|
||||
yield {
|
||||
'value': value.exchange,
|
||||
'name': record.name,
|
||||
'mxLevel': value.preference,
|
||||
'ttl': record.ttl,
|
||||
'type': record._type
|
||||
}
|
||||
|
||||
def _params_for_SRV(self, record):
|
||||
for value in record.values:
|
||||
yield {
|
||||
'value': value.target,
|
||||
'name': record.name,
|
||||
'port': value.port,
|
||||
'priority': value.priority,
|
||||
'ttl': record.ttl,
|
||||
'type': record._type,
|
||||
'weight': value.weight
|
||||
}
|
||||
|
||||
def _params_for_TXT(self, record):
|
||||
# DNSMadeEasy does not want values escaped
|
||||
for value in record.chunked_values:
|
||||
yield {
|
||||
'value': value.replace('\\;', ';'),
|
||||
'name': record.name,
|
||||
'ttl': record.ttl,
|
||||
'type': record._type
|
||||
}
|
||||
|
||||
_params_for_SPF = _params_for_TXT
|
||||
|
||||
def _params_for_CAA(self, record):
|
||||
for value in record.values:
|
||||
yield {
|
||||
'value': value.value,
|
||||
'issuerCritical': value.flags,
|
||||
'name': record.name,
|
||||
'caaType': value.tag,
|
||||
'ttl': record.ttl,
|
||||
'type': record._type
|
||||
}
|
||||
|
||||
def _apply_Create(self, change):
|
||||
new = change.new
|
||||
params_for = getattr(self, f'_params_for_{new._type}')
|
||||
for params in params_for(new):
|
||||
self._client.record_create(new.zone.name, params)
|
||||
|
||||
def _apply_Update(self, change):
|
||||
self._apply_Delete(change)
|
||||
self._apply_Create(change)
|
||||
|
||||
def _apply_Delete(self, change):
|
||||
existing = change.existing
|
||||
zone = existing.zone
|
||||
for record in self.zone_records(zone):
|
||||
if existing.name == record['name'] and \
|
||||
existing._type == record['type']:
|
||||
self._client.record_delete(zone.name, record['id'])
|
||||
|
||||
def _apply(self, plan):
|
||||
desired = plan.desired
|
||||
changes = plan.changes
|
||||
self.log.debug('_apply: zone=%s, len(changes)=%d', desired.name,
|
||||
len(changes))
|
||||
|
||||
domain_name = desired.name[:-1]
|
||||
try:
|
||||
self._client.domain(domain_name)
|
||||
except DnsMadeEasyClientNotFound:
|
||||
self.log.debug('_apply: no matching zone, creating domain')
|
||||
self._client.domain_create(domain_name)
|
||||
|
||||
for change in changes:
|
||||
class_name = change.__class__.__name__
|
||||
getattr(self, f'_apply_{class_name}')(change)
|
||||
|
||||
# Clear out the cache if any
|
||||
self._zone_records.pop(desired.name, None)
|
||||
from logging import getLogger
|
||||
|
||||
logger = getLogger('DnsMadeEasy')
|
||||
try:
|
||||
logger.warn('octodns_dnsmadeeasy shimmed. Update your provider class to '
|
||||
'octodns_dnsmadeeasy.DnsMadeEasyProvider. '
|
||||
'Shim will be removed in 1.0')
|
||||
from octodns_dnsmadeeasy import DnsMadeEasyProvider
|
||||
DnsMadeEasyProvider # pragma: no cover
|
||||
except ModuleNotFoundError:
|
||||
logger.exception('DnsMadeEasyProvider has been moved into a seperate '
|
||||
'module, octodns_dnsmadeeasy is now required. Provider '
|
||||
'class should be updated to '
|
||||
'octodns_dnsmadeeasy.DnsMadeEasyProvider')
|
||||
raise
|
||||
|
||||
+12
-1394
File diff suppressed because it is too large
Load Diff
@@ -5,7 +5,6 @@ azure-mgmt-dns==8.0.0
|
||||
azure-mgmt-trafficmanager==0.51.0
|
||||
dnspython==1.16.0
|
||||
docutils==0.16
|
||||
dyn==1.8.1
|
||||
edgegrid-python==1.1.1
|
||||
fqdn==1.5.0
|
||||
google-cloud-core==1.4.1
|
||||
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
[{
|
||||
"id": 123123,
|
||||
"name": "unit.tests",
|
||||
"soa": {
|
||||
"primaryNameserver": "ns11.constellix.com.",
|
||||
"email": "dns.constellix.com.",
|
||||
"ttl": 86400,
|
||||
"serial": 2015010102,
|
||||
"refresh": 43200,
|
||||
"retry": 3600,
|
||||
"expire": 1209600,
|
||||
"negCache": 180
|
||||
},
|
||||
"createdTs": "2019-08-07T03:36:02Z",
|
||||
"modifiedTs": "2019-08-07T03:36:02Z",
|
||||
"typeId": 1,
|
||||
"domainTags": [],
|
||||
"folder": null,
|
||||
"hasGtdRegions": false,
|
||||
"hasGeoIP": false,
|
||||
"nameserverGroup": 1,
|
||||
"nameservers": ["ns11.constellix.com.", "ns21.constellix.com.", "ns31.constellix.com.", "ns41.constellix.net.", "ns51.constellix.net.", "ns61.constellix.net."],
|
||||
"note": "",
|
||||
"version": 0,
|
||||
"status": "ACTIVE",
|
||||
"tags": [],
|
||||
"contactIds": []
|
||||
}]
|
||||
-34
@@ -1,34 +0,0 @@
|
||||
[
|
||||
{
|
||||
"id": 6303,
|
||||
"name": "some.other",
|
||||
"filterRulesLimit": 100,
|
||||
"createdTs": "2021-08-19T14:47:47Z",
|
||||
"modifiedTs": "2021-08-19T14:47:47Z",
|
||||
"geoipContinents": ["AS", "OC"],
|
||||
"geoipCountries": ["ES", "SE", "UA"],
|
||||
"regions": [
|
||||
{
|
||||
"continentCode": "NA",
|
||||
"countryCode": "CA",
|
||||
"regionCode": "NL"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 5303,
|
||||
"name": "unit.tests.:www.dynamic:A:one",
|
||||
"filterRulesLimit": 100,
|
||||
"createdTs": "2021-08-19T14:47:47Z",
|
||||
"modifiedTs": "2021-08-19T14:47:47Z",
|
||||
"geoipContinents": ["AS", "OC"],
|
||||
"geoipCountries": ["ES", "SE", "UA"],
|
||||
"regions": [
|
||||
{
|
||||
"continentCode": "NA",
|
||||
"countryCode": "CA",
|
||||
"regionCode": "NL"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
Vendored
-62
@@ -1,62 +0,0 @@
|
||||
[
|
||||
{
|
||||
"id": 1808521,
|
||||
"name": "unit.tests.:www.dynamic:A:two",
|
||||
"type": "A",
|
||||
"numReturn": 1,
|
||||
"minAvailableFailover": 1,
|
||||
"createdTs": "2020-09-12T00:44:35Z",
|
||||
"modifiedTs": "2020-09-12T00:44:35Z",
|
||||
"appliedDomains": [
|
||||
{
|
||||
"id": 123123,
|
||||
"name": "unit.tests",
|
||||
"recordOption": "pools"
|
||||
}
|
||||
],
|
||||
"appliedTemplates": null,
|
||||
"unlinkedDomains": [],
|
||||
"unlinkedTemplates": null,
|
||||
"itoEnabled": false,
|
||||
"values": [
|
||||
{
|
||||
"value": "1.2.3.4",
|
||||
"weight": 1
|
||||
},
|
||||
{
|
||||
"value": "1.2.3.5",
|
||||
"weight": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 1808522,
|
||||
"name": "unit.tests.:www.dynamic:A:one",
|
||||
"type": "A",
|
||||
"numReturn": 1,
|
||||
"minAvailableFailover": 1,
|
||||
"createdTs": "2020-09-12T00:44:35Z",
|
||||
"modifiedTs": "2020-09-12T00:44:35Z",
|
||||
"appliedDomains": [
|
||||
{
|
||||
"id": 123123,
|
||||
"name": "unit.tests",
|
||||
"recordOption": "pools"
|
||||
}
|
||||
],
|
||||
"appliedTemplates": null,
|
||||
"unlinkedDomains": [],
|
||||
"unlinkedTemplates": null,
|
||||
"itoEnabled": false,
|
||||
"values": [
|
||||
{
|
||||
"value": "1.2.3.6",
|
||||
"weight": 1
|
||||
},
|
||||
{
|
||||
"value": "1.2.3.7",
|
||||
"weight": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
-696
@@ -1,696 +0,0 @@
|
||||
[{
|
||||
"id": 1808529,
|
||||
"type": "CAA",
|
||||
"recordType": "caa",
|
||||
"name": "",
|
||||
"recordOption": "roundRobin",
|
||||
"noAnswer": false,
|
||||
"note": "",
|
||||
"ttl": 3600,
|
||||
"gtdRegion": 1,
|
||||
"parentId": 123123,
|
||||
"parent": "domain",
|
||||
"source": "Domain",
|
||||
"modifiedTs": 1565149569216,
|
||||
"value": [{
|
||||
"flag": 0,
|
||||
"tag": "issue",
|
||||
"data": "ca.unit.tests",
|
||||
"caaProviderId": 1,
|
||||
"disableFlag": false
|
||||
}],
|
||||
"roundRobin": [{
|
||||
"flag": 0,
|
||||
"tag": "issue",
|
||||
"data": "ca.unit.tests",
|
||||
"caaProviderId": 1,
|
||||
"disableFlag": false
|
||||
}]
|
||||
}, {
|
||||
"id": 1808516,
|
||||
"type": "A",
|
||||
"recordType": "a",
|
||||
"name": "",
|
||||
"recordOption": "roundRobin",
|
||||
"noAnswer": false,
|
||||
"note": "",
|
||||
"ttl": 300,
|
||||
"gtdRegion": 1,
|
||||
"parentId": 123123,
|
||||
"parent": "domain",
|
||||
"source": "Domain",
|
||||
"modifiedTs": 1565149623640,
|
||||
"value": ["1.2.3.4", "1.2.3.5"],
|
||||
"roundRobin": [{
|
||||
"value": "1.2.3.4",
|
||||
"disableFlag": false
|
||||
}, {
|
||||
"value": "1.2.3.5",
|
||||
"disableFlag": false
|
||||
}],
|
||||
"geolocation": null,
|
||||
"recordFailover": {
|
||||
"disabled": false,
|
||||
"failoverType": 1,
|
||||
"failoverTypeStr": "Normal (always lowest level)",
|
||||
"values": []
|
||||
},
|
||||
"failover": {
|
||||
"disabled": false,
|
||||
"failoverType": 1,
|
||||
"failoverTypeStr": "Normal (always lowest level)",
|
||||
"values": []
|
||||
},
|
||||
"roundRobinFailover": [],
|
||||
"pools": [],
|
||||
"poolsDetail": []
|
||||
}, {
|
||||
"id": 1808527,
|
||||
"type": "SRV",
|
||||
"recordType": "srv",
|
||||
"name": "_srv._tcp",
|
||||
"recordOption": "roundRobin",
|
||||
"noAnswer": false,
|
||||
"note": "",
|
||||
"ttl": 600,
|
||||
"gtdRegion": 1,
|
||||
"parentId": 123123,
|
||||
"parent": "domain",
|
||||
"source": "Domain",
|
||||
"modifiedTs": 1565149714387,
|
||||
"value": [{
|
||||
"value": "foo-1.unit.tests.",
|
||||
"priority": 10,
|
||||
"weight": 20,
|
||||
"port": 30,
|
||||
"disableFlag": false
|
||||
}, {
|
||||
"value": "foo-2.unit.tests.",
|
||||
"priority": 12,
|
||||
"weight": 20,
|
||||
"port": 30,
|
||||
"disableFlag": false
|
||||
}],
|
||||
"roundRobin": [{
|
||||
"value": "foo-1.unit.tests.",
|
||||
"priority": 10,
|
||||
"weight": 20,
|
||||
"port": 30,
|
||||
"disableFlag": false
|
||||
}, {
|
||||
"value": "foo-2.unit.tests.",
|
||||
"priority": 12,
|
||||
"weight": 20,
|
||||
"port": 30,
|
||||
"disableFlag": false
|
||||
}]
|
||||
}, {
|
||||
"id": 1808527,
|
||||
"type": "SRV",
|
||||
"recordType": "srv",
|
||||
"name": "_imap._tcp",
|
||||
"recordOption": "roundRobin",
|
||||
"noAnswer": false,
|
||||
"note": "",
|
||||
"ttl": 600,
|
||||
"gtdRegion": 1,
|
||||
"parentId": 123123,
|
||||
"parent": "domain",
|
||||
"source": "Domain",
|
||||
"modifiedTs": 1565149714387,
|
||||
"value": [{
|
||||
"value": ".",
|
||||
"priority": 0,
|
||||
"weight": 0,
|
||||
"port": 0,
|
||||
"disableFlag": false
|
||||
}],
|
||||
"roundRobin": [{
|
||||
"value": ".",
|
||||
"priority": 0,
|
||||
"weight": 0,
|
||||
"port": 0,
|
||||
"disableFlag": false
|
||||
}]
|
||||
}, {
|
||||
"id": 1808527,
|
||||
"type": "SRV",
|
||||
"recordType": "srv",
|
||||
"name": "_pop3._tcp",
|
||||
"recordOption": "roundRobin",
|
||||
"noAnswer": false,
|
||||
"note": "",
|
||||
"ttl": 600,
|
||||
"gtdRegion": 1,
|
||||
"parentId": 123123,
|
||||
"parent": "domain",
|
||||
"source": "Domain",
|
||||
"modifiedTs": 1565149714387,
|
||||
"value": [{
|
||||
"value": ".",
|
||||
"priority": 0,
|
||||
"weight": 0,
|
||||
"port": 0,
|
||||
"disableFlag": false
|
||||
}],
|
||||
"roundRobin": [{
|
||||
"value": ".",
|
||||
"priority": 0,
|
||||
"weight": 0,
|
||||
"port": 0,
|
||||
"disableFlag": false
|
||||
}]
|
||||
}, {
|
||||
"id": 1808515,
|
||||
"type": "AAAA",
|
||||
"recordType": "aaaa",
|
||||
"name": "aaaa",
|
||||
"recordOption": "roundRobin",
|
||||
"noAnswer": false,
|
||||
"note": "",
|
||||
"ttl": 600,
|
||||
"gtdRegion": 1,
|
||||
"parentId": 123123,
|
||||
"parent": "domain",
|
||||
"source": "Domain",
|
||||
"modifiedTs": 1565149739464,
|
||||
"value": ["2601:644:500:e210:62f8:1dff:feb8:947a"],
|
||||
"roundRobin": [{
|
||||
"value": "2601:644:500:e210:62f8:1dff:feb8:947a",
|
||||
"disableFlag": false
|
||||
}],
|
||||
"geolocation": null,
|
||||
"recordFailover": {
|
||||
"disabled": false,
|
||||
"failoverType": 1,
|
||||
"failoverTypeStr": "Normal (always lowest level)",
|
||||
"values": []
|
||||
},
|
||||
"failover": {
|
||||
"disabled": false,
|
||||
"failoverType": 1,
|
||||
"failoverTypeStr": "Normal (always lowest level)",
|
||||
"values": []
|
||||
},
|
||||
"pools": [],
|
||||
"poolsDetail": [],
|
||||
"roundRobinFailover": []
|
||||
}, {
|
||||
"id": 1808530,
|
||||
"type": "ANAME",
|
||||
"recordType": "aname",
|
||||
"name": "",
|
||||
"recordOption": "roundRobin",
|
||||
"noAnswer": false,
|
||||
"note": "",
|
||||
"ttl": 1800,
|
||||
"gtdRegion": 1,
|
||||
"parentId": 123123,
|
||||
"parent": "domain",
|
||||
"source": "Domain",
|
||||
"modifiedTs": 1565150251379,
|
||||
"value": [{
|
||||
"value": "aname.unit.tests.",
|
||||
"disableFlag": false
|
||||
}],
|
||||
"roundRobin": [{
|
||||
"value": "aname.unit.tests.",
|
||||
"disableFlag": false
|
||||
}],
|
||||
"geolocation": null,
|
||||
"recordFailover": {
|
||||
"disabled": false,
|
||||
"failoverType": 1,
|
||||
"failoverTypeStr": "Normal (always lowest level)",
|
||||
"values": []
|
||||
},
|
||||
"failover": {
|
||||
"disabled": false,
|
||||
"failoverType": 1,
|
||||
"failoverTypeStr": "Normal (always lowest level)",
|
||||
"values": []
|
||||
},
|
||||
"pools": [],
|
||||
"poolsDetail": []
|
||||
}, {
|
||||
"id": 1808521,
|
||||
"type": "CNAME",
|
||||
"recordType": "cname",
|
||||
"name": "cname",
|
||||
"recordOption": "roundRobin",
|
||||
"noAnswer": false,
|
||||
"note": "",
|
||||
"ttl": 300,
|
||||
"gtdRegion": 1,
|
||||
"parentId": 123123,
|
||||
"parent": "domain",
|
||||
"source": "Domain",
|
||||
"modifiedTs": 1565152113825,
|
||||
"value": "",
|
||||
"roundRobin": [{
|
||||
"value": "",
|
||||
"disableFlag": false
|
||||
}],
|
||||
"recordFailover": {
|
||||
"disabled": false,
|
||||
"failoverType": 1,
|
||||
"failoverTypeStr": "Normal (always lowest level)",
|
||||
"values": [{
|
||||
"id": null,
|
||||
"value": "",
|
||||
"disableFlag": false,
|
||||
"failedFlag": false,
|
||||
"status": "N/A",
|
||||
"sortOrder": 1,
|
||||
"markedActive": false
|
||||
}, {
|
||||
"id": null,
|
||||
"value": "",
|
||||
"disableFlag": false,
|
||||
"failedFlag": false,
|
||||
"status": "N/A",
|
||||
"sortOrder": 2,
|
||||
"markedActive": false
|
||||
}]
|
||||
},
|
||||
"failover": {
|
||||
"disabled": false,
|
||||
"failoverType": 1,
|
||||
"failoverTypeStr": "Normal (always lowest level)",
|
||||
"values": [{
|
||||
"id": null,
|
||||
"value": "",
|
||||
"disableFlag": false,
|
||||
"failedFlag": false,
|
||||
"status": "N/A",
|
||||
"sortOrder": 1,
|
||||
"markedActive": false
|
||||
}, {
|
||||
"id": null,
|
||||
"value": "",
|
||||
"disableFlag": false,
|
||||
"failedFlag": false,
|
||||
"status": "N/A",
|
||||
"sortOrder": 2,
|
||||
"markedActive": false
|
||||
}]
|
||||
},
|
||||
"pools": [],
|
||||
"poolsDetail": [],
|
||||
"geolocation": null,
|
||||
"host": ""
|
||||
}, {
|
||||
"id": 1808522,
|
||||
"type": "CNAME",
|
||||
"recordType": "cname",
|
||||
"name": "included",
|
||||
"recordOption": "roundRobin",
|
||||
"noAnswer": false,
|
||||
"note": "",
|
||||
"ttl": 3600,
|
||||
"gtdRegion": 1,
|
||||
"parentId": 123123,
|
||||
"parent": "domain",
|
||||
"source": "Domain",
|
||||
"modifiedTs": 1565152119137,
|
||||
"value": "",
|
||||
"roundRobin": [{
|
||||
"value": "",
|
||||
"disableFlag": false
|
||||
}],
|
||||
"recordFailover": {
|
||||
"disabled": false,
|
||||
"failoverType": 1,
|
||||
"failoverTypeStr": "Normal (always lowest level)",
|
||||
"values": [{
|
||||
"id": null,
|
||||
"value": "",
|
||||
"disableFlag": false,
|
||||
"failedFlag": false,
|
||||
"status": "N/A",
|
||||
"sortOrder": 1,
|
||||
"markedActive": false
|
||||
}, {
|
||||
"id": null,
|
||||
"value": "",
|
||||
"disableFlag": false,
|
||||
"failedFlag": false,
|
||||
"status": "N/A",
|
||||
"sortOrder": 2,
|
||||
"markedActive": false
|
||||
}]
|
||||
},
|
||||
"failover": {
|
||||
"disabled": false,
|
||||
"failoverType": 1,
|
||||
"failoverTypeStr": "Normal (always lowest level)",
|
||||
"values": [{
|
||||
"id": null,
|
||||
"value": "",
|
||||
"disableFlag": false,
|
||||
"failedFlag": false,
|
||||
"status": "N/A",
|
||||
"sortOrder": 1,
|
||||
"markedActive": false
|
||||
}, {
|
||||
"id": null,
|
||||
"value": "",
|
||||
"disableFlag": false,
|
||||
"failedFlag": false,
|
||||
"status": "N/A",
|
||||
"sortOrder": 2,
|
||||
"markedActive": false
|
||||
}]
|
||||
},
|
||||
"pools": [],
|
||||
"poolsDetail": [],
|
||||
"geolocation": null,
|
||||
"host": ""
|
||||
}, {
|
||||
"id": 1808523,
|
||||
"type": "MX",
|
||||
"recordType": "mx",
|
||||
"name": "mx",
|
||||
"recordOption": "roundRobin",
|
||||
"noAnswer": false,
|
||||
"note": "",
|
||||
"ttl": 300,
|
||||
"gtdRegion": 1,
|
||||
"parentId": 123123,
|
||||
"parent": "domain",
|
||||
"source": "Domain",
|
||||
"modifiedTs": 1565149879856,
|
||||
"value": [{
|
||||
"value": "smtp-3.unit.tests.",
|
||||
"level": 30,
|
||||
"disableFlag": false
|
||||
}, {
|
||||
"value": "smtp-2.unit.tests.",
|
||||
"level": 20,
|
||||
"disableFlag": false
|
||||
}, {
|
||||
"value": "smtp-4.unit.tests.",
|
||||
"level": 10,
|
||||
"disableFlag": false
|
||||
}, {
|
||||
"value": "smtp-1.unit.tests.",
|
||||
"level": 40,
|
||||
"disableFlag": false
|
||||
}],
|
||||
"roundRobin": [{
|
||||
"value": "smtp-3.unit.tests.",
|
||||
"level": 30,
|
||||
"disableFlag": false
|
||||
}, {
|
||||
"value": "smtp-2.unit.tests.",
|
||||
"level": 20,
|
||||
"disableFlag": false
|
||||
}, {
|
||||
"value": "smtp-4.unit.tests.",
|
||||
"level": 10,
|
||||
"disableFlag": false
|
||||
}, {
|
||||
"value": "smtp-1.unit.tests.",
|
||||
"level": 40,
|
||||
"disableFlag": false
|
||||
}]
|
||||
}, {
|
||||
"id": 1808525,
|
||||
"type": "PTR",
|
||||
"recordType": "ptr",
|
||||
"name": "ptr",
|
||||
"recordOption": "roundRobin",
|
||||
"noAnswer": false,
|
||||
"note": "",
|
||||
"ttl": 300,
|
||||
"gtdRegion": 1,
|
||||
"parentId": 123123,
|
||||
"parent": "domain",
|
||||
"source": "Domain",
|
||||
"modifiedTs": 1565150115139,
|
||||
"value": [{
|
||||
"value": "foo.bar.com.",
|
||||
"disableFlag": false
|
||||
}],
|
||||
"roundRobin": [{
|
||||
"value": "foo.bar.com.",
|
||||
"disableFlag": false
|
||||
}]
|
||||
}, {
|
||||
"id": 1808526,
|
||||
"type": "SPF",
|
||||
"recordType": "spf",
|
||||
"name": "spf",
|
||||
"recordOption": "roundRobin",
|
||||
"noAnswer": false,
|
||||
"note": "",
|
||||
"ttl": 600,
|
||||
"gtdRegion": 1,
|
||||
"parentId": 123123,
|
||||
"parent": "domain",
|
||||
"source": "Domain",
|
||||
"modifiedTs": 1565149916132,
|
||||
"value": [{
|
||||
"value": "\"v=spf1 ip4:192.168.0.1/16-all\"",
|
||||
"disableFlag": false
|
||||
}],
|
||||
"roundRobin": [{
|
||||
"value": "\"v=spf1 ip4:192.168.0.1/16-all\"",
|
||||
"disableFlag": false
|
||||
}]
|
||||
}, {
|
||||
"id": 1808528,
|
||||
"type": "TXT",
|
||||
"recordType": "txt",
|
||||
"name": "txt",
|
||||
"recordOption": "roundRobin",
|
||||
"noAnswer": false,
|
||||
"note": "",
|
||||
"ttl": 600,
|
||||
"gtdRegion": 1,
|
||||
"parentId": 123123,
|
||||
"parent": "domain",
|
||||
"source": "Domain",
|
||||
"modifiedTs": 1565149966915,
|
||||
"value": [{
|
||||
"value": "\"Bah bah black sheep\"",
|
||||
"disableFlag": false
|
||||
}, {
|
||||
"value": "\"have you any wool.\"",
|
||||
"disableFlag": false
|
||||
}, {
|
||||
"value": "\"v=DKIM1;k=rsa;s=email;h=sha256;p=A/kinda+of/long/string+with+numb3rs\"",
|
||||
"disableFlag": false
|
||||
}],
|
||||
"roundRobin": [{
|
||||
"value": "\"Bah bah black sheep\"",
|
||||
"disableFlag": false
|
||||
}, {
|
||||
"value": "\"have you any wool.\"",
|
||||
"disableFlag": false
|
||||
}, {
|
||||
"value": "\"v=DKIM1;k=rsa;s=email;h=sha256;p=A/kinda+of/long/string+with+numb3rs\"",
|
||||
"disableFlag": false
|
||||
}]
|
||||
}, {
|
||||
"id": 1808524,
|
||||
"type": "NS",
|
||||
"recordType": "ns",
|
||||
"name": "under",
|
||||
"recordOption": "roundRobin",
|
||||
"noAnswer": false,
|
||||
"note": "",
|
||||
"ttl": 3600,
|
||||
"gtdRegion": 1,
|
||||
"parentId": 123123,
|
||||
"parent": "domain",
|
||||
"source": "Domain",
|
||||
"modifiedTs": 1565150062850,
|
||||
"value": [{
|
||||
"value": "ns1.unit.tests.",
|
||||
"disableFlag": false
|
||||
}, {
|
||||
"value": "ns2",
|
||||
"disableFlag": false
|
||||
}],
|
||||
"roundRobin": [{
|
||||
"value": "ns1.unit.tests.",
|
||||
"disableFlag": false
|
||||
}, {
|
||||
"value": "ns2",
|
||||
"disableFlag": false
|
||||
}]
|
||||
}, {
|
||||
"id": 1808531,
|
||||
"type": "HTTPRedirection",
|
||||
"recordType": "httpredirection",
|
||||
"name": "unsupported",
|
||||
"recordOption": "roundRobin",
|
||||
"noAnswer": false,
|
||||
"note": "",
|
||||
"ttl": 300,
|
||||
"gtdRegion": 1,
|
||||
"parentId": 123123,
|
||||
"parent": "domain",
|
||||
"source": "Domain",
|
||||
"modifiedTs": 1565150348154,
|
||||
"value": "https://redirect.unit.tests",
|
||||
"roundRobin": [{
|
||||
"value": "https://redirect.unit.tests"
|
||||
}],
|
||||
"title": "Unsupported Record",
|
||||
"keywords": "unsupported",
|
||||
"description": "unsupported record",
|
||||
"hardlinkFlag": false,
|
||||
"redirectTypeId": 1,
|
||||
"url": "https://redirect.unit.tests"
|
||||
}, {
|
||||
"id": 1808519,
|
||||
"type": "A",
|
||||
"recordType": "a",
|
||||
"name": "www",
|
||||
"recordOption": "roundRobin",
|
||||
"noAnswer": false,
|
||||
"note": "",
|
||||
"ttl": 300,
|
||||
"gtdRegion": 1,
|
||||
"parentId": 123123,
|
||||
"parent": "domain",
|
||||
"source": "Domain",
|
||||
"modifiedTs": 1565150079027,
|
||||
"value": ["2.2.3.6"],
|
||||
"roundRobin": [{
|
||||
"value": "2.2.3.6",
|
||||
"disableFlag": false
|
||||
}],
|
||||
"geolocation": null,
|
||||
"recordFailover": {
|
||||
"disabled": false,
|
||||
"failoverType": 1,
|
||||
"failoverTypeStr": "Normal (always lowest level)",
|
||||
"values": []
|
||||
},
|
||||
"failover": {
|
||||
"disabled": false,
|
||||
"failoverType": 1,
|
||||
"failoverTypeStr": "Normal (always lowest level)",
|
||||
"values": []
|
||||
},
|
||||
"roundRobinFailover": [],
|
||||
"pools": [],
|
||||
"poolsDetail": []
|
||||
}, {
|
||||
"id": 1808520,
|
||||
"type": "A",
|
||||
"recordType": "a",
|
||||
"name": "www.sub",
|
||||
"recordOption": "roundRobin",
|
||||
"noAnswer": false,
|
||||
"note": "",
|
||||
"ttl": 300,
|
||||
"gtdRegion": 1,
|
||||
"parentId": 123123,
|
||||
"parent": "domain",
|
||||
"source": "Domain",
|
||||
"modifiedTs": 1565150090588,
|
||||
"value": ["2.2.3.6"],
|
||||
"roundRobin": [{
|
||||
"value": "2.2.3.6",
|
||||
"disableFlag": false
|
||||
}],
|
||||
"geolocation": null,
|
||||
"recordFailover": {
|
||||
"disabled": false,
|
||||
"failoverType": 1,
|
||||
"failoverTypeStr": "Normal (always lowest level)",
|
||||
"values": []
|
||||
},
|
||||
"failover": {
|
||||
"disabled": false,
|
||||
"failoverType": 1,
|
||||
"failoverTypeStr": "Normal (always lowest level)",
|
||||
"values": []
|
||||
},
|
||||
"roundRobinFailover": [],
|
||||
"pools": [],
|
||||
"poolsDetail": []
|
||||
}, {
|
||||
"id": 1808520,
|
||||
"type": "A",
|
||||
"recordType": "a",
|
||||
"name": "www.dynamic",
|
||||
"recordOption": "pools",
|
||||
"noAnswer": false,
|
||||
"note": "",
|
||||
"ttl": 300,
|
||||
"gtdRegion": 1,
|
||||
"parentId": 123123,
|
||||
"parent": "domain",
|
||||
"source": "Domain",
|
||||
"modifiedTs": 1565150090588,
|
||||
"value": [],
|
||||
"roundRobin": [],
|
||||
"geolocation": {
|
||||
"geoipFilter": 1
|
||||
},
|
||||
"recordFailover": {
|
||||
"disabled": false,
|
||||
"failoverType": 1,
|
||||
"failoverTypeStr": "Normal (always lowest level)",
|
||||
"values": []
|
||||
},
|
||||
"failover": {
|
||||
"disabled": false,
|
||||
"failoverType": 1,
|
||||
"failoverTypeStr": "Normal (always lowest level)",
|
||||
"values": []
|
||||
},
|
||||
"roundRobinFailover": [],
|
||||
"pools": [
|
||||
1808521
|
||||
],
|
||||
"poolsDetail": [{
|
||||
"id": 1808521,
|
||||
"name": "unit.tests.:www.dynamic:A:two"
|
||||
}]
|
||||
},
|
||||
{
|
||||
"id": 1808521,
|
||||
"type": "A",
|
||||
"recordType": "a",
|
||||
"name": "www.dynamic",
|
||||
"recordOption": "pools",
|
||||
"noAnswer": false,
|
||||
"note": "",
|
||||
"ttl": 300,
|
||||
"gtdRegion": 1,
|
||||
"parentId": 123123,
|
||||
"parent": "domain",
|
||||
"source": "Domain",
|
||||
"modifiedTs": 1565150090588,
|
||||
"value": [],
|
||||
"roundRobin": [],
|
||||
"geolocation": {
|
||||
"geoipFilter": 5303
|
||||
},
|
||||
"recordFailover": {
|
||||
"disabled": false,
|
||||
"failoverType": 1,
|
||||
"failoverTypeStr": "Normal (always lowest level)",
|
||||
"values": []
|
||||
},
|
||||
"failover": {
|
||||
"disabled": false,
|
||||
"failoverType": 1,
|
||||
"failoverTypeStr": "Normal (always lowest level)",
|
||||
"values": []
|
||||
},
|
||||
"roundRobinFailover": [],
|
||||
"pools": [
|
||||
1808522
|
||||
],
|
||||
"poolsDetail": [{
|
||||
"id": 1808522,
|
||||
"name": "unit.tests.:www.dynamic:A:one"
|
||||
}]
|
||||
}]
|
||||
-188
@@ -1,188 +0,0 @@
|
||||
{
|
||||
"domain_records": [{
|
||||
"id": null,
|
||||
"type": "SOA",
|
||||
"name": "@",
|
||||
"data": null,
|
||||
"priority": null,
|
||||
"port": null,
|
||||
"ttl": null,
|
||||
"weight": null,
|
||||
"flags": null,
|
||||
"tag": null
|
||||
}, {
|
||||
"id": 11189874,
|
||||
"type": "NS",
|
||||
"name": "@",
|
||||
"data": "ns1.digitalocean.com",
|
||||
"priority": null,
|
||||
"port": null,
|
||||
"ttl": 3600,
|
||||
"weight": null,
|
||||
"flags": null,
|
||||
"tag": null
|
||||
}, {
|
||||
"id": 11189875,
|
||||
"type": "NS",
|
||||
"name": "@",
|
||||
"data": "ns2.digitalocean.com",
|
||||
"priority": null,
|
||||
"port": null,
|
||||
"ttl": 3600,
|
||||
"weight": null,
|
||||
"flags": null,
|
||||
"tag": null
|
||||
}, {
|
||||
"id": 11189876,
|
||||
"type": "NS",
|
||||
"name": "@",
|
||||
"data": "ns3.digitalocean.com",
|
||||
"priority": null,
|
||||
"port": null,
|
||||
"ttl": 3600,
|
||||
"weight": null,
|
||||
"flags": null,
|
||||
"tag": null
|
||||
}, {
|
||||
"id": 11189877,
|
||||
"type": "NS",
|
||||
"name": "under",
|
||||
"data": "ns1.unit.tests",
|
||||
"priority": null,
|
||||
"port": null,
|
||||
"ttl": 3600,
|
||||
"weight": null,
|
||||
"flags": null,
|
||||
"tag": null
|
||||
}, {
|
||||
"id": 11189878,
|
||||
"type": "NS",
|
||||
"name": "under",
|
||||
"data": "ns2.unit.tests",
|
||||
"priority": null,
|
||||
"port": null,
|
||||
"ttl": 3600,
|
||||
"weight": null,
|
||||
"flags": null,
|
||||
"tag": null
|
||||
}, {
|
||||
"id": 11189879,
|
||||
"type": "SRV",
|
||||
"name": "_srv._tcp",
|
||||
"data": "foo-1.unit.tests",
|
||||
"priority": 10,
|
||||
"port": 30,
|
||||
"ttl": 600,
|
||||
"weight": 20,
|
||||
"flags": null,
|
||||
"tag": null
|
||||
}, {
|
||||
"id": 11189880,
|
||||
"type": "SRV",
|
||||
"name": "_srv._tcp",
|
||||
"data": "foo-2.unit.tests",
|
||||
"priority": 12,
|
||||
"port": 30,
|
||||
"ttl": 600,
|
||||
"weight": 20,
|
||||
"flags": null,
|
||||
"tag": null
|
||||
}, {
|
||||
"id": 11189881,
|
||||
"type": "TXT",
|
||||
"name": "txt",
|
||||
"data": "Bah bah black sheep",
|
||||
"priority": null,
|
||||
"port": null,
|
||||
"ttl": 600,
|
||||
"weight": null,
|
||||
"flags": null,
|
||||
"tag": null
|
||||
}, {
|
||||
"id": 11189882,
|
||||
"type": "TXT",
|
||||
"name": "txt",
|
||||
"data": "have you any wool.",
|
||||
"priority": null,
|
||||
"port": null,
|
||||
"ttl": 600,
|
||||
"weight": null,
|
||||
"flags": null,
|
||||
"tag": null
|
||||
}, {
|
||||
"id": 11189883,
|
||||
"type": "A",
|
||||
"name": "@",
|
||||
"data": "1.2.3.4",
|
||||
"priority": null,
|
||||
"port": null,
|
||||
"ttl": 300,
|
||||
"weight": null,
|
||||
"flags": null,
|
||||
"tag": null
|
||||
}, {
|
||||
"id": 11189884,
|
||||
"type": "A",
|
||||
"name": "@",
|
||||
"data": "1.2.3.5",
|
||||
"priority": null,
|
||||
"port": null,
|
||||
"ttl": 300,
|
||||
"weight": null,
|
||||
"flags": null,
|
||||
"tag": null
|
||||
}, {
|
||||
"id": 11189885,
|
||||
"type": "A",
|
||||
"name": "www",
|
||||
"data": "2.2.3.6",
|
||||
"priority": null,
|
||||
"port": null,
|
||||
"ttl": 300,
|
||||
"weight": null,
|
||||
"flags": null,
|
||||
"tag": null
|
||||
}, {
|
||||
"id": 11189886,
|
||||
"type": "MX",
|
||||
"name": "mx",
|
||||
"data": "smtp-4.unit.tests",
|
||||
"priority": 10,
|
||||
"port": null,
|
||||
"ttl": 300,
|
||||
"weight": null,
|
||||
"flags": null,
|
||||
"tag": null
|
||||
}, {
|
||||
"id": 11189887,
|
||||
"type": "MX",
|
||||
"name": "mx",
|
||||
"data": "smtp-2.unit.tests",
|
||||
"priority": 20,
|
||||
"port": null,
|
||||
"ttl": 300,
|
||||
"weight": null,
|
||||
"flags": null,
|
||||
"tag": null
|
||||
}, {
|
||||
"id": 11189888,
|
||||
"type": "MX",
|
||||
"name": "mx",
|
||||
"data": "smtp-3.unit.tests",
|
||||
"priority": 30,
|
||||
"port": null,
|
||||
"ttl": 300,
|
||||
"weight": null,
|
||||
"flags": null,
|
||||
"tag": null
|
||||
}],
|
||||
"links": {
|
||||
"pages": {
|
||||
"last": "https://api.digitalocean.com/v2/domains/unit.tests/records?page=2",
|
||||
"next": "https://api.digitalocean.com/v2/domains/unit.tests/records?page=2"
|
||||
}
|
||||
},
|
||||
"meta": {
|
||||
"total": 21
|
||||
}
|
||||
}
|
||||
-111
@@ -1,111 +0,0 @@
|
||||
{
|
||||
"domain_records": [{
|
||||
"id": 11189889,
|
||||
"type": "MX",
|
||||
"name": "mx",
|
||||
"data": "smtp-1.unit.tests",
|
||||
"priority": 40,
|
||||
"port": null,
|
||||
"ttl": 300,
|
||||
"weight": null,
|
||||
"flags": null,
|
||||
"tag": null
|
||||
}, {
|
||||
"id": 11189890,
|
||||
"type": "AAAA",
|
||||
"name": "aaaa",
|
||||
"data": "2601:644:500:e210:62f8:1dff:feb8:947a",
|
||||
"priority": null,
|
||||
"port": null,
|
||||
"ttl": 600,
|
||||
"weight": null,
|
||||
"flags": null,
|
||||
"tag": null
|
||||
}, {
|
||||
"id": 11189891,
|
||||
"type": "CNAME",
|
||||
"name": "cname",
|
||||
"data": "@",
|
||||
"priority": null,
|
||||
"port": null,
|
||||
"ttl": 300,
|
||||
"weight": null,
|
||||
"flags": null,
|
||||
"tag": null
|
||||
}, {
|
||||
"id": 11189892,
|
||||
"type": "A",
|
||||
"name": "www.sub",
|
||||
"data": "2.2.3.6",
|
||||
"priority": null,
|
||||
"port": null,
|
||||
"ttl": 300,
|
||||
"weight": null,
|
||||
"flags": null,
|
||||
"tag": null
|
||||
}, {
|
||||
"id": 11189893,
|
||||
"type": "TXT",
|
||||
"name": "txt",
|
||||
"data": "v=DKIM1;k=rsa;s=email;h=sha256;p=A/kinda+of/long/string+with+numb3rs",
|
||||
"priority": null,
|
||||
"port": null,
|
||||
"ttl": 600,
|
||||
"weight": null,
|
||||
"flags": null,
|
||||
"tag": null
|
||||
}, {
|
||||
"id": 11189894,
|
||||
"type": "CAA",
|
||||
"name": "@",
|
||||
"data": "ca.unit.tests",
|
||||
"priority": null,
|
||||
"port": null,
|
||||
"ttl": 3600,
|
||||
"weight": null,
|
||||
"flags": 0,
|
||||
"tag": "issue"
|
||||
}, {
|
||||
"id": 11189895,
|
||||
"type": "CNAME",
|
||||
"name": "included",
|
||||
"data": "@",
|
||||
"priority": null,
|
||||
"port": null,
|
||||
"ttl": 3600,
|
||||
"weight": null,
|
||||
"flags": null,
|
||||
"tag": null
|
||||
}, {
|
||||
"id": 11189896,
|
||||
"type": "SRV",
|
||||
"name": "_imap._tcp",
|
||||
"data": ".",
|
||||
"priority": 0,
|
||||
"port": 0,
|
||||
"ttl": 600,
|
||||
"weight": 0,
|
||||
"flags": null,
|
||||
"tag": null
|
||||
}, {
|
||||
"id": 11189897,
|
||||
"type": "SRV",
|
||||
"name": "_pop3._tcp",
|
||||
"data": ".",
|
||||
"priority": 0,
|
||||
"port": 0,
|
||||
"ttl": 600,
|
||||
"weight": 0,
|
||||
"flags": null,
|
||||
"tag": null
|
||||
}],
|
||||
"links": {
|
||||
"pages": {
|
||||
"first": "https://api.digitalocean.com/v2/domains/unit.tests/records?page=1",
|
||||
"prev": "https://api.digitalocean.com/v2/domains/unit.tests/records?page=1"
|
||||
}
|
||||
},
|
||||
"meta": {
|
||||
"total": 21
|
||||
}
|
||||
}
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
{
|
||||
"totalPages": 1,
|
||||
"totalRecords": 1,
|
||||
"data": [{
|
||||
"created": 1511740800000,
|
||||
"folderId": 1990,
|
||||
"gtdEnabled": false,
|
||||
"pendingActionId": 0,
|
||||
"updated": 1511766661574,
|
||||
"processMulti": false,
|
||||
"activeThirdParties": [],
|
||||
"name": "unit.tests",
|
||||
"id": 123123
|
||||
}],
|
||||
"page": 0
|
||||
}
|
||||
-344
@@ -1,344 +0,0 @@
|
||||
{
|
||||
"totalPages": 1,
|
||||
"totalRecords": 23,
|
||||
"data": [{
|
||||
"failover": false,
|
||||
"monitor": false,
|
||||
"sourceId": 123123,
|
||||
"caaType": "issue",
|
||||
"dynamicDns": false,
|
||||
"failed": false,
|
||||
"gtdLocation": "DEFAULT",
|
||||
"hardLink": false,
|
||||
"issuerCritical": 0,
|
||||
"ttl": 3600,
|
||||
"source": 1,
|
||||
"name": "",
|
||||
"value": "\"ca.unit.tests\"",
|
||||
"id": 11189874,
|
||||
"type": "CAA"
|
||||
}, {
|
||||
"failover": false,
|
||||
"monitor": false,
|
||||
"sourceId": 123123,
|
||||
"dynamicDns": false,
|
||||
"failed": false,
|
||||
"gtdLocation": "DEFAULT",
|
||||
"hardLink": false,
|
||||
"ttl": 300,
|
||||
"source": 1,
|
||||
"name": "",
|
||||
"value": "1.2.3.4",
|
||||
"id": 11189875,
|
||||
"type": "A"
|
||||
}, {
|
||||
"failover": false,
|
||||
"monitor": false,
|
||||
"sourceId": 123123,
|
||||
"dynamicDns": false,
|
||||
"failed": false,
|
||||
"gtdLocation": "DEFAULT",
|
||||
"hardLink": false,
|
||||
"ttl": 300,
|
||||
"source": 1,
|
||||
"name": "",
|
||||
"value": "1.2.3.5",
|
||||
"id": 11189876,
|
||||
"type": "A"
|
||||
}, {
|
||||
"failover": false,
|
||||
"monitor": false,
|
||||
"sourceId": 123123,
|
||||
"dynamicDns": false,
|
||||
"failed": false,
|
||||
"gtdLocation": "DEFAULT",
|
||||
"hardLink": false,
|
||||
"ttl": 600,
|
||||
"weight": 20,
|
||||
"source": 1,
|
||||
"name": "_srv._tcp",
|
||||
"value": "foo-1.unit.tests.",
|
||||
"id": 11189877,
|
||||
"priority": 10,
|
||||
"type": "SRV",
|
||||
"port": 30
|
||||
}, {
|
||||
"failover": false,
|
||||
"monitor": false,
|
||||
"sourceId": 123123,
|
||||
"dynamicDns": false,
|
||||
"failed": false,
|
||||
"gtdLocation": "DEFAULT",
|
||||
"hardLink": false,
|
||||
"ttl": 600,
|
||||
"weight": 20,
|
||||
"source": 1,
|
||||
"name": "_srv._tcp",
|
||||
"value": "foo-2.unit.tests.",
|
||||
"id": 11189878,
|
||||
"priority": 12,
|
||||
"type": "SRV",
|
||||
"port": 30
|
||||
}, {
|
||||
"failover": false,
|
||||
"monitor": false,
|
||||
"sourceId": 123123,
|
||||
"dynamicDns": false,
|
||||
"failed": false,
|
||||
"gtdLocation": "DEFAULT",
|
||||
"hardLink": false,
|
||||
"ttl": 600,
|
||||
"source": 1,
|
||||
"name": "aaaa",
|
||||
"value": "2601:644:500:e210:62f8:1dff:feb8:947a",
|
||||
"id": 11189879,
|
||||
"type": "AAAA"
|
||||
}, {
|
||||
"failover": false,
|
||||
"monitor": false,
|
||||
"sourceId": 123123,
|
||||
"dynamicDns": false,
|
||||
"failed": false,
|
||||
"gtdLocation": "DEFAULT",
|
||||
"hardLink": false,
|
||||
"ttl": 300,
|
||||
"source": 1,
|
||||
"name": "cname",
|
||||
"value": "",
|
||||
"id": 11189880,
|
||||
"type": "CNAME"
|
||||
}, {
|
||||
"failover": false,
|
||||
"monitor": false,
|
||||
"sourceId": 123123,
|
||||
"dynamicDns": false,
|
||||
"failed": false,
|
||||
"gtdLocation": "DEFAULT",
|
||||
"hardLink": false,
|
||||
"ttl": 3600,
|
||||
"source": 1,
|
||||
"name": "included",
|
||||
"value": "",
|
||||
"id": 11189881,
|
||||
"type": "CNAME"
|
||||
}, {
|
||||
"failover": false,
|
||||
"monitor": false,
|
||||
"sourceId": 123123,
|
||||
"dynamicDns": false,
|
||||
"failed": false,
|
||||
"gtdLocation": "DEFAULT",
|
||||
"hardLink": false,
|
||||
"mxLevel": 30,
|
||||
"ttl": 300,
|
||||
"source": 1,
|
||||
"name": "mx",
|
||||
"value": "smtp-3.unit.tests.",
|
||||
"id": 11189882,
|
||||
"type": "MX"
|
||||
}, {
|
||||
"failover": false,
|
||||
"monitor": false,
|
||||
"sourceId": 123123,
|
||||
"dynamicDns": false,
|
||||
"failed": false,
|
||||
"gtdLocation": "DEFAULT",
|
||||
"hardLink": false,
|
||||
"mxLevel": 20,
|
||||
"ttl": 300,
|
||||
"source": 1,
|
||||
"name": "mx",
|
||||
"value": "smtp-2.unit.tests.",
|
||||
"id": 11189883,
|
||||
"type": "MX"
|
||||
}, {
|
||||
"failover": false,
|
||||
"monitor": false,
|
||||
"sourceId": 123123,
|
||||
"dynamicDns": false,
|
||||
"failed": false,
|
||||
"gtdLocation": "DEFAULT",
|
||||
"hardLink": false,
|
||||
"mxLevel": 10,
|
||||
"ttl": 300,
|
||||
"source": 1,
|
||||
"name": "mx",
|
||||
"value": "smtp-4.unit.tests.",
|
||||
"id": 11189884,
|
||||
"type": "MX"
|
||||
}, {
|
||||
"failover": false,
|
||||
"monitor": false,
|
||||
"sourceId": 123123,
|
||||
"dynamicDns": false,
|
||||
"failed": false,
|
||||
"gtdLocation": "DEFAULT",
|
||||
"hardLink": false,
|
||||
"mxLevel": 40,
|
||||
"ttl": 300,
|
||||
"source": 1,
|
||||
"name": "mx",
|
||||
"value": "smtp-1.unit.tests.",
|
||||
"id": 11189885,
|
||||
"type": "MX"
|
||||
}, {
|
||||
"failover": false,
|
||||
"monitor": false,
|
||||
"sourceId": 123123,
|
||||
"dynamicDns": false,
|
||||
"failed": false,
|
||||
"gtdLocation": "DEFAULT",
|
||||
"hardLink": false,
|
||||
"ttl": 600,
|
||||
"source": 1,
|
||||
"name": "spf",
|
||||
"value": "\"v=spf1 ip4:192.168.0.1/16-all\"",
|
||||
"id": 11189886,
|
||||
"type": "SPF"
|
||||
}, {
|
||||
"failover": false,
|
||||
"monitor": false,
|
||||
"sourceId": 123123,
|
||||
"dynamicDns": false,
|
||||
"failed": false,
|
||||
"gtdLocation": "DEFAULT",
|
||||
"hardLink": false,
|
||||
"ttl": 600,
|
||||
"source": 1,
|
||||
"name": "txt",
|
||||
"value": "\"Bah bah black sheep\"",
|
||||
"id": 11189887,
|
||||
"type": "TXT"
|
||||
}, {
|
||||
"failover": false,
|
||||
"monitor": false,
|
||||
"sourceId": 123123,
|
||||
"dynamicDns": false,
|
||||
"failed": false,
|
||||
"gtdLocation": "DEFAULT",
|
||||
"hardLink": false,
|
||||
"ttl": 600,
|
||||
"source": 1,
|
||||
"name": "txt",
|
||||
"value": "\"have you any wool.\"",
|
||||
"id": 11189888,
|
||||
"type": "TXT"
|
||||
}, {
|
||||
"failover": false,
|
||||
"monitor": false,
|
||||
"sourceId": 123123,
|
||||
"dynamicDns": false,
|
||||
"failed": false,
|
||||
"gtdLocation": "DEFAULT",
|
||||
"hardLink": false,
|
||||
"ttl": 600,
|
||||
"source": 1,
|
||||
"name": "txt",
|
||||
"value": "\"v=DKIM1;k=rsa;s=email;h=sha256;p=A/kinda+of/long/string+with+numb3rs\"",
|
||||
"id": 11189889,
|
||||
"type": "TXT"
|
||||
}, {
|
||||
"failover": false,
|
||||
"monitor": false,
|
||||
"sourceId": 123123,
|
||||
"dynamicDns": false,
|
||||
"failed": false,
|
||||
"gtdLocation": "DEFAULT",
|
||||
"hardLink": false,
|
||||
"ttl": 3600,
|
||||
"source": 1,
|
||||
"name": "under",
|
||||
"value": "ns1.unit.tests.",
|
||||
"id": 11189890,
|
||||
"type": "NS"
|
||||
}, {
|
||||
"failover": false,
|
||||
"monitor": false,
|
||||
"sourceId": 123123,
|
||||
"dynamicDns": false,
|
||||
"failed": false,
|
||||
"gtdLocation": "DEFAULT",
|
||||
"hardLink": false,
|
||||
"ttl": 3600,
|
||||
"source": 1,
|
||||
"name": "under",
|
||||
"value": "ns2",
|
||||
"id": 11189891,
|
||||
"type": "NS"
|
||||
}, {
|
||||
"failover": false,
|
||||
"monitor": false,
|
||||
"sourceId": 123123,
|
||||
"dynamicDns": false,
|
||||
"failed": false,
|
||||
"gtdLocation": "DEFAULT",
|
||||
"hardLink": false,
|
||||
"ttl": 300,
|
||||
"source": 1,
|
||||
"name": "www",
|
||||
"value": "2.2.3.6",
|
||||
"id": 11189892,
|
||||
"type": "A"
|
||||
}, {
|
||||
"failover": false,
|
||||
"monitor": false,
|
||||
"sourceId": 123123,
|
||||
"dynamicDns": false,
|
||||
"failed": false,
|
||||
"gtdLocation": "DEFAULT",
|
||||
"hardLink": false,
|
||||
"ttl": 300,
|
||||
"source": 1,
|
||||
"name": "www.sub",
|
||||
"value": "2.2.3.6",
|
||||
"id": 11189893,
|
||||
"type": "A"
|
||||
}, {
|
||||
"failover": false,
|
||||
"monitor": false,
|
||||
"sourceId": 123123,
|
||||
"dynamicDns": false,
|
||||
"failed": false,
|
||||
"gtdLocation": "DEFAULT",
|
||||
"hardLink": false,
|
||||
"ttl": 300,
|
||||
"source": 1,
|
||||
"name": "ptr",
|
||||
"value": "foo.bar.com.",
|
||||
"id": 11189894,
|
||||
"type": "PTR"
|
||||
}, {
|
||||
"failover": false,
|
||||
"monitor": false,
|
||||
"sourceId": 123123,
|
||||
"dynamicDns": false,
|
||||
"failed": false,
|
||||
"gtdLocation": "DEFAULT",
|
||||
"hardLink": false,
|
||||
"ttl": 1800,
|
||||
"source": 1,
|
||||
"name": "",
|
||||
"value": "aname.unit.tests.",
|
||||
"id": 11189895,
|
||||
"type": "ANAME"
|
||||
}, {
|
||||
"failover": false,
|
||||
"monitor": false,
|
||||
"sourceId": 123123,
|
||||
"dynamicDns": false,
|
||||
"failed": false,
|
||||
"gtdLocation": "DEFAULT",
|
||||
"hardLink": true,
|
||||
"ttl": 1800,
|
||||
"source": 1,
|
||||
"name": "unsupported",
|
||||
"value": "https://redirect.unit.tests",
|
||||
"id": 11189897,
|
||||
"title": "Unsupported Record",
|
||||
"keywords": "unsupported",
|
||||
"redirectType": "Standard - 302",
|
||||
"description": "unsupported record",
|
||||
"type": "HTTPRED"
|
||||
}],
|
||||
"page": 0
|
||||
}
|
||||
-4190
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -2,273 +2,15 @@
|
||||
#
|
||||
#
|
||||
|
||||
|
||||
from __future__ import absolute_import, division, print_function, \
|
||||
unicode_literals
|
||||
|
||||
from mock import Mock, call
|
||||
from os.path import dirname, join
|
||||
from requests import HTTPError
|
||||
from requests_mock import ANY, mock as requests_mock
|
||||
from unittest import TestCase
|
||||
|
||||
from octodns.record import Record
|
||||
from octodns.provider.digitalocean import DigitalOceanClientNotFound, \
|
||||
DigitalOceanProvider
|
||||
from octodns.provider.yaml import YamlProvider
|
||||
from octodns.zone import Zone
|
||||
|
||||
class TestDigitalOceanShim(TestCase):
|
||||
|
||||
class TestDigitalOceanProvider(TestCase):
|
||||
expected = Zone('unit.tests.', [])
|
||||
source = YamlProvider('test', join(dirname(__file__), 'config'))
|
||||
source.populate(expected)
|
||||
|
||||
# Our test suite differs a bit, add our NS and remove the simple one
|
||||
expected.add_record(Record.new(expected, 'under', {
|
||||
'ttl': 3600,
|
||||
'type': 'NS',
|
||||
'values': [
|
||||
'ns1.unit.tests.',
|
||||
'ns2.unit.tests.',
|
||||
]
|
||||
}))
|
||||
for record in list(expected.records):
|
||||
if record.name == 'sub' and record._type == 'NS':
|
||||
expected._remove_record(record)
|
||||
break
|
||||
|
||||
def test_populate(self):
|
||||
provider = DigitalOceanProvider('test', 'token')
|
||||
|
||||
# Bad auth
|
||||
with requests_mock() as mock:
|
||||
mock.get(ANY, status_code=401,
|
||||
text='{"id":"unauthorized",'
|
||||
'"message":"Unable to authenticate you."}')
|
||||
|
||||
with self.assertRaises(Exception) as ctx:
|
||||
zone = Zone('unit.tests.', [])
|
||||
provider.populate(zone)
|
||||
self.assertEquals('Unauthorized', str(ctx.exception))
|
||||
|
||||
# General error
|
||||
with requests_mock() as mock:
|
||||
mock.get(ANY, status_code=502, text='Things caught fire')
|
||||
|
||||
with self.assertRaises(HTTPError) as ctx:
|
||||
zone = Zone('unit.tests.', [])
|
||||
provider.populate(zone)
|
||||
self.assertEquals(502, ctx.exception.response.status_code)
|
||||
|
||||
# Non-existent zone doesn't populate anything
|
||||
with requests_mock() as mock:
|
||||
mock.get(ANY, status_code=404,
|
||||
text='{"id":"not_found","message":"The resource you '
|
||||
'were accessing could not be found."}')
|
||||
|
||||
zone = Zone('unit.tests.', [])
|
||||
provider.populate(zone)
|
||||
self.assertEquals(set(), zone.records)
|
||||
|
||||
# No diffs == no changes
|
||||
with requests_mock() as mock:
|
||||
base = 'https://api.digitalocean.com/v2/domains/unit.tests/' \
|
||||
'records?page='
|
||||
with open('tests/fixtures/digitalocean-page-1.json') as fh:
|
||||
mock.get(f'{base}1', text=fh.read())
|
||||
with open('tests/fixtures/digitalocean-page-2.json') as fh:
|
||||
mock.get(f'{base}2', text=fh.read())
|
||||
|
||||
zone = Zone('unit.tests.', [])
|
||||
provider.populate(zone)
|
||||
self.assertEquals(14, len(zone.records))
|
||||
changes = self.expected.changes(zone, provider)
|
||||
self.assertEquals(0, len(changes))
|
||||
|
||||
# 2nd populate makes no network calls/all from cache
|
||||
again = Zone('unit.tests.', [])
|
||||
provider.populate(again)
|
||||
self.assertEquals(14, len(again.records))
|
||||
|
||||
# bust the cache
|
||||
del provider._zone_records[zone.name]
|
||||
|
||||
def test_apply(self):
|
||||
provider = DigitalOceanProvider('test', 'token')
|
||||
|
||||
resp = Mock()
|
||||
resp.json = Mock()
|
||||
provider._client._request = Mock(return_value=resp)
|
||||
|
||||
domain_after_creation = {
|
||||
"domain_records": [{
|
||||
"id": 11189874,
|
||||
"type": "NS",
|
||||
"name": "@",
|
||||
"data": "ns1.digitalocean.com",
|
||||
"priority": None,
|
||||
"port": None,
|
||||
"ttl": 3600,
|
||||
"weight": None,
|
||||
"flags": None,
|
||||
"tag": None
|
||||
}, {
|
||||
"id": 11189875,
|
||||
"type": "NS",
|
||||
"name": "@",
|
||||
"data": "ns2.digitalocean.com",
|
||||
"priority": None,
|
||||
"port": None,
|
||||
"ttl": 3600,
|
||||
"weight": None,
|
||||
"flags": None,
|
||||
"tag": None
|
||||
}, {
|
||||
"id": 11189876,
|
||||
"type": "NS",
|
||||
"name": "@",
|
||||
"data": "ns3.digitalocean.com",
|
||||
"priority": None,
|
||||
"port": None,
|
||||
"ttl": 3600,
|
||||
"weight": None,
|
||||
"flags": None,
|
||||
"tag": None
|
||||
}, {
|
||||
"id": 11189877,
|
||||
"type": "A",
|
||||
"name": "@",
|
||||
"data": "192.0.2.1",
|
||||
"priority": None,
|
||||
"port": None,
|
||||
"ttl": 3600,
|
||||
"weight": None,
|
||||
"flags": None,
|
||||
"tag": None
|
||||
}],
|
||||
"links": {},
|
||||
"meta": {
|
||||
"total": 4
|
||||
}
|
||||
}
|
||||
|
||||
# non-existent domain, create everything
|
||||
resp.json.side_effect = [
|
||||
DigitalOceanClientNotFound, # no zone in populate
|
||||
DigitalOceanClientNotFound, # no domain during apply
|
||||
domain_after_creation
|
||||
]
|
||||
plan = provider.plan(self.expected)
|
||||
|
||||
# No root NS, no ignored, no excluded, no unsupported
|
||||
n = len(self.expected.records) - 10
|
||||
self.assertEquals(n, len(plan.changes))
|
||||
self.assertEquals(n, provider.apply(plan))
|
||||
self.assertFalse(plan.exists)
|
||||
|
||||
provider._client._request.assert_has_calls([
|
||||
# created the domain
|
||||
call('POST', '/domains', data={'ip_address': '192.0.2.1',
|
||||
'name': 'unit.tests'}),
|
||||
# get all records in newly created zone
|
||||
call('GET', '/domains/unit.tests/records', {'page': 1}),
|
||||
# delete the initial A record
|
||||
call('DELETE', '/domains/unit.tests/records/11189877'),
|
||||
# created at least some of the record with expected data
|
||||
call('POST', '/domains/unit.tests/records', data={
|
||||
'data': '1.2.3.4',
|
||||
'name': '@',
|
||||
'ttl': 300, 'type': 'A'}),
|
||||
call('POST', '/domains/unit.tests/records', data={
|
||||
'data': '1.2.3.5',
|
||||
'name': '@',
|
||||
'ttl': 300, 'type': 'A'}),
|
||||
call('POST', '/domains/unit.tests/records', data={
|
||||
'data': 'ca.unit.tests',
|
||||
'flags': 0, 'name': '@',
|
||||
'tag': 'issue',
|
||||
'ttl': 3600, 'type': 'CAA'}),
|
||||
call('POST', '/domains/unit.tests/records', data={
|
||||
'name': '_imap._tcp',
|
||||
'weight': 0,
|
||||
'data': '.',
|
||||
'priority': 0,
|
||||
'ttl': 600,
|
||||
'type': 'SRV',
|
||||
'port': 0
|
||||
}),
|
||||
call('POST', '/domains/unit.tests/records', data={
|
||||
'name': '_pop3._tcp',
|
||||
'weight': 0,
|
||||
'data': '.',
|
||||
'priority': 0,
|
||||
'ttl': 600,
|
||||
'type': 'SRV',
|
||||
'port': 0
|
||||
}),
|
||||
call('POST', '/domains/unit.tests/records', data={
|
||||
'name': '_srv._tcp',
|
||||
'weight': 20,
|
||||
'data': 'foo-1.unit.tests.',
|
||||
'priority': 10,
|
||||
'ttl': 600,
|
||||
'type': 'SRV',
|
||||
'port': 30
|
||||
}),
|
||||
])
|
||||
self.assertEquals(26, provider._client._request.call_count)
|
||||
|
||||
provider._client._request.reset_mock()
|
||||
|
||||
# delete 1 and update 1
|
||||
provider._client.records = Mock(return_value=[
|
||||
{
|
||||
'id': 11189897,
|
||||
'name': 'www',
|
||||
'data': '1.2.3.4',
|
||||
'ttl': 300,
|
||||
'type': 'A',
|
||||
},
|
||||
{
|
||||
'id': 11189898,
|
||||
'name': 'www',
|
||||
'data': '2.2.3.4',
|
||||
'ttl': 300,
|
||||
'type': 'A',
|
||||
},
|
||||
{
|
||||
'id': 11189899,
|
||||
'name': 'ttl',
|
||||
'data': '3.2.3.4',
|
||||
'ttl': 600,
|
||||
'type': 'A',
|
||||
}
|
||||
])
|
||||
|
||||
# Domain exists, we don't care about return
|
||||
resp.json.side_effect = ['{}']
|
||||
|
||||
wanted = Zone('unit.tests.', [])
|
||||
wanted.add_record(Record.new(wanted, 'ttl', {
|
||||
'ttl': 300,
|
||||
'type': 'A',
|
||||
'value': '3.2.3.4'
|
||||
}))
|
||||
|
||||
plan = provider.plan(wanted)
|
||||
self.assertTrue(plan.exists)
|
||||
self.assertEquals(2, len(plan.changes))
|
||||
self.assertEquals(2, provider.apply(plan))
|
||||
# recreate for update, and delete for the 2 parts of the other
|
||||
provider._client._request.assert_has_calls([
|
||||
call('POST', '/domains/unit.tests/records', data={
|
||||
'data': '3.2.3.4',
|
||||
'type': 'A',
|
||||
'name': 'ttl',
|
||||
'ttl': 300
|
||||
}),
|
||||
call('DELETE', '/domains/unit.tests/records/11189899'),
|
||||
call('DELETE', '/domains/unit.tests/records/11189897'),
|
||||
call('DELETE', '/domains/unit.tests/records/11189898')
|
||||
], any_order=True)
|
||||
def test_missing(self):
|
||||
with self.assertRaises(ModuleNotFoundError):
|
||||
from octodns.provider.digitalocean import DigitalOceanProvider
|
||||
DigitalOceanProvider
|
||||
|
||||
@@ -2,227 +2,15 @@
|
||||
#
|
||||
#
|
||||
|
||||
|
||||
from __future__ import absolute_import, division, print_function, \
|
||||
unicode_literals
|
||||
|
||||
from mock import Mock, call
|
||||
from os.path import dirname, join
|
||||
from requests import HTTPError
|
||||
from requests_mock import ANY, mock as requests_mock
|
||||
from unittest import TestCase
|
||||
|
||||
from octodns.record import Record
|
||||
from octodns.provider.dnsmadeeasy import DnsMadeEasyClientNotFound, \
|
||||
DnsMadeEasyProvider
|
||||
from octodns.provider.yaml import YamlProvider
|
||||
from octodns.zone import Zone
|
||||
|
||||
import json
|
||||
class TestDnsMadeEasyShim(TestCase):
|
||||
|
||||
|
||||
class TestDnsMadeEasyProvider(TestCase):
|
||||
expected = Zone('unit.tests.', [])
|
||||
source = YamlProvider('test', join(dirname(__file__), 'config'))
|
||||
source.populate(expected)
|
||||
|
||||
# Our test suite differs a bit, add our NS and remove the simple one
|
||||
expected.add_record(Record.new(expected, 'under', {
|
||||
'ttl': 3600,
|
||||
'type': 'NS',
|
||||
'values': [
|
||||
'ns1.unit.tests.',
|
||||
'ns2.unit.tests.',
|
||||
]
|
||||
}))
|
||||
|
||||
# Add some ALIAS records
|
||||
expected.add_record(Record.new(expected, '', {
|
||||
'ttl': 1800,
|
||||
'type': 'ALIAS',
|
||||
'value': 'aname.unit.tests.'
|
||||
}))
|
||||
|
||||
for record in list(expected.records):
|
||||
if record.name == 'sub' and record._type == 'NS':
|
||||
expected._remove_record(record)
|
||||
break
|
||||
|
||||
def test_populate(self):
|
||||
provider = DnsMadeEasyProvider('test', 'api', 'secret')
|
||||
|
||||
# Bad auth
|
||||
with requests_mock() as mock:
|
||||
mock.get(ANY, status_code=401,
|
||||
text='{"error": ["API key not found"]}')
|
||||
|
||||
with self.assertRaises(Exception) as ctx:
|
||||
zone = Zone('unit.tests.', [])
|
||||
provider.populate(zone)
|
||||
self.assertEquals('Unauthorized', str(ctx.exception))
|
||||
|
||||
# Bad request
|
||||
with requests_mock() as mock:
|
||||
mock.get(ANY, status_code=400,
|
||||
text='{"error": ["Rate limit exceeded"]}')
|
||||
|
||||
with self.assertRaises(Exception) as ctx:
|
||||
zone = Zone('unit.tests.', [])
|
||||
provider.populate(zone)
|
||||
self.assertEquals('\n - Rate limit exceeded', str(ctx.exception))
|
||||
|
||||
# General error
|
||||
with requests_mock() as mock:
|
||||
mock.get(ANY, status_code=502, text='Things caught fire')
|
||||
|
||||
with self.assertRaises(HTTPError) as ctx:
|
||||
zone = Zone('unit.tests.', [])
|
||||
provider.populate(zone)
|
||||
self.assertEquals(502, ctx.exception.response.status_code)
|
||||
|
||||
# Non-existent zone doesn't populate anything
|
||||
with requests_mock() as mock:
|
||||
mock.get(ANY, status_code=404,
|
||||
text='<html><head></head><body></body></html>')
|
||||
|
||||
zone = Zone('unit.tests.', [])
|
||||
provider.populate(zone)
|
||||
self.assertEquals(set(), zone.records)
|
||||
|
||||
# No diffs == no changes
|
||||
with requests_mock() as mock:
|
||||
base = 'https://api.dnsmadeeasy.com/V2.0/dns/managed'
|
||||
with open('tests/fixtures/dnsmadeeasy-domains.json') as fh:
|
||||
mock.get(f'{base}/', text=fh.read())
|
||||
with open('tests/fixtures/dnsmadeeasy-records.json') as fh:
|
||||
mock.get(f'{base}/123123/records', text=fh.read())
|
||||
|
||||
zone = Zone('unit.tests.', [])
|
||||
provider.populate(zone)
|
||||
self.assertEquals(14, len(zone.records))
|
||||
changes = self.expected.changes(zone, provider)
|
||||
self.assertEquals(0, len(changes))
|
||||
|
||||
# 2nd populate makes no network calls/all from cache
|
||||
again = Zone('unit.tests.', [])
|
||||
provider.populate(again)
|
||||
self.assertEquals(14, len(again.records))
|
||||
|
||||
# bust the cache
|
||||
del provider._zone_records[zone.name]
|
||||
|
||||
def test_apply(self):
|
||||
# Create provider with sandbox enabled
|
||||
provider = DnsMadeEasyProvider('test', 'api', 'secret', True)
|
||||
|
||||
resp = Mock()
|
||||
resp.json = Mock()
|
||||
provider._client._request = Mock(return_value=resp)
|
||||
|
||||
with open('tests/fixtures/dnsmadeeasy-domains.json') as fh:
|
||||
domains = json.load(fh)
|
||||
|
||||
# non-existent domain, create everything
|
||||
resp.json.side_effect = [
|
||||
DnsMadeEasyClientNotFound, # no zone in populate
|
||||
DnsMadeEasyClientNotFound, # no domain during apply
|
||||
domains
|
||||
]
|
||||
plan = provider.plan(self.expected)
|
||||
|
||||
# No root NS, no ignored, no excluded, no unsupported
|
||||
n = len(self.expected.records) - 10
|
||||
self.assertEquals(n, len(plan.changes))
|
||||
self.assertEquals(n, provider.apply(plan))
|
||||
|
||||
provider._client._request.assert_has_calls([
|
||||
# created the domain
|
||||
call('POST', '/', data={'name': 'unit.tests'}),
|
||||
# get all domains to build the cache
|
||||
call('GET', '/'),
|
||||
# created at least some of the record with expected data
|
||||
call('POST', '/123123/records', data={
|
||||
'type': 'A',
|
||||
'name': '',
|
||||
'value': '1.2.3.4',
|
||||
'ttl': 300}),
|
||||
call('POST', '/123123/records', data={
|
||||
'type': 'A',
|
||||
'name': '',
|
||||
'value': '1.2.3.5',
|
||||
'ttl': 300}),
|
||||
call('POST', '/123123/records', data={
|
||||
'type': 'ANAME',
|
||||
'name': '',
|
||||
'value': 'aname.unit.tests.',
|
||||
'ttl': 1800}),
|
||||
call('POST', '/123123/records', data={
|
||||
'name': '',
|
||||
'value': 'ca.unit.tests',
|
||||
'issuerCritical': 0, 'caaType': 'issue',
|
||||
'ttl': 3600, 'type': 'CAA'}),
|
||||
call('POST', '/123123/records', data={
|
||||
'name': '_srv._tcp',
|
||||
'weight': 20,
|
||||
'value': 'foo-1.unit.tests.',
|
||||
'priority': 10,
|
||||
'ttl': 600,
|
||||
'type': 'SRV',
|
||||
'port': 30
|
||||
}),
|
||||
])
|
||||
self.assertEquals(26, provider._client._request.call_count)
|
||||
|
||||
provider._client._request.reset_mock()
|
||||
|
||||
# delete 1 and update 1
|
||||
provider._client.records = Mock(return_value=[
|
||||
{
|
||||
'id': 11189897,
|
||||
'name': 'www',
|
||||
'value': '1.2.3.4',
|
||||
'ttl': 300,
|
||||
'type': 'A',
|
||||
},
|
||||
{
|
||||
'id': 11189898,
|
||||
'name': 'www',
|
||||
'value': '2.2.3.4',
|
||||
'ttl': 300,
|
||||
'type': 'A',
|
||||
},
|
||||
{
|
||||
'id': 11189899,
|
||||
'name': 'ttl',
|
||||
'value': '3.2.3.4',
|
||||
'ttl': 600,
|
||||
'type': 'A',
|
||||
}
|
||||
])
|
||||
|
||||
# Domain exists, we don't care about return
|
||||
resp.json.side_effect = ['{}']
|
||||
|
||||
wanted = Zone('unit.tests.', [])
|
||||
wanted.add_record(Record.new(wanted, 'ttl', {
|
||||
'ttl': 300,
|
||||
'type': 'A',
|
||||
'value': '3.2.3.4'
|
||||
}))
|
||||
|
||||
plan = provider.plan(wanted)
|
||||
self.assertEquals(2, len(plan.changes))
|
||||
self.assertEquals(2, provider.apply(plan))
|
||||
|
||||
# recreate for update, and deletes for the 2 parts of the other
|
||||
provider._client._request.assert_has_calls([
|
||||
call('POST', '/123123/records', data={
|
||||
'value': '3.2.3.4',
|
||||
'type': 'A',
|
||||
'name': 'ttl',
|
||||
'ttl': 300
|
||||
}),
|
||||
call('DELETE', '/123123/records/11189899'),
|
||||
call('DELETE', '/123123/records/11189897'),
|
||||
call('DELETE', '/123123/records/11189898')
|
||||
], any_order=True)
|
||||
def test_missing(self):
|
||||
with self.assertRaises(ModuleNotFoundError):
|
||||
from octodns.provider.dnsmadeeasy import DnsMadeEasyProvider
|
||||
DnsMadeEasyProvider
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user