mirror of https://github.com/zulip/zulip.git
registration: On Zulip Cloud, show a 500 instead of a config page.
This commit is contained in:
parent
db38d43473
commit
7c80cbbc77
|
@ -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 locale
|
||||
|
|
|
@ -17,6 +17,7 @@ from django.shortcuts import redirect, render
|
|||
from django.template.response import TemplateResponse
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import get_language
|
||||
from django.views.defaults import server_error
|
||||
from django_auth_ldap.backend import LDAPBackend, _LDAPUser
|
||||
|
||||
from confirmation.models import (
|
||||
|
@ -817,6 +818,8 @@ def create_realm(request: HttpRequest, creation_key: Optional[str] = None) -> Ht
|
|||
send_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})
|
||||
|
|
Loading…
Reference in New Issue