Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
registration: On Zulip Cloud, show a 500 instead of a config page.
Alex Vandiver7c80cbbc771c
diff --git a/zerver/tests/test_signup.py b/zerver/tests/test_signup.pyindex 529e51af651..f4a64b79ec6 100644--- a/zerver/tests/test_signup.py+++ b/zerver/tests/test_signup.py@@ -2068,6 +2068,7 @@ class UserSignUpTest(ZulipTestCase):self.assert_logged_in_user_id(user_profile.id)return user_profile+ @override_settings(CORPORATE_ENABLED=False)def test_bad_email_configuration_for_accounts_home(self) -> None:"""Make sure we show an error page for EmailNotDeliveredError.@@ -2090,6 +2091,31 @@ class UserSignUpTest(ZulipTestCase):"ERROR:root:Failed to deliver email during user registration" in m.output[0])+ @override_settings(CORPORATE_ENABLED=True)+ def test_bad_email_configuration_for_corporate_accounts_home(self) -> None:+ """+ This should show a generic 500.+ """+ email = self.nonreg_email("newguy")++ smtp_mock = patch(+ "zerver.views.registration.send_confirm_registration_email",+ side_effect=EmailNotDeliveredError,+ )++ with smtp_mock, self.assertLogs(level="ERROR") as m:+ result = self.client_post("/accounts/home/", {"email": email})++ self.assertEqual(result.status_code, 500)+ self.assertNotIn(+ "https://zulip.readthedocs.io/en/latest/subsystems/email.html", result.content.decode()+ )+ self.assert_in_response("server is experiencing technical difficulties", result)+ self.assertTrue(+ "ERROR:root:Failed to deliver email during user registration" in m.output[0]+ )++ @override_settings(CORPORATE_ENABLED=False)def test_bad_email_configuration_for_create_realm(self) -> None:"""Make sure we show an error page for EmailNotDeliveredError.@@ -2112,6 +2138,30 @@ class UserSignUpTest(ZulipTestCase):)self.assertTrue("ERROR:root:Failed to deliver email during realm creation" in m.output[0])+ @override_settings(CORPORATE_ENABLED=True)+ def test_bad_email_configuration_for_corporate_create_realm(self) -> None:+ """+ This should show a generic 500.+ """+ email = self.nonreg_email("newguy")++ smtp_mock = patch(+ "zerver.views.registration.send_confirm_registration_email",+ side_effect=EmailNotDeliveredError,+ )++ with smtp_mock, self.assertLogs(level="ERROR") as m:+ result = self.submit_realm_creation_form(+ email, realm_subdomain="custom-test", realm_name="Zulip test"+ )++ self.assertEqual(result.status_code, 500)+ self.assertNotIn(+ "https://zulip.readthedocs.io/en/latest/subsystems/email.html", result.content.decode()+ )+ self.assert_in_response("server is experiencing technical difficulties", result)+ self.assertTrue("ERROR:root:Failed to deliver email during realm creation" in m.output[0])+def test_user_default_language_and_timezone(self) -> None:"""Check if the default language of new user is set using the browser localediff --git a/zerver/views/registration.py b/zerver/views/registration.pyindex bc792fd6d7a..0dd566b93b8 100644--- a/zerver/views/registration.py+++ b/zerver/views/registration.py@@ -17,6 +17,7 @@ from django.shortcuts import redirect, renderfrom django.template.response import TemplateResponsefrom django.urls import reversefrom django.utils.translation import get_language+from django.views.defaults import server_errorfrom django_auth_ldap.backend import LDAPBackend, _LDAPUserfrom confirmation.models import (@@ -817,6 +818,8 @@ def create_realm(request: HttpRequest, creation_key: Optional[str] = None) -> Htsend_confirm_registration_email(email, activation_url, request=request)except EmailNotDeliveredError:logging.exception("Failed to deliver email during realm creation")+ if settings.CORPORATE_ENABLED:+ return server_error(request)return config_error(request, "smtp")if key_record is not None:@@ -947,6 +950,8 @@ def accounts_home(send_confirm_registration_email(email, activation_url, request=request, realm=realm)except EmailNotDeliveredError:logging.exception("Failed to deliver email during user registration")+ if settings.CORPORATE_ENABLED:+ return server_error(request)return config_error(request, "smtp")signup_send_confirm_url = reverse("signup_send_confirm")query = urlencode({"email": email})