diff --git a/tests/rest/admin/test_server_notice.py b/tests/rest/admin/test_server_notice.py
index 2398bc503a..e1d4ceb698 100644
--- a/tests/rest/admin/test_server_notice.py
+++ b/tests/rest/admin/test_server_notice.py
@@ -596,6 +596,115 @@ class ServerNoticeTestCase(unittest.HomeserverTestCase):
)
self.assertEqual(notice_user_state["avatar_url"], new_avatar_url)
+ @override_config(
+ {
+ "server_notices": {
+ "system_mxid_localpart": "notices",
+ "room_avatar_url": "test/url",
+ "room_topic": "Test Topic",
+ }
+ }
+ )
+ def test_notice_room_avatar_and_topic(self) -> None:
+ """
+ Tests that using `room_avatar_url` and `room_topic` config properly sets
+ those properties for the created notice rooms.
+ """
+ server_notice_request_content = {
+ "user_id": self.other_user,
+ "content": {"msgtype": "m.text", "body": "test msg one"},
+ }
+
+ self.make_request(
+ "POST",
+ self.url,
+ access_token=self.admin_user_tok,
+ content=server_notice_request_content,
+ )
+
+ invited_rooms = self._check_invite_and_join_status(self.other_user, 1, 0)
+ notice_room_id = invited_rooms[0].room_id
+ self.helper.join(
+ room=notice_room_id, user=self.other_user, tok=self.other_user_token
+ )
+
+ room_avatar_state = self.helper.get_state(
+ notice_room_id,
+ "m.room.avatar",
+ self.other_user_token,
+ state_key="",
+ )
+ self.assertEqual(room_avatar_state["url"], "test/url")
+
+ room_topic_state = self.helper.get_state(
+ notice_room_id,
+ "m.room.topic",
+ self.other_user_token,
+ state_key="",
+ )
+ self.assertEqual(room_topic_state["topic"], "Test Topic")
+
+ @override_config(
+ {
+ "server_notices": {
+ "system_mxid_localpart": "notices",
+ "room_avatar_url": "test/url",
+ }
+ }
+ )
+ def test_update_room_avatar_when_changed(self) -> None:
+ """
+ Tests that existing server notices room avatar is updated when it is
+ different from the one in homeserver config.
+ """
+ server_notice_request_content = {
+ "user_id": self.other_user,
+ "content": {"msgtype": "m.text", "body": "test msg one"},
+ }
+
+ self.make_request(
+ "POST",
+ self.url,
+ access_token=self.admin_user_tok,
+ content=server_notice_request_content,
+ )
+
+ invited_rooms = self._check_invite_and_join_status(self.other_user, 1, 0)
+ notice_room_id = invited_rooms[0].room_id
+ self.helper.join(
+ room=notice_room_id, user=self.other_user, tok=self.other_user_token
+ )
+
+ room_avatar_state = self.helper.get_state(
+ notice_room_id,
+ "m.room.avatar",
+ self.other_user_token,
+ state_key="",
+ )
+ self.assertEqual(room_avatar_state["url"], "test/url")
+
+ # simulate a change in server config after a server restart.
+ new_avatar_url = "test/new-url"
+ self.server_notices_manager._config.servernotices.server_notices_room_avatar_url = (
+ new_avatar_url
+ )
+ self.server_notices_manager.get_or_create_notice_room_for_user.cache.invalidate_all()
+
+ self.make_request(
+ "POST",
+ self.url,
+ access_token=self.admin_user_tok,
+ content=server_notice_request_content,
+ )
+
+ room_avatar_state = self.helper.get_state(
+ notice_room_id,
+ "m.room.avatar",
+ self.other_user_token,
+ state_key="",
+ )
+ self.assertEqual(room_avatar_state["url"], new_avatar_url)
+
def _check_invite_and_join_status(
self, user_id: str, expected_invites: int, expected_memberships: int
) -> Sequence[RoomsForUser]:
diff --git a/tests/rest/client/test_auth_issuer.py b/tests/rest/client/test_auth_issuer.py
new file mode 100644
index 0000000000..964baeec32
--- /dev/null
+++ b/tests/rest/client/test_auth_issuer.py
@@ -0,0 +1,59 @@
+# Copyright 2023 The Matrix.org Foundation C.I.C.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+from http import HTTPStatus
+
+from synapse.rest.client import auth_issuer
+
+from tests.unittest import HomeserverTestCase, override_config, skip_unless
+from tests.utils import HAS_AUTHLIB
+
+ISSUER = "https://account.example.com/"
+
+
+class AuthIssuerTestCase(HomeserverTestCase):
+ servlets = [
+ auth_issuer.register_servlets,
+ ]
+
+ def test_returns_404_when_msc3861_disabled(self) -> None:
+ # Make an unauthenticated request for the discovery info.
+ channel = self.make_request(
+ "GET",
+ "/_matrix/client/unstable/org.matrix.msc2965/auth_issuer",
+ )
+ self.assertEqual(channel.code, HTTPStatus.NOT_FOUND)
+
+ @skip_unless(HAS_AUTHLIB, "requires authlib")
+ @override_config(
+ {
+ "disable_registration": True,
+ "experimental_features": {
+ "msc3861": {
+ "enabled": True,
+ "issuer": ISSUER,
+ "client_id": "David Lister",
+ "client_auth_method": "client_secret_post",
+ "client_secret": "Who shot Mister Burns?",
+ }
+ },
+ }
+ )
+ def test_returns_issuer_when_oidc_enabled(self) -> None:
+ # Make an unauthenticated request for the discovery info.
+ channel = self.make_request(
+ "GET",
+ "/_matrix/client/unstable/org.matrix.msc2965/auth_issuer",
+ )
+ self.assertEqual(channel.code, HTTPStatus.OK)
+ self.assertEqual(channel.json_body, {"issuer": ISSUER})
|