2
0
mirror of https://github.com/VinylDNS/vinyldns synced 2025-08-31 14:25:30 +00:00

Test DDNS connectivity when connecting to a zone (#140)

* Add DDNS connectivity check when validating zone connections.

* Add unit tests for DDNS connectivity test.

* Update functional tests for DDNS connectivity test.

* Update create zone documentation with DDNS connectivity information.

* Updates based on feedback (pauljamescleary).

* Convert TSIG key algoritm from default HMAC-MD5 to HMAC-SHA512.

* Updates based on feedback.
This commit is contained in:
Michael Ly
2018-08-30 18:17:55 -04:00
committed by GitHub
parent ed6144b805
commit c7555ebb42
28 changed files with 191 additions and 80 deletions

View File

@@ -17,10 +17,6 @@ def pytest_addoption(parser):
help="The ip address for the dns server to use for the tests")
parser.addoption("--dns-zone", dest="dns_zone", action="store", default="vinyldns.",
help="The zone name that will be used for testing")
parser.addoption("--dns-key-name", dest="dns_key_name", action="store", default="vinyldns.",
help="The name of the key used to sign updates for the zone")
parser.addoption("--dns-key", dest="dns_key", action="store", default="nzisn+4G2ldMn0q1CV3vsg==",
help="The tsig key")
# optional
parser.addoption("--basic-auth", dest="basic_auth_creds",
@@ -62,8 +58,6 @@ def pytest_configure(config):
VinylDNSTestContext.configure(config.getoption("dns_ip"),
config.getoption("dns_zone"),
config.getoption("dns_key_name"),
config.getoption("dns_key"),
config.getoption("url"))
def pytest_report_header(config):

View File

@@ -7,7 +7,7 @@ from vinyldns_context import VinylDNSTestContext
from utils import *
records_in_dns = [
{'name': 'one-time.',
{'name': 'vinyldns.',
'type': 'SOA',
'records': [{u'mname': u'172.17.42.1.',
u'rname': u'admin.test.com.',
@@ -16,7 +16,7 @@ records_in_dns = [
u'minimum': 38400,
u'expire': 604800,
u'serial': 1439234395}]},
{'name': u'one-time.',
{'name': u'vinyldns.',
'type': u'NS',
'records': [{u'nsdname': u'172.17.42.1.'}]},
{'name': u'jenkins',
@@ -28,21 +28,21 @@ records_in_dns = [
{'name': u'test',
'type': u'A',
'records': [{u'address': u'3.3.3.3'}, {u'address': u'4.4.4.4'}]},
{'name': u'one-time.',
{'name': u'vinyldns.',
'type': u'A',
'records': [{u'address': u'5.5.5.5'}]},
{'name': u'already-exists',
'type': u'A',
'records': [{u'address': u'6.6.6.6'}]}]
def test_create_zone_success(shared_zone_test_context):
def test_create_zone_success_with_existing_test_ddns_record(shared_zone_test_context):
"""
Test successfully creating a zone
"""
client = shared_zone_test_context.ok_vinyldns_client
result_zone = None
try:
zone_name = 'one-time'
zone_name = 'vinyldns'
zone = {
'name': zone_name,
@@ -77,16 +77,41 @@ def test_create_zone_success(shared_zone_test_context):
# confirm that the recordsets in DNS have been saved in vinyldns
recordsets = client.list_recordsets(result_zone['id'])['recordSets']
assert_that(len(recordsets), is_(7))
assert_that(len(recordsets), is_(len(records_in_dns)))
for rs in recordsets:
small_rs = dict((k, rs[k]) for k in ['name', 'type', 'records'])
small_rs['records'] = sorted(small_rs['records'])
assert_that(records_in_dns, has_item(small_rs))
if small_rs['type'] == 'SOA':
assert_that(small_rs['name'], is_('vinyldns.'))
else:
assert_that(records_in_dns, has_item(small_rs))
finally:
if result_zone:
dns_add(result_zone, "vinyldns-ddns-connectivity-test", 86400, "TXT", "random existing text")
client.abandon_zones([result_zone['id']], status=202)
def test_create_zone_with_unauthorized_tsig_key_fails(shared_zone_test_context):
"""
Test that creating a zone with a TSIG key that is not primed for allowing updates fails
"""
client = shared_zone_test_context.ok_vinyldns_client
zone_name = 'vinyldns'
zone = {
'name': zone_name,
'email': 'test@test.com',
'adminGroupId': shared_zone_test_context.ok_group['id'],
'connection': {
'name': 'vinyldns-no-updates',
'keyName': VinylDNSTestContext.dns_no_updates_key_name,
'key': VinylDNSTestContext.dns_no_updates_key,
'primaryServer': VinylDNSTestContext.dns_ip
}
}
error = client.create_zone(zone, status=400)
assert_that(error, starts_with('Unable to apply changes in zone'))
@pytest.mark.skip_production
def test_create_zone_without_transfer_connection_leaves_it_empty(shared_zone_test_context):

View File

@@ -104,7 +104,7 @@ def dns_do_command(zone, record_name, record_type, command, ttl=0, rdata=""):
print "updating " + fqdn + " to have data " + rdata
update = dns.update.Update(zone['name'], keyring=keyring)
update = dns.update.Update(zone['name'], keyring=keyring, keyalgorithm=dns.tsig.HMAC_SHA512)
if (command == 'add'):
update.add(fqdn, ttl, record_type, rdata)
elif (command == 'update'):

View File

@@ -4,13 +4,13 @@ class VinylDNSTestContext:
dns_rev_v4_zone_name = '30.172.in-addr.arpa.'
dns_rev_v6_zone_name = '1.9.e.f.c.c.7.2.9.6.d.f.ip6.arpa.'
dns_key_name = 'vinyldns.'
dns_key = 'nzisn+4G2ldMn0q1CV3vsg=='
dns_key = 'wCZZS9lyRr77+jqfnkZ/92L9fD5ilmfrG0sslc3mgmTFsF1fRgmtJ0rj RkFITt8VHQ37wvM/nI9MAIWXYTvMqg=='
dns_no_updates_key_name = 'vinyldns-no-updates'
dns_no_updates_key = '1GOhWm/nwqlQop1YQ6sl96eVTjULth0E7LonKB6X4uycygaCUQRG2JPQ kHVFgp768cyUuCv4j/tvL8C+cUCkcA=='
vinyldns_url = 'http://localhost:9000'
@staticmethod
def configure(ip, zone, key_name, key, url):
def configure(ip, zone, url):
VinylDNSTestContext.dns_ip = ip
VinylDNSTestContext.dns_zone_name = zone
VinylDNSTestContext.dns_key_name = key_name
VinylDNSTestContext.dns_key = key
VinylDNSTestContext.vinyldns_url = url