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
1e9e1a5b
Commit
1e9e1a5b
authored
May 18, 2017
by
Xavier Ordoquy
Committed by
GitHub
May 18, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5149 from tomchuk/master
Don't trim whitespace from authtoken passwords
parents
1ca5a9d0
70205cc6
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
1 deletions
+11
-1
rest_framework/authtoken/serializers.py
+5
-1
tests/test_authtoken.py
+6
-0
No files found.
rest_framework/authtoken/serializers.py
View file @
1e9e1a5b
...
@@ -6,7 +6,11 @@ from rest_framework import serializers
...
@@ -6,7 +6,11 @@ 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 @
1e9e1a5b
...
@@ -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