-
Notifications
You must be signed in to change notification settings - Fork 367
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
孙永强
committed
Aug 15, 2024
1 parent
062f7e9
commit aba4e22
Showing
6 changed files
with
21 additions
and
26 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
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 |
---|---|---|
|
@@ -37,12 +37,12 @@ def test_can_send_email_configured(self): | |
|
||
resp = self.client.post(url, data) | ||
self.assertEqual(200, resp.status_code) | ||
self.assertEqual(len(mail.outbox), 1) | ||
self.assertEqual(len(mail.outbox), 2) | ||
json_resp = json.loads(resp.content) | ||
assert json_resp['success'][0] == self.admin.email | ||
assert json_resp['failed'][0]['email'] == invalid_email | ||
assert 'test.txt' in mail.outbox[0].body | ||
assert mail.outbox[0].from_email == '[email protected]' | ||
assert 'test.txt' in mail.outbox[1].body | ||
assert mail.outbox[1].from_email == '[email protected]' | ||
|
||
@patch('seahub.utils.IS_EMAIL_CONFIGURED', True) | ||
@patch('seahub.api2.endpoints.send_share_link_email.IS_EMAIL_CONFIGURED', True) | ||
|
@@ -57,11 +57,11 @@ def test_can_send_email_rewrite(self): | |
|
||
resp = self.client.post(url, data) | ||
self.assertEqual(200, resp.status_code) | ||
self.assertEqual(len(mail.outbox), 1) | ||
self.assertEqual(len(mail.outbox), 2) | ||
json_resp = json.loads(resp.content) | ||
assert json_resp['success'][0] == self.admin.email | ||
assert 'test.txt' in mail.outbox[0].body | ||
assert mail.outbox[0].extra_headers['Reply-to'] == self.user.email | ||
assert 'test.txt' in mail.outbox[1].body | ||
assert mail.outbox[1].extra_headers['Reply-to'] == self.user.email | ||
|
||
@patch('seahub.utils.IS_EMAIL_CONFIGURED', True) | ||
@patch('seahub.api2.endpoints.send_share_link_email.IS_EMAIL_CONFIGURED', True) | ||
|
@@ -75,7 +75,6 @@ def test_can_send_email_rewrite_contact_email(self): | |
p.save() | ||
|
||
refresh_cache(self.user.email) | ||
|
||
url = reverse("api2-send-share-link") | ||
data = { | ||
"token": self.token, | ||
|
@@ -84,11 +83,12 @@ def test_can_send_email_rewrite_contact_email(self): | |
|
||
resp = self.client.post(url, data) | ||
self.assertEqual(200, resp.status_code) | ||
self.assertEqual(len(mail.outbox), 1) | ||
|
||
self.assertEqual(len(mail.outbox), 2) | ||
json_resp = json.loads(resp.content) | ||
assert json_resp['success'][0] == self.admin.email | ||
assert 'test.txt' in mail.outbox[0].body | ||
assert mail.outbox[0].extra_headers['Reply-to'] == contact_email | ||
assert 'test.txt' in mail.outbox[1].body | ||
assert mail.outbox[1].extra_headers['Reply-to'] == contact_email | ||
|
||
@patch('seahub.utils.IS_EMAIL_CONFIGURED', False) | ||
@patch('seahub.api2.endpoints.send_share_link_email.IS_EMAIL_CONFIGURED', False) | ||
|
@@ -103,7 +103,7 @@ def test_can_send_email_not_configured(self): | |
|
||
resp = self.client.post(url, data) | ||
self.assertEqual(403, resp.status_code) | ||
self.assertEqual(len(mail.outbox), 0) | ||
self.assertEqual(len(mail.outbox), 1) | ||
|
||
def test_can_not_send_email_if_not_link_owner(self): | ||
self.login_as(self.admin) | ||
|
@@ -115,4 +115,4 @@ def test_can_not_send_email_if_not_link_owner(self): | |
|
||
resp = self.client.post(url, data) | ||
self.assertEqual(403, resp.status_code) | ||
self.assertEqual(len(mail.outbox), 0) | ||
self.assertEqual(len(mail.outbox), 1) |
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 |
---|---|---|
|
@@ -26,17 +26,16 @@ def test_can_send_reset_email_to_contact_email(self): | |
p.contact_email = '[email protected]' | ||
p.save() | ||
|
||
self.assertEqual(len(mail.outbox), 0) | ||
self.assertEqual(len(mail.outbox), 1) | ||
|
||
resp = self.client.post( | ||
reverse('user_reset', args=[self.user.email]) | ||
) | ||
self.assertEqual(302, resp.status_code) | ||
|
||
self.assertEqual(len(mail.outbox), 1) | ||
assert mail.outbox[0].to[0] != self.user.username | ||
assert mail.outbox[0].to[0] == '[email protected]' | ||
self.assertEqual(len(mail.outbox), 1) | ||
self.assertEqual(len(mail.outbox), 2) | ||
assert mail.outbox[1].to[0] != self.user.username | ||
assert mail.outbox[1].to[0] == '[email protected]' | ||
self.assertEqual(len(mail.outbox), 2) | ||
|
||
def test_can_reset_when_pwd_change_required(self): | ||
self.config.FORCE_PASSWORD_CHANGE = 1 | ||
|