mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 17:47:04 +03:00
Rename to force_authenticate
This commit is contained in:
parent
ab799ccc3e
commit
c9485c783a
|
@ -109,7 +109,7 @@ class APIClient(APIRequestFactory, DjangoClient):
|
||||||
"""
|
"""
|
||||||
self._credentials = kwargs
|
self._credentials = kwargs
|
||||||
|
|
||||||
def authenticate(self, user=None, token=None):
|
def force_authenticate(self, user=None, token=None):
|
||||||
"""
|
"""
|
||||||
Forcibly authenticates outgoing requests with the given
|
Forcibly authenticates outgoing requests with the given
|
||||||
user and/or token.
|
user and/or token.
|
||||||
|
|
|
@ -37,12 +37,12 @@ class CheckTestClient(TestCase):
|
||||||
response = self.client.get('/view/')
|
response = self.client.get('/view/')
|
||||||
self.assertEqual(response.data['auth'], 'example')
|
self.assertEqual(response.data['auth'], 'example')
|
||||||
|
|
||||||
def test_authenticate(self):
|
def test_force_authenticate(self):
|
||||||
"""
|
"""
|
||||||
Setting `.authenticate()` forcibly authenticates each request.
|
Setting `.force_authenticate()` forcibly authenticates each request.
|
||||||
"""
|
"""
|
||||||
user = User.objects.create_user('example', 'example@example.com')
|
user = User.objects.create_user('example', 'example@example.com')
|
||||||
self.client.authenticate(user)
|
self.client.force_authenticate(user)
|
||||||
response = self.client.get('/view/')
|
response = self.client.get('/view/')
|
||||||
self.assertEqual(response.data['user'], 'example')
|
self.assertEqual(response.data['user'], 'example')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user