forked from jpadilla/django-jwt-auth
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
105 additions
and
16 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
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 |
---|---|---|
|
@@ -2,12 +2,10 @@ | |
from django.test.client import Client | ||
|
||
from jwt_auth import utils | ||
from jwt_auth.compat import User, json | ||
from jwt_auth.compat import User, json, smart_text | ||
|
||
|
||
class JSONWebTokenAuthMixinTestCase(TestCase): | ||
# urls = 'tests.test_mixins' | ||
|
||
def setUp(self): | ||
self.email = '[email protected]' | ||
self.username = 'jpueblo' | ||
|
@@ -37,7 +35,7 @@ def test_post_json_passing_jwt_auth(self): | |
HTTP_AUTHORIZATION=auth | ||
) | ||
|
||
response_content = json.loads(response.content) | ||
response_content = json.loads(smart_text(response.content)) | ||
|
||
self.assertEqual(response.status_code, 200) | ||
self.assertEqual(response_content['username'], self.username) | ||
|
@@ -48,7 +46,7 @@ def test_post_json_failing_jwt_auth(self): | |
""" | ||
response = self.client.post('/jwt/', content_type='application/json') | ||
|
||
response_content = json.loads(response.content) | ||
response_content = json.loads(smart_text(response.content)) | ||
|
||
self.assertEqual(response.status_code, 401) | ||
self.assertEqual(response['WWW-Authenticate'], 'JWT realm="api"') | ||
|
@@ -67,7 +65,7 @@ def test_post_no_jwt_header_failing_jwt_auth(self): | |
HTTP_AUTHORIZATION=auth, | ||
) | ||
|
||
response_content = json.loads(response.content) | ||
response_content = json.loads(smart_text(response.content)) | ||
|
||
self.assertEqual(response.status_code, 401) | ||
self.assertEqual(response['WWW-Authenticate'], 'JWT realm="api"') | ||
|
@@ -86,7 +84,7 @@ def test_post_invalid_jwt_header_failing_jwt_auth(self): | |
HTTP_AUTHORIZATION=auth | ||
) | ||
|
||
response_content = json.loads(response.content) | ||
response_content = json.loads(smart_text(response.content)) | ||
|
||
self.assertEqual(response.status_code, 401) | ||
self.assertEqual(response['WWW-Authenticate'], 'JWT realm="api"') | ||
|
@@ -109,7 +107,7 @@ def test_post_expired_token_failing_jwt_auth(self): | |
HTTP_AUTHORIZATION=auth | ||
) | ||
|
||
response_content = json.loads(response.content) | ||
response_content = json.loads(smart_text(response.content)) | ||
|
||
self.assertEqual(response.status_code, 401) | ||
self.assertEqual(response['WWW-Authenticate'], 'JWT realm="api"') | ||
|
@@ -128,7 +126,7 @@ def test_post_invalid_token_failing_jwt_auth(self): | |
HTTP_AUTHORIZATION=auth | ||
) | ||
|
||
response_content = json.loads(response.content) | ||
response_content = json.loads(smart_text(response.content)) | ||
|
||
self.assertEqual(response.status_code, 401) | ||
self.assertEqual(response['WWW-Authenticate'], 'JWT realm="api"') | ||
|
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 |
---|---|---|
|
@@ -2,12 +2,10 @@ | |
from django.test.client import Client | ||
|
||
from jwt_auth import utils | ||
from jwt_auth.compat import json, User | ||
from jwt_auth.compat import json, User, smart_text | ||
|
||
|
||
class ObtainJSONWebTokenTestCase(TestCase): | ||
# urls = 'tests.test_views' | ||
|
||
def setUp(self): | ||
self.email = '[email protected]' | ||
self.username = 'jpueblo' | ||
|
@@ -32,7 +30,7 @@ def test_jwt_login_json(self): | |
content_type='application/json' | ||
) | ||
|
||
response_content = json.loads(response.content) | ||
response_content = json.loads(smart_text(response.content)) | ||
|
||
decoded_payload = utils.jwt_decode_handler(response_content['token']) | ||
|
||
|
@@ -83,7 +81,7 @@ def test_jwt_login_with_expired_token(self): | |
HTTP_AUTHORIZATION=auth | ||
) | ||
|
||
response_content = json.loads(response.content) | ||
response_content = json.loads(smart_text(response.content)) | ||
|
||
decoded_payload = utils.jwt_decode_handler(response_content['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,86 @@ | ||
[tox] | ||
downloadcache = {toxworkdir}/cache/ | ||
envlist = | ||
py3.4-django1.6,py3.3-django1.6,py3.2-django1.6,py2.7-django1.6,py2.6-django1.6, | ||
py3.4-django1.5,py3.3-django1.5,py3.2-django1.5,py2.7-django1.5,py2.6-django1.5, | ||
py2.7-django1.4,py2.6-django1.4 | ||
|
||
[testenv] | ||
commands = ./runtests.py --fast | ||
|
||
[testenv:flake8] | ||
basepython = python2.7 | ||
deps = Django | ||
-rrequirements.txt | ||
-rrequirements-test.txt | ||
commands = ./runtests.py --lintonly | ||
|
||
[testenv:py3.4-django1.6] | ||
basepython = python3.4 | ||
deps = Django==1.6.3 | ||
|
||
[testenv:py3.3-django1.6] | ||
basepython = python3.3 | ||
deps = Django==1.6.3 | ||
-rrequirements.txt | ||
-rrequirements-test.txt | ||
|
||
[testenv:py3.2-django1.6] | ||
basepython = python3.2 | ||
deps = Django==1.6.3 | ||
-rrequirements.txt | ||
-rrequirements-test.txt | ||
|
||
[testenv:py2.7-django1.6] | ||
basepython = python2.7 | ||
deps = Django==1.6.3 | ||
-rrequirements.txt | ||
-rrequirements-test.txt | ||
|
||
[testenv:py2.6-django1.6] | ||
basepython = python2.6 | ||
deps = Django==1.6.3 | ||
-rrequirements.txt | ||
-rrequirements-test.txt | ||
|
||
[testenv:py3.4-django1.5] | ||
basepython = python3.4 | ||
deps = Django==1.5.6 | ||
-rrequirements.txt | ||
-rrequirements-test.txt | ||
|
||
[testenv:py3.3-django1.5] | ||
basepython = python3.3 | ||
deps = Django==1.5.6 | ||
-rrequirements.txt | ||
-rrequirements-test.txt | ||
|
||
[testenv:py3.2-django1.5] | ||
basepython = python3.2 | ||
deps = Django==1.5.6 | ||
-rrequirements.txt | ||
-rrequirements-test.txt | ||
|
||
[testenv:py2.7-django1.5] | ||
basepython = python2.7 | ||
deps = Django==1.5.6 | ||
-rrequirements.txt | ||
-rrequirements-test.txt | ||
|
||
[testenv:py2.6-django1.5] | ||
basepython = python2.6 | ||
deps = Django==1.5.6 | ||
-rrequirements.txt | ||
-rrequirements-test.txt | ||
|
||
[testenv:py2.7-django1.4] | ||
basepython = python2.7 | ||
deps = Django==1.4.11 | ||
-rrequirements.txt | ||
-rrequirements-test.txt | ||
|
||
[testenv:py2.6-django1.4] | ||
basepython = python2.6 | ||
deps = Django==1.4.11 | ||
-rrequirements.txt | ||
-rrequirements-test.txt |