-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #99 from incuna/invalid-token-401
Return HTTP Bad Request 400 code when the token and uidb64 are not valid
- Loading branch information
Showing
5 changed files
with
37 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from django.utils.translation import ugettext_lazy as _ | ||
from rest_framework import status | ||
from rest_framework.exceptions import APIException | ||
|
||
|
||
class InvalidExpiredToken(APIException): | ||
"""Exception to confirm an account.""" | ||
status_code = status.HTTP_400_BAD_REQUEST | ||
default_detail = _('Invalid or expired token.') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from django.test import TestCase | ||
from rest_framework.status import HTTP_400_BAD_REQUEST | ||
|
||
from ..exceptions import InvalidExpiredToken | ||
|
||
|
||
class InvalidExpiredTokenTest(TestCase): | ||
"""Assert `InvalidExpiredToken` behaves as expected.""" | ||
def test_raise(self): | ||
"""Assert `InvalidExpiredToken` can be raised.""" | ||
with self.assertRaises(InvalidExpiredToken) as error: | ||
raise InvalidExpiredToken | ||
self.assertEqual(error.exception.status_code, HTTP_400_BAD_REQUEST) | ||
message = error.exception.detail.format() | ||
self.assertEqual(message, 'Invalid or expired token.') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters