Проверять аутентификацию раньше валидации тела запроса
This commit is contained in:
@@ -99,6 +99,12 @@ class BearerTest(unittest.TestCase):
|
||||
self.assertBearerChallenge({'Authorization': 'Bearer ' + uuid.uuid4().hex})
|
||||
self.assertBearerChallenge({'Authorization': 'Bearer'})
|
||||
|
||||
def test_authentication_before_validation(self):
|
||||
"""Аноним с битым JSON на защищённом endpoint получает 401, а не 400; с сессией — 400"""
|
||||
self.assertEqual(call('POST', '/api/v1/chats', raw=b'{bad')[0], 401)
|
||||
self.assertEqual(call('POST', '/api/v1/chats', raw=b'{bad', token=self.alice['token'])[0], 400)
|
||||
self.assertEqual(call('POST', '/api/v1/users', raw=b'{bad')[0], 400)
|
||||
|
||||
def test_scheme_is_case_insensitive(self):
|
||||
"""Схема аутентификации нечувствительна к регистру (RFC 9110)"""
|
||||
status, _, me = call('GET', '/api/v1/users/me', headers={'Authorization': 'bearer ' + self.alice['token']})
|
||||
|
||||
Reference in New Issue
Block a user