From 8738b135fc65c6dbc50b4a09e8ea97e11271dda4 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Tue, 2 Sep 2014 23:50:39 +0200 Subject: [PATCH] add tests for update/delete api with invalid IPs --- nsupdate/api/_tests/test_api.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/nsupdate/api/_tests/test_api.py b/nsupdate/api/_tests/test_api.py index 3b71ef8..2135ace 100644 --- a/nsupdate/api/_tests/test_api.py +++ b/nsupdate/api/_tests/test_api.py @@ -72,6 +72,20 @@ def test_nic_update_authorized_not_fqdn_username(client): assert response.content == b'notfqdn' +def test_nic_update_authorized_invalid_ip1(client): + response = client.get(reverse('nic_update') + '?myip=1234', + HTTP_AUTHORIZATION=make_basic_auth_header(TEST_HOST, TEST_SECRET)) + assert response.status_code == 200 + assert response.content == b'dnserr' + + +def test_nic_update_authorized_invalid_ip2(client): + response = client.get(reverse('nic_update') + '?myip=%C3%A4%C3%BC%C3%B6', + HTTP_AUTHORIZATION=make_basic_auth_header(TEST_HOST, TEST_SECRET)) + assert response.status_code == 200 + assert response.content == b'dnserr' + + def test_nic_update_authorized(client): response = client.get(reverse('nic_update'), HTTP_AUTHORIZATION=make_basic_auth_header(TEST_HOST, TEST_SECRET)) @@ -184,6 +198,20 @@ def test_nic_update_session_foreign_host(client): assert response.content == b'nohost' +def test_nic_delete_authorized_invalid_ip1(client): + response = client.get(reverse('nic_delete') + '?myip=1234', + HTTP_AUTHORIZATION=make_basic_auth_header(TEST_HOST, TEST_SECRET)) + assert response.status_code == 200 + assert response.content == b'dnserr' + + +def test_nic_delete_authorized_invalid_ip2(client): + response = client.get(reverse('nic_delete') + '?myip=%C3%A4%C3%BC%C3%B6', + HTTP_AUTHORIZATION=make_basic_auth_header(TEST_HOST, TEST_SECRET)) + assert response.status_code == 200 + assert response.content == b'dnserr' + + def test_nic_delete_authorized(client): response = client.get(reverse('nic_update') + '?myip=%s' % ('1.2.3.4', ), HTTP_AUTHORIZATION=make_basic_auth_header(TEST_HOST, TEST_SECRET))