|
| 1 | +# |
| 2 | +# This file is licensed under the Affero General Public License (AGPL) version 3. |
| 3 | +# |
| 4 | +# Copyright 2014-2016 OpenMarket Ltd |
| 5 | +# Copyright (C) 2023 New Vector, Ltd |
| 6 | +# |
| 7 | +# This program is free software: you can redistribute it and/or modify |
| 8 | +# it under the terms of the GNU Affero General Public License as |
| 9 | +# published by the Free Software Foundation, either version 3 of the |
| 10 | +# License, or (at your option) any later version. |
| 11 | +# |
| 12 | +# See the GNU Affero General Public License for more details: |
| 13 | +# <https://www.gnu.org/licenses/agpl-3.0.html>. |
| 14 | +# |
| 15 | +# Originally licensed under the Apache License, Version 2.0: |
| 16 | +# <http://www.apache.org/licenses/LICENSE-2.0>. |
| 17 | +# |
| 18 | +# [This file includes modifications made by New Vector Limited] |
| 19 | +# |
| 20 | +# |
| 21 | + |
| 22 | +"""Tests REST events for /rtc/endpoints path.""" |
| 23 | + |
| 24 | + |
| 25 | +from synapse.rest import admin |
| 26 | +from synapse.rest.client import login, matrixrtc, register,room |
| 27 | + |
| 28 | +from tests import unittest |
| 29 | + |
| 30 | +PATH_PREFIX = "/_matrix/client/unstable/org.matrix.msc4143" |
| 31 | +RTC_ENDPOINT = {"type": "focusA", "required_field": "theField"} |
| 32 | + |
| 33 | +class MatrixRtcTestCase(unittest.HomeserverTestCase): |
| 34 | + """Tests /rtc/endpoints REST API.""" |
| 35 | + |
| 36 | + servlets = [ |
| 37 | + admin.register_servlets, |
| 38 | + room.register_servlets, |
| 39 | + login.register_servlets, |
| 40 | + register.register_servlets, |
| 41 | + matrixrtc.register_servlets |
| 42 | + ] |
| 43 | + |
| 44 | + @unittest.override_config({"matrix_rtc": {"services": [RTC_ENDPOINT]}}) |
| 45 | + def test_matrixrtc_endpoints(self) -> None: |
| 46 | + channel = self.make_request("GET", f"{PATH_PREFIX}/rtc/services") |
| 47 | + self.assertEqual(401, channel.code) |
| 48 | + |
| 49 | + self.register_user("user", "password") |
| 50 | + tok = self.login("user", "password") |
| 51 | + channel = self.make_request("GET", f"{PATH_PREFIX}/rtc/services", access_token=tok) |
| 52 | + self.assertEqual(200, channel.code) |
| 53 | + |
| 54 | + self.assert_dict({"services": [RTC_ENDPOINT]}, channel.json_body) |
| 55 | + |
0 commit comments