Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
registration: Show SMTP failure page correctly.
Alex Vandivere45f74dafbdc
diff --git a/zerver/tests/test_signup.py b/zerver/tests/test_signup.pyindex 56e0dd4117a..115b6e57666 100644--- a/zerver/tests/test_signup.py+++ b/zerver/tests/test_signup.py@@ -2011,10 +2011,6 @@ class RealmCreationTest(ZulipTestCase):class UserSignUpTest(ZulipTestCase):- def _assert_redirected_to(self, result: "TestHttpResponse", url: str) -> None:- self.assertEqual(result.status_code, 302)- self.assertEqual(result["LOCATION"], url)-def verify_signup(self,*,@@ -2074,7 +2070,7 @@ class UserSignUpTest(ZulipTestCase):def test_bad_email_configuration_for_accounts_home(self) -> None:"""- Make sure we redirect for EmailNotDeliveredError.+ Make sure we show an error page for EmailNotDeliveredError."""email = self.nonreg_email("newguy")@@ -2086,12 +2082,15 @@ class UserSignUpTest(ZulipTestCase):with smtp_mock, self.assertLogs(level="ERROR") as m:result = self.client_post("/accounts/home/", {"email": email})- self._assert_redirected_to(result, "/config-error/smtp")- self.assertEqual(m.output, ["ERROR:root:Error in accounts_home"])+ self.assertEqual(result.status_code, 500)+ self.assert_in_response(+ "https://zulip.readthedocs.io/en/latest/subsystems/email.html", result+ )+ self.assertTrue("ERROR:root:Error in accounts_home" in m.output[0])def test_bad_email_configuration_for_create_realm(self) -> None:"""- Make sure we redirect for EmailNotDeliveredError.+ Make sure we show an error page for EmailNotDeliveredError."""email = self.nonreg_email("newguy")@@ -2105,8 +2104,11 @@ class UserSignUpTest(ZulipTestCase):email, realm_subdomain="custom-test", realm_name="Zulip test")- self._assert_redirected_to(result, "/config-error/smtp")- self.assertEqual(m.output, ["ERROR:root:Error in create_realm"])+ self.assertEqual(result.status_code, 500)+ self.assert_in_response(+ "https://zulip.readthedocs.io/en/latest/subsystems/email.html", result+ )+ self.assertTrue("ERROR:root:Error in create_realm" in m.output[0])def test_user_default_language_and_timezone(self) -> None:"""diff --git a/zerver/views/registration.py b/zerver/views/registration.pyindex 7dc154e6a4f..2e00304ec1d 100644--- a/zerver/views/registration.py+++ b/zerver/views/registration.py@@ -94,6 +94,7 @@ from zerver.views.auth import (redirect_and_log_into_subdomain,redirect_to_deactivation_notice,)+from zerver.views.errors import config_errorfrom zproject.backends import (ExternalAuthResult,NoMatchingLDAPUserError,@@ -816,7 +817,7 @@ def create_realm(request: HttpRequest, creation_key: Optional[str] = None) -> Htsend_confirm_registration_email(email, activation_url, request=request)except EmailNotDeliveredError:logging.error("Error in create_realm")- return HttpResponseRedirect("/config-error/smtp")+ return config_error(request, "smtp")if key_record is not None:key_record.delete()@@ -946,7 +947,7 @@ def accounts_home(send_confirm_registration_email(email, activation_url, request=request, realm=realm)except EmailNotDeliveredError:logging.error("Error in accounts_home")- return HttpResponseRedirect("/config-error/smtp")+ return config_error(request, "smtp")signup_send_confirm_url = reverse("signup_send_confirm")query = urlencode({"email": email})url = append_url_query_string(signup_send_confirm_url, query)