1 import ./make-test-python.nix ({ pkgs, ...}:
4 baseUrl = "http://server:${toString port}";
8 meta = with pkgs.lib.maintainers; {
13 server = { config, ... }:
15 networking.firewall.allowedTCPPorts = [
25 client = { pkgs, ... }:
27 environment.systemPackages = [
30 (pkgs.writers.writePython3Bin "setup-steck.py" {
31 libraries = with pkgs.python3.pkgs; [ appdirs toml ];
42 "base": "${baseUrl}/",
48 os.makedirs(appdirs.user_config_dir('steck'))
49 with open(os.path.join(appdirs.user_config_dir('steck'), 'steck.toml'), "w") as fd:
59 server.wait_for_unit("pinnwand.service")
60 client.wait_for_unit("network.target")
62 # create steck.toml config file
63 client.succeed("setup-steck.py")
65 # wait until the server running pinnwand is reachable
66 client.wait_until_succeeds("ping -c1 server")
68 # make sure pinnwand is listening
69 server.wait_for_open_port(${toString port})
71 # send the contents of /etc/machine-id
72 response = client.succeed("steck paste /etc/machine-id")
74 # parse the steck response
77 for line in response.split("\n"):
78 if line.startswith("View link:"):
79 raw_url = f"${baseUrl}/raw/{line.split('/')[-1]}"
80 if line.startswith("Removal link:"):
81 removal_link = line.split(":", 1)[1]
83 # check whether paste matches what we sent
84 client.succeed(f"curl {raw_url} > /tmp/machine-id")
85 client.succeed("diff /tmp/machine-id /etc/machine-id")
87 # remove paste and check that it's not available any more
88 client.succeed(f"curl {removal_link}")
89 client.fail(f"curl --fail {raw_url}")
91 server.log(server.execute("systemd-analyze security pinnwand | grep '✗'")[1])