1 import ./make-test-python.nix ({ pkgs, ...}:
3 pythonEnv = pkgs.python3.withPackages (py: with py; [ appdirs toml ]);
6 baseUrl = "http://server:${toString port}";
8 configureSteck = pkgs.writeScript "configure.py" ''
9 #!${pythonEnv.interpreter}
15 "base": "${baseUrl}/",
21 os.makedirs(appdirs.user_config_dir('steck'))
22 with open(os.path.join(appdirs.user_config_dir('steck'), 'steck.toml'), "w") as fd:
28 meta = with pkgs.lib.maintainers; {
29 maintainers =[ hexa ];
33 server = { config, ... }:
35 networking.firewall.allowedTCPPorts = [
45 client = { pkgs, ... }:
47 environment.systemPackages = [ pkgs.steck ];
54 server.wait_for_unit("pinnwand.service")
55 client.wait_for_unit("network.target")
57 # create steck.toml config file
58 client.succeed("${configureSteck}")
60 # wait until the server running pinnwand is reachable
61 client.wait_until_succeeds("ping -c1 server")
63 # make sure pinnwand is listening
64 server.wait_for_open_port(${toString port})
66 # send the contents of /etc/machine-id
67 response = client.succeed("steck paste /etc/machine-id")
69 # parse the steck response
72 for line in response.split("\n"):
73 if line.startswith("View link:"):
74 raw_url = f"${baseUrl}/raw/{line.split('/')[-1]}"
75 if line.startswith("Removal link:"):
76 removal_link = line.split(":", 1)[1]
79 # start the reaper, it shouldn't do anything meaningful here
80 server.systemctl("start pinnwand-reaper.service")
81 server.wait_until_fails("systemctl is-active -q pinnwand-reaper.service")
82 server.log(server.execute("journalctl -u pinnwand-reaper -e --no-pager")[1])
84 # check whether paste matches what we sent
85 client.succeed(f"curl {raw_url} > /tmp/machine-id")
86 client.succeed("diff /tmp/machine-id /etc/machine-id")
88 # remove paste and check that it's not available any more
89 client.succeed(f"curl {removal_link}")
90 client.fail(f"curl --fail {raw_url}")
92 server.log(server.succeed("systemd-analyze security pinnwand"))