Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
606c20f0
Commit
606c20f0
authored
Nov 22, 2012
by
Xavier Ordoquy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
6 first tests passes under python 3.2
parent
49f8e641
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
5 additions
and
5 deletions
+5
-5
rest_framework/authentication.py
+1
-1
rest_framework/request.py
+1
-1
rest_framework/tests/authentication.py
+2
-2
rest_framework/utils/mediatypes.py
+1
-1
No files found.
rest_framework/authentication.py
View file @
606c20f0
...
@@ -40,7 +40,7 @@ class BasicAuthentication(BaseAuthentication):
...
@@ -40,7 +40,7 @@ class BasicAuthentication(BaseAuthentication):
auth
=
request
.
META
[
'HTTP_AUTHORIZATION'
]
.
split
()
auth
=
request
.
META
[
'HTTP_AUTHORIZATION'
]
.
split
()
if
len
(
auth
)
==
2
and
auth
[
0
]
.
lower
()
==
"basic"
:
if
len
(
auth
)
==
2
and
auth
[
0
]
.
lower
()
==
"basic"
:
try
:
try
:
auth_parts
=
base64
.
b64decode
(
auth
[
1
])
.
partition
(
':'
)
auth_parts
=
base64
.
b64decode
(
auth
[
1
]
.
encode
(
'utf8'
))
.
decode
(
'utf8'
)
.
partition
(
':'
)
except
TypeError
:
except
TypeError
:
return
None
return
None
...
...
rest_framework/request.py
View file @
606c20f0
...
@@ -20,7 +20,7 @@ def is_form_media_type(media_type):
...
@@ -20,7 +20,7 @@ def is_form_media_type(media_type):
"""
"""
Return True if the media type is a valid form media type.
Return True if the media type is a valid form media type.
"""
"""
base_media_type
,
params
=
parse_header
(
media_type
)
base_media_type
,
params
=
parse_header
(
media_type
.
encode
(
'utf8'
)
)
return
(
base_media_type
==
'application/x-www-form-urlencoded'
or
return
(
base_media_type
==
'application/x-www-form-urlencoded'
or
base_media_type
==
'multipart/form-data'
)
base_media_type
==
'multipart/form-data'
)
...
...
rest_framework/tests/authentication.py
View file @
606c20f0
...
@@ -44,13 +44,13 @@ class BasicAuthTests(TestCase):
...
@@ -44,13 +44,13 @@ class BasicAuthTests(TestCase):
def
test_post_form_passing_basic_auth
(
self
):
def
test_post_form_passing_basic_auth
(
self
):
"""Ensure POSTing json over basic auth with correct credentials passes and does not require CSRF"""
"""Ensure POSTing json over basic auth with correct credentials passes and does not require CSRF"""
auth
=
b
'Basic '
+
base64
.
encodestring
((
'
%
s:
%
s'
%
(
self
.
username
,
self
.
password
))
.
encode
(
'utf8'
))
.
strip
(
)
auth
=
'Basic '
+
base64
.
encodestring
((
'
%
s:
%
s'
%
(
self
.
username
,
self
.
password
))
.
encode
(
'utf8'
))
.
strip
()
.
decode
(
'utf8'
)
response
=
self
.
csrf_client
.
post
(
'/'
,
{
'example'
:
'example'
},
HTTP_AUTHORIZATION
=
auth
)
response
=
self
.
csrf_client
.
post
(
'/'
,
{
'example'
:
'example'
},
HTTP_AUTHORIZATION
=
auth
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
status_code
,
200
)
def
test_post_json_passing_basic_auth
(
self
):
def
test_post_json_passing_basic_auth
(
self
):
"""Ensure POSTing form over basic auth with correct credentials passes and does not require CSRF"""
"""Ensure POSTing form over basic auth with correct credentials passes and does not require CSRF"""
auth
=
b
'Basic
%
s'
%
base64
.
encodestring
((
'
%
s:
%
s'
%
(
self
.
username
,
self
.
password
))
.
encode
(
'utf8'
))
.
strip
(
)
auth
=
'Basic '
+
base64
.
encodestring
((
'
%
s:
%
s'
%
(
self
.
username
,
self
.
password
))
.
encode
(
'utf8'
))
.
strip
()
.
decode
(
'utf8'
)
response
=
self
.
csrf_client
.
post
(
'/'
,
json
.
dumps
({
'example'
:
'example'
}),
'application/json'
,
HTTP_AUTHORIZATION
=
auth
)
response
=
self
.
csrf_client
.
post
(
'/'
,
json
.
dumps
({
'example'
:
'example'
}),
'application/json'
,
HTTP_AUTHORIZATION
=
auth
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
status_code
,
200
)
...
...
rest_framework/utils/mediatypes.py
View file @
606c20f0
...
@@ -47,7 +47,7 @@ class _MediaType(object):
...
@@ -47,7 +47,7 @@ class _MediaType(object):
if
media_type_str
is
None
:
if
media_type_str
is
None
:
media_type_str
=
''
media_type_str
=
''
self
.
orig
=
media_type_str
self
.
orig
=
media_type_str
self
.
full_type
,
self
.
params
=
parse_header
(
media_type_str
)
self
.
full_type
,
self
.
params
=
parse_header
(
media_type_str
.
encode
(
'utf8'
)
)
self
.
main_type
,
sep
,
self
.
sub_type
=
self
.
full_type
.
partition
(
'/'
)
self
.
main_type
,
sep
,
self
.
sub_type
=
self
.
full_type
.
partition
(
'/'
)
def
match
(
self
,
other
):
def
match
(
self
,
other
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment