-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Fix API v2 exception on incorrect API key. Fixes #5425 * Update changelog * Fix authentication endpoint * Test bad auth conditions * Fix RESTful and non-RESTful error handling * Fix API pagination This reverts commit b291939. * Fix Tornado request logging - Fix requests getting logged twice. - Fix API v2 HTTPErrors getting logged as warnings. * Fix `write_error` for `raise HTTPError(code, message)`
- Loading branch information
Showing
4 changed files
with
77 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# coding=utf-8 | ||
"""Test /authentication route and authentication checks.""" | ||
from __future__ import unicode_literals | ||
|
||
import json | ||
|
||
import pytest | ||
|
||
|
||
@pytest.mark.gen_test | ||
def test_no_api_key(http_client, create_url): | ||
# given | ||
expected = {'error': 'No authorization token.'} | ||
|
||
url = create_url('/log', api_key=None) | ||
|
||
# when | ||
response = yield http_client.fetch(url, raise_error=False) | ||
|
||
# then | ||
assert response.code == 401 | ||
assert expected == json.loads(response.body) | ||
|
||
|
||
@pytest.mark.gen_test | ||
def test_bad_api_key(http_client, create_url): | ||
# given | ||
expected = {'error': 'No authorization token.'} | ||
|
||
url = create_url('/log', api_key='123') | ||
|
||
# when | ||
response = yield http_client.fetch(url, raise_error=False) | ||
|
||
# then | ||
assert response.code == 401 | ||
assert expected == json.loads(response.body) |