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
47f2f7de
Commit
47f2f7de
authored
May 31, 2016
by
attiyaishaque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set the Email field length is 254 characters.
parent
c681c567
Hide 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 @
47f2f7de
...
@@ -131,7 +131,7 @@ class AccountCreationForm(forms.Form):
...
@@ -131,7 +131,7 @@ class AccountCreationForm(forms.Form):
}
}
)
)
email
=
forms
.
EmailField
(
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
=
{
error_messages
=
{
"required"
:
_EMAIL_INVALID_MSG
,
"required"
:
_EMAIL_INVALID_MSG
,
"invalid"
:
_EMAIL_INVALID_MSG
,
"invalid"
:
_EMAIL_INVALID_MSG
,
...
...
common/djangoapps/student/tests/test_create_account.py
View file @
47f2f7de
...
@@ -388,8 +388,19 @@ class TestCreateAccountValidation(TestCase):
...
@@ -388,8 +388,19 @@ class TestCreateAccountValidation(TestCase):
assert_email_error
(
"A properly formatted e-mail is required"
)
assert_email_error
(
"A properly formatted e-mail is required"
)
# Too long
# Too long
params
[
"email"
]
=
"this_email_address_has_76_characters_in_it_so_it_is_unacceptable@example.com"
params
[
"email"
]
=
'{email}@example.com'
.
format
(
assert_email_error
(
"Email cannot be more than 75 characters long"
)
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
# Invalid
params
[
"email"
]
=
"not_an_email_address"
params
[
"email"
]
=
"not_an_email_address"
...
...
common/djangoapps/student/tests/test_long_username_email.py
View file @
47f2f7de
...
@@ -38,17 +38,20 @@ class TestLongUsernameEmail(TestCase):
...
@@ -38,17 +38,20 @@ class TestLongUsernameEmail(TestCase):
def
test_long_email
(
self
):
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
)
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.
# Status code should be 400.
self
.
assertEqual
(
response
.
status_code
,
400
)
self
.
assertEqual
(
response
.
status_code
,
400
)
obj
=
json
.
loads
(
response
.
content
)
obj
=
json
.
loads
(
response
.
content
)
self
.
assertEqual
(
self
.
assertEqual
(
obj
[
'value'
],
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