-
-
Notifications
You must be signed in to change notification settings - Fork 527
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip #893: some input sanity checks for user API's
- Loading branch information
Showing
5 changed files
with
67 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -84,6 +84,15 @@ def test_submit_empty(self): | |
response = self.client.post('/api/auth/') | ||
self.assertContains(response, 'empty_data', status_code=400) | ||
|
||
def test_submit_invalid(self): | ||
"""login api errors for invalid data""" | ||
response = self.client.post( | ||
'/api/auth/', | ||
'false', | ||
content_type="application/json", | ||
) | ||
self.assertContains(response, "Invalid data.", status_code=400) | ||
|
||
def test_login_banned(self): | ||
"""login api fails to sign banned user in""" | ||
UserModel.objects.create_user('Bob', '[email protected]', 'Pass.123') | ||
|
@@ -279,7 +288,16 @@ def test_submit_empty(self): | |
|
||
self.assertTrue(not mail.outbox) | ||
|
||
def test_submit_invalid(self): | ||
def test_submit_invalid_data(self): | ||
"""login api errors for invalid data""" | ||
response = self.client.post( | ||
self.link, | ||
'false', | ||
content_type="application/json", | ||
) | ||
self.assertContains(response, "Invalid data.", status_code=400) | ||
|
||
def test_submit_invalid_email(self): | ||
"""request activation link api errors for invalid email""" | ||
response = self.client.post( | ||
self.link, | ||
|
@@ -403,6 +421,15 @@ def test_submit_invalid(self): | |
|
||
self.assertTrue(not mail.outbox) | ||
|
||
def test_submit_invalid_data(self): | ||
"""login api errors for invalid data""" | ||
response = self.client.post( | ||
self.link, | ||
'false', | ||
content_type="application/json", | ||
) | ||
self.assertContains(response, "Invalid data.", status_code=400) | ||
|
||
def test_submit_inactive_user(self): | ||
"""request change password form link api errors for inactive users""" | ||
self.user.requires_activation = 1 | ||
|
@@ -462,6 +489,15 @@ def test_submit_with_whitespaces(self): | |
user = UserModel.objects.get(id=self.user.pk) | ||
self.assertTrue(user.check_password(' n3wp4ss! ')) | ||
|
||
def test_submit_invalid_data(self): | ||
"""login api errors for invalid data""" | ||
response = self.client.post( | ||
self.link % (self.user.pk, make_password_change_token(self.user)), | ||
'false', | ||
content_type="application/json", | ||
) | ||
self.assertContains(response, "Invalid data.", status_code=400) | ||
|
||
def test_invalid_token_link(self): | ||
"""api errors on invalid user id link""" | ||
response = self.client.post(self.link % (self.user.pk, 'asda7ad89sa7d9s789as')) | ||
|
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