1{ pkgs, lib, ... }:
2
3let
4 chipVersion = pkgs.python311Packages.home-assistant-chip-core.version;
5in
6
7{
8 name = "matter-server";
9 meta.maintainers = with lib.maintainers; [ leonm1 ];
10 meta.timeout = 120; # Timeout after two minutes
11
12 nodes = {
13 machine =
14 { config, ... }:
15 {
16 services.matter-server = {
17 enable = true;
18 port = 1234;
19 };
20 };
21 };
22
23 testScript = # python
24 ''
25 @polling_condition
26 def matter_server_running():
27 machine.succeed("systemctl status matter-server")
28
29 start_all()
30
31 machine.wait_for_unit("matter-server.service", timeout=20)
32 machine.wait_for_open_port(1234, timeout=20)
33
34 with matter_server_running: # type: ignore[union-attr]
35 with subtest("Check websocket server initialized"):
36 output = machine.succeed("echo \"\" | ${pkgs.websocat}/bin/websocat ws://localhost:1234/ws")
37 machine.log(output)
38
39 assert '"fabric_id": 1' in output, (
40 "fabric_id not propagated to server"
41 )
42
43 with subtest("Check storage directory is created"):
44 machine.succeed("ls /var/lib/matter-server/chip.json")
45
46 with subtest("Check systemd hardening"):
47 _, output = machine.execute("systemd-analyze security matter-server.service | grep -v '✓'")
48 machine.log(output)
49 '';
50}