Add a test for inactive users with token auth.

This commit is contained in:
Alexander Schrijver 2016-09-27 18:13:10 +02:00
parent b82ec540ad
commit 10be6439a9

View File

@ -349,6 +349,25 @@ class TokenAuthTests(BaseTokenAuthTests, TestCase):
format='json' format='json'
) )
self.assertEqual(response.status_code, 400) self.assertEqual(response.status_code, 400)
self.assertEqual(response.data['non_field_errors'],
[u'Unable to log in with provided credentials.', ])
def test_token_login_json_inactive_user(self):
"""
Ensure token login view using JSON POST fails if
an inactive user is given.
"""
self.user.is_active = False
self.user.save()
client = APIClient(enforce_csrf_checks=True)
response = client.post(
'/auth-token/',
{'username': self.username, 'password': self.password},
format='json'
)
self.assertEqual(response.status_code, 400)
self.assertEqual(response.data['non_field_errors'],
[u'User account is disabled.', ])
def test_token_login_json_missing_fields(self): def test_token_login_json_missing_fields(self):
"""Ensure token login view using JSON POST fails if missing fields.""" """Ensure token login view using JSON POST fails if missing fields."""