-
Notifications
You must be signed in to change notification settings - Fork 284
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added check for email provider check before sending email
- Loading branch information
1 parent
08f0c72
commit ee5f329
Showing
2 changed files
with
42 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,6 +127,34 @@ def test_forgot_password_with_valid_input(self): | |
self.assertEqual(response.status_code, status.HTTP_200_OK) | ||
self.assertTrue(ResetPasswordToken.objects.filter(user=self.user).exists()) | ||
|
||
@override_settings(IS_PRODUCTION=True) | ||
def test_forgot_password_without_email_configration(self): | ||
response = self.client.post( | ||
"/api/v1/password_reset/", | ||
{"username": self.user.username}, | ||
) | ||
|
||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) | ||
self.assertEqual( | ||
response.json()["detail"][0], | ||
"There was a problem resetting your password. Please contact the administrator.", | ||
) | ||
|
||
@override_settings( | ||
IS_PRODUCTION=True, | ||
EMAIL_HOST="smtp.gmail.com", | ||
EMAIL_HOST_USER="[email protected]", | ||
EMAIL_HOST_PASSWORD="your-app-password", | ||
) | ||
def test_forgot_password_with_email_configration(self): | ||
response = self.client.post( | ||
"/api/v1/password_reset/", | ||
{"username": self.user.username}, | ||
) | ||
|
||
self.assertEqual(response.status_code, status.HTTP_200_OK) | ||
self.assertTrue(ResetPasswordToken.objects.filter(user=self.user).exists()) | ||
|
||
def test_forgot_password_with_missing_fields(self): | ||
response = self.client.post("/api/v1/password_reset/") | ||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) | ||
|