Browse files

Added setter to the auth property

  • Loading branch information...
1 parent c27295d commit 125f027d2d124e2a483406d9d70e447b8634350c Mark Hughes committed Dec 20, 2012
Showing with 16 additions and 0 deletions.
  1. +8 −0 rest_framework/request.py
  2. +8 −0 rest_framework/tests/request.py
View
8 rest_framework/request.py
@@ -188,6 +188,14 @@ def auth(self):
self._user, self._auth = self._authenticate()
return self._auth
+ @auth.setter
+ def auth(self, value):
+ """
+ Sets any non-user authentication information associated with the
+ request, such as an authentication token.
+ """
+ self._auth = value
+
def _load_data_and_files(self):
"""
Parses the request content into self.DATA and self.FILES.
View
8 rest_framework/tests/request.py
@@ -303,3 +303,11 @@ def test_user_can_logout(self):
self.assertFalse(self.request.user.is_anonymous())
logout(self.request)
self.assertTrue(self.request.user.is_anonymous())
+
+
+class TestAuthSetter(TestCase):
+
+ def test_auth_can_be_set(self):
+ request = Request(factory.get('/'))
+ request.auth = 'DUMMY'
+ self.assertEqual(request.auth, 'DUMMY')

0 comments on commit 125f027

Please sign in to comment.