diff options
| author | Tom Christie | 2013-02-01 11:58:55 +0000 |
|---|---|---|
| committer | Tom Christie | 2013-02-01 11:58:55 +0000 |
| commit | d9c7b1c58523d63c8118d88f44ebfdf5f35e942a (patch) | |
| tree | 6efc5a04556b1800756034791ce8aed082f25d4d /rest_framework/tests/authentication.py | |
| parent | 8021bb5d5089955b171173e60dcc0968e13d29ea (diff) | |
| parent | 0f0e76d8b1b7a7a28b4ce2c6d8f7ecc89e7219ff (diff) | |
| download | django-rest-framework-d9c7b1c58523d63c8118d88f44ebfdf5f35e942a.tar.bz2 | |
Merge branch 'p3k' of https://github.com/linovia/django-rest-framework into working
Conflicts:
rest_framework/authentication.py
rest_framework/relations.py
rest_framework/serializers.py
rest_framework/settings.py
rest_framework/tests/authentication.py
rest_framework/tests/genericrelations.py
rest_framework/tests/generics.py
rest_framework/tests/relations_hyperlink.py
rest_framework/tests/relations_nested.py
rest_framework/tests/relations_pk.py
rest_framework/tests/serializer.py
Diffstat (limited to 'rest_framework/tests/authentication.py')
| -rw-r--r-- | rest_framework/tests/authentication.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/rest_framework/tests/authentication.py b/rest_framework/tests/authentication.py index 1f17e8d2..ba2042cb 100644 --- a/rest_framework/tests/authentication.py +++ b/rest_framework/tests/authentication.py @@ -1,7 +1,6 @@ from django.contrib.auth.models import User from django.http import HttpResponse from django.test import Client, TestCase - from rest_framework import permissions from rest_framework.authtoken.models import Token from rest_framework.authentication import TokenAuthentication, BasicAuthentication, SessionAuthentication @@ -42,13 +41,13 @@ class BasicAuthTests(TestCase): def test_post_form_passing_basic_auth(self): """Ensure POSTing json over basic auth with correct credentials passes and does not require CSRF""" - auth = 'Basic %s' % base64.encodestring('%s:%s' % (self.username, self.password)).strip() + auth = 'Basic %s' % base64.encodestring('%s:%s' % (self.username, self.password)).encode('iso-8859-1').strip().decode('iso-8859-1') response = self.csrf_client.post('/basic/', {'example': 'example'}, HTTP_AUTHORIZATION=auth) self.assertEqual(response.status_code, 200) def test_post_json_passing_basic_auth(self): """Ensure POSTing form over basic auth with correct credentials passes and does not require CSRF""" - auth = 'Basic %s' % base64.encodestring('%s:%s' % (self.username, self.password)).strip() + auth = 'Basic %s' % base64.encodestring('%s:%s' % (self.username, self.password)).encode('iso-8859-1').strip().decode('iso-8859-1') response = self.csrf_client.post('/basic/', json.dumps({'example': 'example'}), 'application/json', HTTP_AUTHORIZATION=auth) self.assertEqual(response.status_code, 200) @@ -159,7 +158,7 @@ class TokenAuthTests(TestCase): response = client.post('/auth-token/', json.dumps({'username': self.username, 'password': self.password}), 'application/json') self.assertEqual(response.status_code, 200) - self.assertEqual(json.loads(response.content)['token'], self.key) + self.assertEqual(json.loads(response.content.decode('ascii'))['token'], self.key) def test_token_login_json_bad_creds(self): """Ensure token login view using JSON POST fails if bad credentials are used.""" @@ -181,4 +180,4 @@ class TokenAuthTests(TestCase): response = client.post('/auth-token/', {'username': self.username, 'password': self.password}) self.assertEqual(response.status_code, 200) - self.assertEqual(json.loads(response.content)['token'], self.key) + self.assertEqual(json.loads(response.content.decode('ascii'))['token'], self.key) |
