From b2604e32cc0e7213628c4ba869766b4ef4685706 Mon Sep 17 00:00:00 2001 From: "Amanda H. L. de Andrade Katz" Date: Tue, 17 Sep 2024 17:43:15 -0300 Subject: [PATCH] fix: replace regex for room ids (#525) * fix: replace regex for room ids * chores: add test_synapse_configure_roomids integration test --- src/charm_state.py | 2 +- tests/integration/test_charm.py | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/charm_state.py b/src/charm_state.py index 88871258..2ef0465b 100644 --- a/src/charm_state.py +++ b/src/charm_state.py @@ -266,7 +266,7 @@ def roomids_to_list(cls, value: str) -> typing.List[str]: """ # Based on documentation # https://spec.matrix.org/v1.10/appendices/#user-identifiers - roomid_regex = r"![a-z0-9._=/+-]+:\w+(?:\.\w+)+" + roomid_regex = r"![a-zA-Z0-9._=/+-]+:[a-zA-Z0-9-.]+" if value is None: return [] value_list = ["!" + room_id.strip() for room_id in value.split(",")] diff --git a/tests/integration/test_charm.py b/tests/integration/test_charm.py index 7b6ef10f..5bdbf464 100644 --- a/tests/integration/test_charm.py +++ b/tests/integration/test_charm.py @@ -67,6 +67,28 @@ async def test_synapse_validate_configuration(synapse_app: Application): ) +async def test_synapse_configure_roomids(synapse_app: Application): + """ + arrange: build and deploy the Synapse charm. + act: configure invite_checker_policy_rooms with valid room ids. + assert: the Synapse application should be active after setting and + reverting the config. + """ + await synapse_app.set_config( + {"invite_checker_policy_rooms": "a1b2c3d4e5f6g7h8i9j:foo.bar,w1x2y3z4A5B6C7D8E9F:xyz.org"} + ) + + await synapse_app.model.wait_for_idle( + idle_period=30, timeout=120, apps=[synapse_app.name], status="active" + ) + + await synapse_app.reset_config(["invite_checker_policy_rooms"]) + + await synapse_app.model.wait_for_idle( + idle_period=30, timeout=120, apps=[synapse_app.name], status="active" + ) + + async def test_enable_stats_exporter( synapse_app: Application, synapse_app_name: str,