diff --git a/common/djangoapps/student/tests/test_reset_password.py b/common/djangoapps/student/tests/test_reset_password.py index d0f35bc9c7c36ff72f55464bee10d327f8d00f9b..6c60c65c2312911e002b603add8427ba8f65de30 100644 --- a/common/djangoapps/student/tests/test_reset_password.py +++ b/common/djangoapps/student/tests/test_reset_password.py @@ -16,12 +16,14 @@ from django.utils.http import int_to_base36 from mock import Mock, patch from textwrap import dedent +import ddt from student.views import password_reset, password_reset_confirm_wrapper from student.tests.factories import UserFactory from student.tests.test_email import mock_render_to_string +@ddt.ddt class ResetPasswordTests(TestCase): """ Tests that clicking reset password sends email, and doesn't activate the user """ @@ -121,6 +123,30 @@ class ResetPasswordTests(TestCase): self.assertFalse(self.user.is_active) re.search(r'password_reset_confirm/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/', msg).groupdict() + @unittest.skipIf( + settings.FEATURES.get('DISABLE_RESET_EMAIL_TEST', False), + dedent(""" + Skipping Test because CMS has not provided necessary templates for password reset. + If LMS tests print this message, that needs to be fixed. + """) + ) + @patch('django.core.mail.send_mail') + @ddt.data((False, 'http://'), (True, 'https://')) + @ddt.unpack + def test_reset_password_email_https(self, is_secure, protocol, send_email): + """ + Tests that the right url protocol is included in the reset password link + """ + req = self.request_factory.post( + '/password_reset/', {'email': self.user.email} + ) + req.is_secure = Mock(return_value=is_secure) + resp = password_reset(req) + _, msg, _, _ = send_email.call_args[0] + expected_msg = "Please go to the following page and choose a new password:\n\n" + protocol + + self.assertIn(expected_msg, msg) + @patch('student.views.password_reset_confirm') def test_reset_password_bad_token(self, reset_confirm): """Tests bad token and uidb36 in password reset""" diff --git a/lms/djangoapps/instructor/views/instructor_dashboard.py b/lms/djangoapps/instructor/views/instructor_dashboard.py index ca7aec3ecf3161ce9516eb8adf2f3dd847f0b9e0..0b31547cf518b4c822a7deba1a067541c7a50a51 100644 --- a/lms/djangoapps/instructor/views/instructor_dashboard.py +++ b/lms/djangoapps/instructor/views/instructor_dashboard.py @@ -110,7 +110,7 @@ def instructor_dashboard_2(request, course_id): # Construct a URL to the external analytics dashboard analytics_dashboard_url = '{0}/courses/{1}'.format(settings.ANALYTICS_DASHBOARD_URL, unicode(course_key)) link_start = "<a href=\"{}\" target=\"_blank\">".format(analytics_dashboard_url) - analytics_dashboard_message = _("To gain insights into student enrollment and participation {link_start}visit {analytics_dashboard_name}, our new dashboard for course analytics{link_end}.") + analytics_dashboard_message = _("To gain insights into student enrollment and participation {link_start}visit {analytics_dashboard_name}, our new course analytics product{link_end}.") analytics_dashboard_message = analytics_dashboard_message.format( link_start=link_start, link_end="</a>", analytics_dashboard_name=settings.ANALYTICS_DASHBOARD_NAME) diff --git a/lms/templates/registration/password_reset_email.html b/lms/templates/registration/password_reset_email.html index e7bbc6cf355b146ec876d10fae6f56199c384ff2..1952fa1bd6cd7d171d999398129b67a6591dbd60 100644 --- a/lms/templates/registration/password_reset_email.html +++ b/lms/templates/registration/password_reset_email.html @@ -3,7 +3,7 @@ {% trans "Please go to the following page and choose a new password:" %} {% block reset_link %} -http{% if is_secure %}s{% endif %}://{{domain}}{% url 'student.views.password_reset_confirm_wrapper' uidb36=uid token=token %} +{{ protocol }}://{{domain}}{% url 'student.views.password_reset_confirm_wrapper' uidb36=uid token=token %} {% endblock %} {% trans "If you didn't request this change, you can disregard this email - we have not yet reset your password." %}