From 08d8ce472b715c7990c069a37d25db5cbe24ef3f Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sat, 16 Nov 2013 07:23:44 +0100 Subject: [PATCH] added test for nic_update_session --- nsupdate/api/_tests/test_api.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/nsupdate/api/_tests/test_api.py b/nsupdate/api/_tests/test_api.py index ff69f1d..5f2e03b 100644 --- a/nsupdate/api/_tests/test_api.py +++ b/nsupdate/api/_tests/test_api.py @@ -10,6 +10,9 @@ from django.core.urlresolvers import reverse TEST_HOST = "test.nsupdate.info" TEST_SECRET = "secret" +USERNAME = 'test' +PASSWORD = 'pass' + def test_myip(client): response = client.get(reverse('myip')) @@ -43,11 +46,21 @@ def test_nic_update_authorized(client): assert response.content.startswith('good ') or response.content.startswith('nochg ') -def test_nic_update_session(client): +def test_nic_update_session_nosession(client): response = client.get(reverse('nic_update_authorized')) assert response.status_code == 302 # redirects to login view +def test_nic_update_session(client): + client.login(username=USERNAME, password=PASSWORD) + response = client.get(reverse('nic_update_authorized')) + assert response.status_code == 200 + assert response.content == "nohost" # we did not tell which host + response = client.get(reverse('nic_update_authorized') + '?hostname=%s&myip=%s' % (TEST_HOST, '1.2.3.4')) + assert response.status_code == 200 + assert response.content.startswith('good ') or response.content.startswith('nochg ') + + def test_detect_ip(client): response = client.get(reverse('detectip', args=('invalid_session_id', ))) assert response.status_code == 204