diff --git a/nsupdate/api/_tests/test_api.py b/nsupdate/api/_tests/test_api.py index 4951c12..dbc6123 100644 --- a/nsupdate/api/_tests/test_api.py +++ b/nsupdate/api/_tests/test_api.py @@ -5,6 +5,7 @@ Tests for api package. from django.core.urlresolvers import reverse from nsupdate.main.dnstools import query_ns +from nsupdate.main.models import Domain TEST_HOST = "test.nsupdate.info" @@ -80,6 +81,16 @@ def test_nic_update_authorized(client): assert response.content.startswith('good ') or response.content.startswith('nochg ') +def test_nic_update_authorized_ns_unavailable(client): + d = Domain.objects.get(domain=TEST_HOST) + d.available = False # simulate DNS unavailability + d.save() + response = client.get(reverse('nic_update'), + HTTP_AUTHORIZATION=make_basic_auth_header(TEST_HOST, TEST_SECRET)) + assert response.status_code == 200 + assert response.content == 'dnserr' + + def test_nic_update_authorized_myip(client): response = client.get(reverse('nic_update') + '?myip=4.3.2.1', HTTP_AUTHORIZATION=make_basic_auth_header(TEST_HOST, TEST_SECRET)) diff --git a/nsupdate/api/views.py b/nsupdate/api/views.py index 478d83f..a23e91b 100644 --- a/nsupdate/api/views.py +++ b/nsupdate/api/views.py @@ -311,4 +311,4 @@ def _update(host, hostname, ipaddr, ssl=False, logger=None): logger.error('%s - received update that resulted in a dns error [%s], ip: %s ssl: %r' % ( hostname, msg, ipaddr, ssl)) host.register_server_fault() - return Response('dnserr %s' % msg) + return Response('dnserr')