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