1 import ../make-test-python.nix ({ pkgs, ... }:
6 name = "matrix-conduit";
10 services.matrix-conduit = {
12 settings.global.server_name = name;
13 settings.global.allow_registration = true;
14 extraEnvironment.RUST_BACKTRACE = "yes";
18 virtualHosts.${name} = {
23 locations."/_matrix" = {
24 proxyPass = "http://[::1]:6167";
28 networking.firewall.allowedTCPPorts = [ 80 ];
30 client = { pkgs, ... }: {
31 environment.systemPackages = [
33 pkgs.writers.writePython3Bin "do_test"
34 { libraries = [ pkgs.python3Packages.matrix-nio ]; } ''
37 from nio import AsyncClient
40 async def main() -> None:
42 client = AsyncClient("http://conduit:80", "alice")
44 # Register as user alice
45 response = await client.register("alice", "my-secret-password")
47 # Log in as user alice
48 response = await client.login("my-secret-password")
51 response = await client.room_create(federate=False)
52 room_id = response.room_id
55 response = await client.join(room_id)
57 # Send a message to the room
58 response = await client.room_send(
60 message_type="m.room.message",
63 "body": "Hello conduit!"
68 response = await client.sync(timeout=30000)
70 # Check the message was received by conduit
71 last_message = response.rooms.join[room_id].timeline.events[-1].body
72 assert last_message == "Hello conduit!"
75 response = await client.room_leave(room_id)
80 asyncio.get_event_loop().run_until_complete(main())
90 with subtest("start conduit"):
91 conduit.wait_for_unit("conduit.service")
92 conduit.wait_for_open_port(80)
94 with subtest("ensure messages can be exchanged"):
95 client.succeed("do_test")