Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

video_calls: Provide more information on failure.

Alex Vandiver3ddde28fbe9f
diff --git a/zerver/tests/test_create_video_call.py b/zerver/tests/test_create_video_call.py
index ad435c04f3d..2697bf40b47 100644
--- a/zerver/tests/test_create_video_call.py
+++ b/zerver/tests/test_create_video_call.py
@@ -504,14 +504,31 @@ class BigBlueButtonVideoCallTest(ZulipTestCase):
responses.add(
responses.GET,
"https://bbb.example.com/bigbluebutton/api/create?meetingID=a&name=a&lockSettingsDisableCam=True&checksum=33349e6374ca9b2d15a0c6e51a42bc3e8f770de13f88660815c6449859856e20",
- "",
status=500,
+ body="Something went wrong",
)
response = self.client_get(
"/calls/bigbluebutton/join",
{"bigbluebutton": self.signed_bbb_a_object},
)
- self.assert_json_error(response, "Error connecting to the BigBlueButton server.")
+ self.assert_json_error(
+ response, "Error connecting to the BigBlueButton server: HTTP 500: Something went wrong"
+ )
+
+ @responses.activate
+ def test_join_bigbluebutton_connection_refused(self) -> None:
+ responses.add(
+ responses.GET,
+ "https://bbb.example.com/bigbluebutton/api/create?meetingID=a&name=a&lockSettingsDisableCam=True&checksum=33349e6374ca9b2d15a0c6e51a42bc3e8f770de13f88660815c6449859856e20",
+ body=requests.exceptions.ConnectionError("Connection refused"),
+ )
+ response = self.client_get(
+ "/calls/bigbluebutton/join",
+ {"bigbluebutton": self.signed_bbb_a_object},
+ )
+ self.assert_json_error(
+ response, "Error connecting to the BigBlueButton server: Connection refused"
+ )
@responses.activate
def test_join_bigbluebutton_redirect_error_by_server(self) -> None:
@@ -525,7 +542,9 @@ class BigBlueButtonVideoCallTest(ZulipTestCase):
"/calls/bigbluebutton/join",
{"bigbluebutton": self.signed_bbb_a_object},
)
- self.assert_json_error(response, "BigBlueButton server returned an unexpected error.")
+ self.assert_json_error(
+ response, "BigBlueButton server returned an unexpected error: FAILURE"
+ )
def test_join_bigbluebutton_redirect_not_configured(self) -> None:
with self.settings(BIG_BLUE_BUTTON_SECRET=None, BIG_BLUE_BUTTON_URL=None):
@@ -745,6 +764,23 @@ class NextcloudVideoCallTest(ZulipTestCase):
)
self.assert_json_error(response, "Nextcloud Talk is not configured")
+ @responses.activate
+ def test_create_nextcloud_talk_server_error(self) -> None:
+ responses.add(
+ responses.POST,
+ self.nextcloud_api_url,
+ status=400,
+ body="Invalid request",
+ )
+
+ response = self.client_post(
+ "/json/calls/nextcloud_talk/create", {"room_name": "#Test > team check-in"}
+ )
+
+ self.assert_json_error(
+ response, "Error connecting to the Nextcloud Talk server: HTTP 400: Invalid request"
+ )
+
@responses.activate
def test_create_nextcloud_talk_connection_error(self) -> None:
responses.add(
@@ -757,7 +793,9 @@ class NextcloudVideoCallTest(ZulipTestCase):
"/json/calls/nextcloud_talk/create", {"room_name": "#Test > team check-in"}
)
- self.assert_json_error(response, "Error connecting to the Nextcloud Talk server")
+ self.assert_json_error(
+ response, "Error connecting to the Nextcloud Talk server: Connection failed"
+ )
@responses.activate
def test_create_nextcloud_talk_invalid_response(self) -> None:
diff --git a/zerver/views/video_calls.py b/zerver/views/video_calls.py
index a61a92bb6a0..4be71a1bebf 100644
--- a/zerver/views/video_calls.py
+++ b/zerver/views/video_calls.py
@@ -493,15 +493,24 @@ def join_bigbluebutton(request: HttpRequest, *, bigbluebutton: str) -> HttpRespo
+ checksum
)
response.raise_for_status()
- except requests.RequestException:
- raise JsonableError(_("Error connecting to the BigBlueButton server."))
+ except requests.RequestException as e:
+ if e.response is not None:
+ reason = f"HTTP {response.status_code}: {response.text:.200}"
+ else:
+ reason = str(e)
+ raise JsonableError(
+ _("Error connecting to the BigBlueButton server: {reason}").format(reason=reason)
+ )
payload = ElementTree.fromstring(response.text)
if assert_is_not_none(payload.find("messageKey")).text == "checksumError":
raise JsonableError(_("Error authenticating to the BigBlueButton server."))
- if assert_is_not_none(payload.find("returncode")).text != "SUCCESS":
- raise JsonableError(_("BigBlueButton server returned an unexpected error."))
+ status = assert_is_not_none(payload.find("returncode")).text
+ if status != "SUCCESS":
+ raise JsonableError(
+ _("BigBlueButton server returned an unexpected error: {status}").format(status=status)
+ )
join_params = urlencode(
{
@@ -594,9 +603,14 @@ def create_nextcloud_talk_url(
try:
response = VideoCallSession().post(api_url, json=payload, headers=headers, timeout=10)
response.raise_for_status()
- except requests.RequestException:
- raise JsonableError(_("Error connecting to the Nextcloud Talk server"))
-
+ except requests.RequestException as e:
+ if e.response is not None:
+ reason = f"HTTP {response.status_code}: {response.text:.200}"
+ else:
+ reason = str(e)
+ raise JsonableError(
+ _("Error connecting to the Nextcloud Talk server: {reason}").format(reason=reason)
+ )
try:
data = response.json()
token = data["ocs"]["data"]["token"]