diff --git a/tests/seahub/share/views/test_send_shared_link.py b/tests/seahub/share/views/test_send_shared_link.py
new file mode 100644
index 0000000000..cbf8bae458
--- /dev/null
+++ b/tests/seahub/share/views/test_send_shared_link.py
@@ -0,0 +1,50 @@
+from mock import patch
+from django.core import mail
+from django.core.urlresolvers import reverse
+from django.test import override_settings
+
+from seahub.test_utils import BaseTestCase
+
+
+class SendSharedLinkTest(BaseTestCase):
+ def setUp(self):
+ mail.outbox = []
+
+ @override_settings(DEFAULT_FROM_EMAIL='from_noreply@seafile.com')
+ @patch('seahub.share.views.IS_EMAIL_CONFIGURED', True)
+ def test_can_send(self):
+ self.login_as(self.user)
+
+ resp = self.client.post(reverse('send_shared_link'), {
+ 'email': self.user.email,
+ 'file_shared_link': 'http://xxx',
+ 'file_shared_name': 'xxx',
+ 'file_shared_type': 'd',
+ 'extra_msg': ''
+ }, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
+
+ self.assertEqual(200, resp.status_code)
+ self.assertEqual(len(mail.outbox), 1)
+ assert 'http://xxx' in mail.outbox[0].body
+ assert mail.outbox[0].from_email == 'from_noreply@seafile.com'
+
+ @patch('seahub.share.views.REPLACE_FROM_EMAIL', True)
+ @patch('seahub.share.views.ADD_REPLY_TO_HEADER', True)
+ @patch('seahub.share.views.IS_EMAIL_CONFIGURED', True)
+ @patch('seahub.utils.IS_EMAIL_CONFIGURED', True)
+ def test_can_send_from_replyto_rewrite(self):
+ self.login_as(self.user)
+
+ resp = self.client.post(reverse('send_shared_link'), {
+ 'email': self.user.email,
+ 'file_shared_link': 'http://xxx',
+ 'file_shared_name': 'xxx',
+ 'file_shared_type': 'd',
+ 'extra_msg': ''
+ }, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
+
+ self.assertEqual(200, resp.status_code)
+ self.assertEqual(len(mail.outbox), 1)
+ assert 'http://xxx' in mail.outbox[0].body
+ assert mail.outbox[0].from_email == self.user.email
+ assert mail.outbox[0].extra_headers['Reply-to'] == self.user.email
diff --git a/tests/seahub/share/views/test_send_shared_upload_link.py b/tests/seahub/share/views/test_send_shared_upload_link.py
index 8fde10dfa1..d98254b413 100644
--- a/tests/seahub/share/views/test_send_shared_upload_link.py
+++ b/tests/seahub/share/views/test_send_shared_upload_link.py
@@ -1,6 +1,7 @@
from mock import patch
from django.core import mail
from django.core.urlresolvers import reverse
+from django.test import override_settings
from seahub.test_utils import BaseTestCase
@@ -9,6 +10,7 @@ class SendSharedUploadLinkTest(BaseTestCase):
def setUp(self):
mail.outbox = []
+ @override_settings(DEFAULT_FROM_EMAIL='from_noreply@seafile.com')
@patch('seahub.share.views.IS_EMAIL_CONFIGURED', True)
def test_can_send(self):
self.login_as(self.user)
@@ -22,3 +24,23 @@ class SendSharedUploadLinkTest(BaseTestCase):
self.assertEqual(200, resp.status_code)
self.assertEqual(len(mail.outbox), 1)
assert 'http://xxx' in mail.outbox[0].body
+ assert mail.outbox[0].from_email == 'from_noreply@seafile.com'
+
+ @patch('seahub.share.views.REPLACE_FROM_EMAIL', True)
+ @patch('seahub.share.views.ADD_REPLY_TO_HEADER', True)
+ @patch('seahub.share.views.IS_EMAIL_CONFIGURED', True)
+ @patch('seahub.utils.IS_EMAIL_CONFIGURED', True)
+ def test_can_send_from_replyto_rewrite(self):
+ self.login_as(self.user)
+
+ resp = self.client.post(reverse('send_shared_upload_link'), {
+ 'email': self.user.email,
+ 'shared_upload_link': 'http://xxx',
+ 'extra_msg': ''
+ }, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
+
+ self.assertEqual(200, resp.status_code)
+ self.assertEqual(len(mail.outbox), 1)
+ assert 'http://xxx' in mail.outbox[0].body
+ assert mail.outbox[0].from_email == self.user.email
+ assert mail.outbox[0].extra_headers['Reply-to'] == self.user.email