Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx-platform
Commits
f7659c8b
Commit
f7659c8b
authored
Jun 02, 2016
by
Attiya Ishaque
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #12587 from edx/PLAT-1004-Email-field-lenght
Set the Email field length is 254 characters.
parents
9d3365f0
62b431ea
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
6 deletions
+20
-6
common/djangoapps/student/forms.py
+1
-1
common/djangoapps/student/tests/test_create_account.py
+13
-2
common/djangoapps/student/tests/test_long_username_email.py
+6
-3
No files found.
common/djangoapps/student/forms.py
View file @
f7659c8b
...
...
@@ -131,7 +131,7 @@ class AccountCreationForm(forms.Form):
}
)
email
=
forms
.
EmailField
(
max_length
=
75
,
# Limit per RFCs is 254, but User's email field in django 1.4 only takes 75
max_length
=
254
,
# Limit per RFCs is 254
error_messages
=
{
"required"
:
_EMAIL_INVALID_MSG
,
"invalid"
:
_EMAIL_INVALID_MSG
,
...
...
common/djangoapps/student/tests/test_create_account.py
View file @
f7659c8b
...
...
@@ -388,8 +388,19 @@ class TestCreateAccountValidation(TestCase):
assert_email_error
(
"A properly formatted e-mail is required"
)
# Too long
params
[
"email"
]
=
"this_email_address_has_76_characters_in_it_so_it_is_unacceptable@example.com"
assert_email_error
(
"Email cannot be more than 75 characters long"
)
params
[
"email"
]
=
'{email}@example.com'
.
format
(
email
=
'this_email_address_has_254_characters_in_it_so_it_is_unacceptable'
*
4
)
# Assert that we get error when email has more than 254 characters.
self
.
assertGreater
(
len
(
params
[
'email'
]),
254
)
assert_email_error
(
"Email cannot be more than 254 characters long"
)
# Valid Email
params
[
"email"
]
=
"student@edx.com"
# Assert success on valid email
self
.
assertLess
(
len
(
params
[
"email"
]),
254
)
self
.
assert_success
(
params
)
# Invalid
params
[
"email"
]
=
"not_an_email_address"
...
...
common/djangoapps/student/tests/test_long_username_email.py
View file @
f7659c8b
...
...
@@ -38,17 +38,20 @@ class TestLongUsernameEmail(TestCase):
def
test_long_email
(
self
):
"""
Test email cannot be more than
75
characters long.
Test email cannot be more than
254
characters long.
"""
self
.
url_params
[
'email'
]
=
'{
0}@bar.com'
.
format
(
'foo_bar'
*
15
)
self
.
url_params
[
'email'
]
=
'{
email}@bar.com'
.
format
(
email
=
'foo_bar'
*
36
)
response
=
self
.
client
.
post
(
self
.
url
,
self
.
url_params
)
# Assert that we get error when email has more than 254 characters.
self
.
assertGreater
(
len
(
self
.
url_params
[
'email'
]),
254
)
# Status code should be 400.
self
.
assertEqual
(
response
.
status_code
,
400
)
obj
=
json
.
loads
(
response
.
content
)
self
.
assertEqual
(
obj
[
'value'
],
"Email cannot be more than
75
characters long"
,
"Email cannot be more than
254
characters long"
,
)
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