Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
reactivate_realm: Change error status code on invalid links to 404.
Mateusz Mandera46c6f33b10bc
diff --git a/zerver/tests/test_realm.py b/zerver/tests/test_realm.pyindex f0c12723e29..a7656da60ec 100644--- a/zerver/tests/test_realm.py+++ b/zerver/tests/test_realm.py@@ -404,8 +404,9 @@ class RealmTest(ZulipTestCase):def test_realm_reactivation_with_random_link(self) -> None:random_link = "/reactivate/5e89081eb13984e0f3b130bf7a4121d153f1614b"response = self.client_get(random_link)- self.assert_in_success_response(- ["The organization reactivation link has expired or is not valid."], response+ self.assertEqual(response.status_code, 404)+ self.assert_in_response(+ "The organization reactivation link has expired or is not valid.", response)def test_change_notifications_stream(self) -> None:diff --git a/zerver/views/realm.py b/zerver/views/realm.pyindex bbf06be44cf..756dc20bca8 100644--- a/zerver/views/realm.py+++ b/zerver/views/realm.py@@ -331,7 +331,7 @@ def realm_reactivation(request: HttpRequest, confirmation_key: str) -> HttpRespoconfirmation_key, [Confirmation.REALM_REACTIVATION], mark_object_used=False)except ConfirmationKeyException:- return render(request, "zerver/realm_reactivation_link_error.html")+ return render(request, "zerver/realm_reactivation_link_error.html", status=404)assert isinstance(realm, Realm)do_reactivate_realm(realm)# TODO: After reactivating the realm, the confirmation link needs to be revoked in some way.