aboutsummaryrefslogtreecommitdiffstats
path: root/djangorestframework/tests/authentication.py
diff options
context:
space:
mode:
authorMjumbe Wawatu Poe2012-09-07 13:15:24 -0400
committerMjumbe Wawatu Poe2012-09-07 13:15:24 -0400
commit5a3874ee112490937f83fa5700899f3631a14128 (patch)
tree9d1c987a5501d3136ef48bbeb1d77a209aa9ec13 /djangorestframework/tests/authentication.py
parentf3e65eab6b60a23eeed2178db4f6034ce2c6ac3d (diff)
downloaddjango-rest-framework-5a3874ee112490937f83fa5700899f3631a14128.tar.bz2
Create a key by default if none is specified
Diffstat (limited to 'djangorestframework/tests/authentication.py')
-rw-r--r--djangorestframework/tests/authentication.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/djangorestframework/tests/authentication.py b/djangorestframework/tests/authentication.py
index 2806da36..fb9996be 100644
--- a/djangorestframework/tests/authentication.py
+++ b/djangorestframework/tests/authentication.py
@@ -146,3 +146,8 @@ class TokenAuthTests(TestCase):
"""Ensure POSTing json over token auth without correct credentials fails"""
response = self.csrf_client.post('/', json.dumps({'example': 'example'}), 'application/json')
self.assertEqual(response.status_code, 403)
+
+ def test_token_has_auto_assigned_key_if_none_provided(self):
+ """Ensure creating a token with no key will auto-assign a key"""
+ token = Token.objects.create(user=self.user)
+ self.assertEqual(len(token.key), 32)