Skip to content

Commit

Permalink
fix: replace regex for room ids (#525)
Browse files Browse the repository at this point in the history
* fix: replace regex for room ids

* chores: add test_synapse_configure_roomids integration test
  • Loading branch information
amandahla committed Sep 17, 2024
1 parent a6f172a commit b2604e3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/charm_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(",")]
Expand Down
22 changes: 22 additions & 0 deletions tests/integration/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit b2604e3

Please sign in to comment.