1 import ./make-test-python.nix ({ pkgs, lib, ... }: {
3 meta = with lib.maintainers; {
7 nodes.machine = { pkgs, ... }: {
8 virtualisation.memorySize = 4096;
12 email = "admin@example.org";
13 passwordFile = "${pkgs.writeText "pwd" "foobar"}";
17 baseUrl = "http://localhost:8000";
18 secretKeybaseFile = "${pkgs.writeText "dont-try-this-at-home" "nannannannannannannannannannannannannannannannannannannan_batman!"}";
25 machine.wait_for_unit("plausible.service")
26 machine.wait_for_open_port(8000)
28 # Ensure that the software does not make not make the machine
29 # listen on any public interfaces by default.
30 machine.fail("ss -tlpn 'src = 0.0.0.0 or src = [::]' | grep LISTEN")
32 machine.succeed("curl -f localhost:8000 >&2")
34 machine.succeed("curl -f localhost:8000/js/script.js >&2")
36 csrf_token = machine.succeed(
37 "curl -c /tmp/cookies localhost:8000/login | grep '_csrf_token' | sed -E 's,.*value=\"(.*)\".*,\\1,g'"
41 f"curl -b /tmp/cookies -f -X POST localhost:8000/login -F email=admin@example.org -F password=foobar -F _csrf_token={csrf_token.strip()} -D headers"
44 # By ensuring that the user is redirected to the dashboard after login, we
45 # also make sure that the automatic verification of the module works.
47 "[[ $(grep 'location: ' headers | cut -d: -f2- | xargs echo) == /sites* ]]"