-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add regression checks on email validator.
This is mostly to ensure that it rejects domains (other than "localhost") without dots in them.
- Loading branch information
1 parent
d217015
commit 9033b91
Showing
3 changed files
with
19 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,25 +49,30 @@ def test_email_validation(self): | |
"[email protected]", | ||
"[email protected]", | ||
"[email protected]", | ||
"test@localhost", # Django's default validator allows this one. | ||
): | ||
user_data = self.valid_data.copy() | ||
user_data["email"] = value | ||
form = forms.RegistrationForm(data=user_data) | ||
assert form.is_valid() | ||
with self.subTest(value=value): | ||
user_data = self.valid_data.copy() | ||
user_data["email"] = value | ||
form = forms.RegistrationForm(data=user_data) | ||
assert form.is_valid() | ||
for value in ( | ||
"@@@example.com", | ||
"test:test@[email protected]", | ||
'test"test@example"[email protected]', | ||
"test@example", | ||
"test@1234", | ||
): | ||
user_data = self.valid_data.copy() | ||
user_data["email"] = value | ||
form = forms.RegistrationForm(data=user_data) | ||
assert not form.is_valid() | ||
assert form.has_error(user_model.get_email_field_name()) | ||
assert ( | ||
str(validators.HTML5EmailValidator.message) | ||
in form.errors[user_model.get_email_field_name()] | ||
) | ||
with self.subTest(value=value): | ||
user_data = self.valid_data.copy() | ||
user_data["email"] = value | ||
form = forms.RegistrationForm(data=user_data) | ||
assert not form.is_valid() | ||
assert form.has_error(user_model.get_email_field_name()) | ||
assert ( | ||
str(validators.HTML5EmailValidator.message) | ||
in form.errors[user_model.get_email_field_name()] | ||
) | ||
|
||
def test_email_validated_once(self): | ||
""" | ||
|