mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-02 20:54:42 +03:00
Added setter to the auth property
This commit is contained in:
parent
c27295dcbd
commit
125f027d2d
|
@ -188,6 +188,14 @@ class Request(object):
|
||||||
self._user, self._auth = self._authenticate()
|
self._user, self._auth = self._authenticate()
|
||||||
return self._auth
|
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):
|
def _load_data_and_files(self):
|
||||||
"""
|
"""
|
||||||
Parses the request content into self.DATA and self.FILES.
|
Parses the request content into self.DATA and self.FILES.
|
||||||
|
|
|
@ -303,3 +303,11 @@ class TestUserSetter(TestCase):
|
||||||
self.assertFalse(self.request.user.is_anonymous())
|
self.assertFalse(self.request.user.is_anonymous())
|
||||||
logout(self.request)
|
logout(self.request)
|
||||||
self.assertTrue(self.request.user.is_anonymous())
|
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')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user