-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: name field validations (#33429)
- Loading branch information
1 parent
d6e21a1
commit b0f5d1e
Showing
4 changed files
with
62 additions
and
4 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
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 |
---|---|---|
|
@@ -294,6 +294,45 @@ def test_register_fullname_url_validation_error(self): | |
} | ||
) | ||
|
||
# testing for http/https | ||
response = self.client.post(self.url, { | ||
"email": "[email protected]", | ||
"name": "http://", | ||
"username": "bob", | ||
"password": "password", | ||
"honor_code": "true", | ||
}) | ||
assert response.status_code == 400 | ||
response_json = json.loads(response.content.decode('utf-8')) | ||
self.assertDictEqual( | ||
response_json, | ||
{ | ||
"name": [{"user_message": 'Enter a valid name'}], | ||
"error_code": "validation-error" | ||
} | ||
) | ||
|
||
def test_register_fullname_html_validation_error(self): | ||
""" | ||
Test for catching invalid full name errors | ||
""" | ||
response = self.client.post(self.url, { | ||
"email": "[email protected]", | ||
"name": "<Bob Smith>", | ||
"username": "bob", | ||
"password": "password", | ||
"honor_code": "true", | ||
}) | ||
assert response.status_code == 400 | ||
response_json = json.loads(response.content.decode('utf-8')) | ||
self.assertDictEqual( | ||
response_json, | ||
{ | ||
'name': [{'user_message': 'Full Name cannot contain the following characters: < >'}], | ||
"error_code": "validation-error" | ||
} | ||
) | ||
|
||
def test_register_duplicate_username_account_validation_error(self): | ||
# Register the first user | ||
response = self.client.post(self.url, { | ||
|