mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-08 06:14:47 +03:00
Merge 550e9af04a
into a9bbb502cb
This commit is contained in:
commit
38683d304c
|
@ -5,12 +5,14 @@ from __future__ import unicode_literals
|
|||
import base64
|
||||
|
||||
from django.conf.urls import include, url
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.models import AnonymousUser, User
|
||||
from django.db import models
|
||||
from django.http import HttpResponse
|
||||
from django.test import TestCase
|
||||
from django.utils import six
|
||||
|
||||
import pytest
|
||||
|
||||
from rest_framework import (
|
||||
HTTP_HEADER_ENCODING, exceptions, permissions, renderers, status
|
||||
)
|
||||
|
@ -265,6 +267,26 @@ class CustomTokenAuthTests(BaseTokenAuthTests, TestCase):
|
|||
path = '/customtoken/'
|
||||
|
||||
|
||||
class AttributeErrorInAuthenticateTests(TestCase):
|
||||
def test_incorrect_credentials(self):
|
||||
"""
|
||||
Make sure AttributeErrors thrown in .authenticate() are not suppressed.
|
||||
"""
|
||||
class AttributeErrorThrowingAuth(BaseAuthentication):
|
||||
def authenticate(self, request):
|
||||
raise AttributeError('This exception should crash the authentication')
|
||||
|
||||
request = factory.get('/')
|
||||
request.user = AnonymousUser()
|
||||
view = MockView.as_view(
|
||||
authentication_classes=(AttributeErrorThrowingAuth,),
|
||||
permission_classes=()
|
||||
)
|
||||
|
||||
with pytest.raises(AttributeError):
|
||||
view(request)
|
||||
|
||||
|
||||
class IncorrectCredentialsTests(TestCase):
|
||||
def test_incorrect_credentials(self):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue
Block a user