update api: there is no "noauth" return value, it must be "badauth"
This commit is contained in:
parent
89e18d9d65
commit
925ad20405
@ -17,9 +17,10 @@ def test_myip(client):
|
||||
assert response.content in ['127.0.0.1', '::1']
|
||||
|
||||
|
||||
def test_nic_update(client):
|
||||
def test_nic_update_noauth(client):
|
||||
response = client.get(reverse('nic_update'))
|
||||
assert response.status_code == 401
|
||||
assert response.content == "badauth"
|
||||
|
||||
|
||||
def make_basic_auth_header(username, password):
|
||||
@ -27,6 +28,13 @@ def make_basic_auth_header(username, password):
|
||||
return "Basic " + base64.b64encode("%s:%s" % (username, password))
|
||||
|
||||
|
||||
def test_nic_update_badauth(client):
|
||||
response = client.get(reverse('nic_update'),
|
||||
HTTP_AUTHORIZATION=make_basic_auth_header(TEST_HOST, "wrong"))
|
||||
assert response.status_code == 401
|
||||
assert response.content == "badauth"
|
||||
|
||||
|
||||
def test_nic_update_authorized(client):
|
||||
response = client.get(reverse('nic_update'),
|
||||
HTTP_AUTHORIZATION=make_basic_auth_header(TEST_HOST, TEST_SECRET))
|
||||
|
@ -184,7 +184,7 @@ class NicUpdateView(View):
|
||||
auth = request.META.get('HTTP_AUTHORIZATION')
|
||||
if auth is None:
|
||||
logger.warning('%s - received no auth' % (hostname, ))
|
||||
return basic_challenge("authenticate to update DNS", 'noauth')
|
||||
return basic_challenge("authenticate to update DNS", 'badauth')
|
||||
username, password = basic_authenticate(auth)
|
||||
if not check_api_auth(username, password):
|
||||
logger.warning('%s - received bad credentials, username: %s' % (hostname, username, ))
|
||||
|
Loading…
x
Reference in New Issue
Block a user