aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/tests/authentication.py
diff options
context:
space:
mode:
authorMichal Dvorak (cen38289)2012-12-17 16:35:47 +0100
committerMichal Dvorak (cen38289)2012-12-17 17:01:00 +0100
commit8ac77eaae8d6ad01ec8f6de18134c4aa1961d4dd (patch)
treedbdfdf8d3bdb5fd255ff0c9ce7bad75f34b48b19 /rest_framework/tests/authentication.py
parent2a82b64963792b353a7a2634c003692bd4957c9f (diff)
parent70714c234630cd205ed88686ece3b594f387a48f (diff)
downloaddjango-rest-framework-8ac77eaae8d6ad01ec8f6de18134c4aa1961d4dd.tar.bz2
Merge remote-tracking branch 'tom/master'
Conflicts: rest_framework/serializers.py rest_framework/tests/serializer.py
Diffstat (limited to 'rest_framework/tests/authentication.py')
-rw-r--r--rest_framework/tests/authentication.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/rest_framework/tests/authentication.py b/rest_framework/tests/authentication.py
index 802bc6c1..d498ae3e 100644
--- a/rest_framework/tests/authentication.py
+++ b/rest_framework/tests/authentication.py
@@ -1,4 +1,4 @@
-from django.conf.urls.defaults import patterns, include
+from django.conf.urls.defaults import patterns
from django.contrib.auth.models import User
from django.test import Client, TestCase
@@ -27,7 +27,7 @@ MockView.authentication_classes += (TokenAuthentication,)
urlpatterns = patterns('',
(r'^$', MockView.as_view()),
- (r'^auth-token/', 'rest_framework.authtoken.views.obtain_auth_token'),
+ (r'^auth-token/$', 'rest_framework.authtoken.views.obtain_auth_token'),
)
@@ -157,7 +157,7 @@ class TokenAuthTests(TestCase):
def test_token_login_json(self):
"""Ensure token login view using JSON POST works."""
client = Client(enforce_csrf_checks=True)
- response = client.post('/auth-token/login/',
+ response = client.post('/auth-token/',
json.dumps({'username': self.username, 'password': self.password}), 'application/json')
self.assertEqual(response.status_code, 200)
self.assertEqual(json.loads(response.content)['token'], self.key)
@@ -165,21 +165,21 @@ class TokenAuthTests(TestCase):
def test_token_login_json_bad_creds(self):
"""Ensure token login view using JSON POST fails if bad credentials are used."""
client = Client(enforce_csrf_checks=True)
- response = client.post('/auth-token/login/',
+ response = client.post('/auth-token/',
json.dumps({'username': self.username, 'password': "badpass"}), 'application/json')
- self.assertEqual(response.status_code, 401)
+ self.assertEqual(response.status_code, 400)
def test_token_login_json_missing_fields(self):
"""Ensure token login view using JSON POST fails if missing fields."""
client = Client(enforce_csrf_checks=True)
- response = client.post('/auth-token/login/',
+ response = client.post('/auth-token/',
json.dumps({'username': self.username}), 'application/json')
- self.assertEqual(response.status_code, 401)
+ self.assertEqual(response.status_code, 400)
def test_token_login_form(self):
"""Ensure token login view using form POST works."""
client = Client(enforce_csrf_checks=True)
- response = client.post('/auth-token/login/',
+ response = client.post('/auth-token/',
{'username': self.username, 'password': self.password})
self.assertEqual(response.status_code, 200)
self.assertEqual(json.loads(response.content)['token'], self.key)