aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/tests/test_authentication.py
diff options
context:
space:
mode:
authorTom Christie2014-07-26 20:57:28 +0100
committerTom Christie2014-07-26 20:57:28 +0100
commit02187eb2edf34a992bc56da797caded085b1e09a (patch)
tree1c34f45e49da416bd694809b1f6e9c1e708fb047 /rest_framework/tests/test_authentication.py
parent299a8347e8ef448eefc611eebfe80d7e142ceaa1 (diff)
parente3aff6a5678d48a2e328c9bb44b7c3de81caffd5 (diff)
downloaddjango-rest-framework-02187eb2edf34a992bc56da797caded085b1e09a.tar.bz2
Merge pull request #1705 from opbeat/master
Sending "Bearer" and "Bearer " resulted in a 500.
Diffstat (limited to 'rest_framework/tests/test_authentication.py')
-rw-r--r--rest_framework/tests/test_authentication.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/rest_framework/tests/test_authentication.py b/rest_framework/tests/test_authentication.py
index a1c43d9c..34bf2910 100644
--- a/rest_framework/tests/test_authentication.py
+++ b/rest_framework/tests/test_authentication.py
@@ -550,6 +550,15 @@ class OAuth2Tests(TestCase):
self.assertEqual(response.status_code, 401)
@unittest.skipUnless(oauth2_provider, 'django-oauth2-provider not installed')
+ def test_get_form_with_wrong_authorization_header_token_missing(self):
+ """Ensure that a missing token lead to the correct HTTP error status code"""
+ auth = "Bearer"
+ response = self.csrf_client.get('/oauth2-test/', {}, HTTP_AUTHORIZATION=auth)
+ self.assertEqual(response.status_code, 401)
+ response = self.csrf_client.get('/oauth2-test/', HTTP_AUTHORIZATION=auth)
+ self.assertEqual(response.status_code, 401)
+
+ @unittest.skipUnless(oauth2_provider, 'django-oauth2-provider not installed')
def test_get_form_passing_auth(self):
"""Ensure GETing form over OAuth with correct client credentials succeed"""
auth = self._create_authorization_header()