1 import ./make-test-python.nix ({ pkgs, ... }:
5 meta = with pkgs.lib.maintainers; {
12 invoiceplane_caddy = { ... }: {
13 services.invoiceplane.webserver = "caddy";
14 services.invoiceplane.sites = {
16 database.name = "invoiceplane1";
17 database.createLocally = true;
21 database.name = "invoiceplane2";
22 database.createLocally = true;
27 networking.firewall.allowedTCPPorts = [ 80 ];
28 networking.hosts."127.0.0.1" = [ "site1.local" "site2.local" ];
35 invoiceplane_caddy.wait_for_unit("caddy")
36 invoiceplane_caddy.wait_for_open_port(80)
37 invoiceplane_caddy.wait_for_open_port(3306)
39 site_names = ["site1.local", "site2.local"]
41 for site_name in site_names:
42 machine.wait_for_unit(f"phpfpm-invoiceplane-{site_name}")
44 with subtest("Website returns welcome screen"):
45 assert "Please install InvoicePlane" in machine.succeed(f"curl -L {site_name}")
47 with subtest("Finish InvoicePlane setup"):
49 f"curl -sSfL --cookie-jar cjar {site_name}/setup/language"
51 csrf_token = machine.succeed(
52 "grep ip_csrf_cookie cjar | cut -f 7 | tr -d '\n'"
55 f"curl -sSfL --cookie cjar --cookie-jar cjar -d '_ip_csrf={csrf_token}&ip_lang=english&btn_continue=Continue' {site_name}/setup/language"
57 csrf_token = machine.succeed(
58 "grep ip_csrf_cookie cjar | cut -f 7 | tr -d '\n'"
61 f"curl -sSfL --cookie cjar --cookie-jar cjar -d '_ip_csrf={csrf_token}&btn_continue=Continue' {site_name}/setup/prerequisites"
63 csrf_token = machine.succeed(
64 "grep ip_csrf_cookie cjar | cut -f 7 | tr -d '\n'"
67 f"curl -sSfL --cookie cjar --cookie-jar cjar -d '_ip_csrf={csrf_token}&btn_continue=Continue' {site_name}/setup/configure_database"
69 csrf_token = machine.succeed(
70 "grep ip_csrf_cookie cjar | cut -f 7 | tr -d '\n'"
73 f"curl -sSfl --cookie cjar --cookie-jar cjar -d '_ip_csrf={csrf_token}&btn_continue=Continue' {site_name}/setup/install_tables"
75 csrf_token = machine.succeed(
76 "grep ip_csrf_cookie cjar | cut -f 7 | tr -d '\n'"
79 f"curl -sSfl --cookie cjar --cookie-jar cjar -d '_ip_csrf={csrf_token}&btn_continue=Continue' {site_name}/setup/upgrade_tables"