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
c9c383df
Unverified
Commit
c9c383df
authored
May 17, 2017
by
Thomas Achtemichuk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't trim whitespace from authtoken passwords
* Fixes #5148
parent
1ca5a9d0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
1 deletions
+8
-1
rest_framework/authtoken/serializers.py
+2
-1
tests/test_authtoken.py
+6
-0
No files found.
rest_framework/authtoken/serializers.py
View file @
c9c383df
...
@@ -6,7 +6,8 @@ from rest_framework import serializers
...
@@ -6,7 +6,8 @@ from rest_framework import serializers
class
AuthTokenSerializer
(
serializers
.
Serializer
):
class
AuthTokenSerializer
(
serializers
.
Serializer
):
username
=
serializers
.
CharField
(
label
=
_
(
"Username"
))
username
=
serializers
.
CharField
(
label
=
_
(
"Username"
))
password
=
serializers
.
CharField
(
label
=
_
(
"Password"
),
style
=
{
'input_type'
:
'password'
})
password
=
serializers
.
CharField
(
label
=
_
(
"Password"
),
style
=
{
'input_type'
:
'password'
},
trim_whitespace
=
False
)
def
validate
(
self
,
attrs
):
def
validate
(
self
,
attrs
):
username
=
attrs
.
get
(
'username'
)
username
=
attrs
.
get
(
'username'
)
...
...
tests/test_authtoken.py
View file @
c9c383df
...
@@ -27,3 +27,9 @@ class AuthTokenTests(TestCase):
...
@@ -27,3 +27,9 @@ class AuthTokenTests(TestCase):
def
test_validate_raise_error_if_no_credentials_provided
(
self
):
def
test_validate_raise_error_if_no_credentials_provided
(
self
):
with
pytest
.
raises
(
ValidationError
):
with
pytest
.
raises
(
ValidationError
):
AuthTokenSerializer
()
.
validate
({})
AuthTokenSerializer
()
.
validate
({})
def
test_whitespace_in_password
(
self
):
data
=
{
'username'
:
self
.
user
.
username
,
'password'
:
'test pass '
}
self
.
user
.
set_password
(
data
[
'password'
])
self
.
user
.
save
()
assert
AuthTokenSerializer
(
data
=
data
)
.
is_valid
()
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