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" ];
31 invoiceplane_nginx = { ... }: {
32 services.invoiceplane.webserver = "nginx";
33 services.invoiceplane.sites = {
35 database.name = "invoiceplane1";
36 database.createLocally = true;
40 database.name = "invoiceplane2";
41 database.createLocally = true;
46 networking.firewall.allowedTCPPorts = [ 80 ];
47 networking.hosts."127.0.0.1" = [ "site1.local" "site2.local" ];
54 invoiceplane_caddy.wait_for_unit("caddy")
55 invoiceplane_nginx.wait_for_unit("nginx")
57 site_names = ["site1.local", "site2.local"]
59 machines = [invoiceplane_caddy, invoiceplane_nginx]
61 for machine in machines:
62 machine.wait_for_open_port(80)
63 machine.wait_for_open_port(3306)
65 for site_name in site_names:
66 machine.wait_for_unit(f"phpfpm-invoiceplane-{site_name}")
68 with subtest("Website returns welcome screen"):
69 assert "Please install InvoicePlane" in machine.succeed(f"curl -L {site_name}")
71 with subtest("Finish InvoicePlane setup"):
73 f"curl -sSfL --cookie-jar cjar {site_name}/setup/language"
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}&ip_lang=english&btn_continue=Continue' {site_name}/setup/language"
81 csrf_token = machine.succeed(
82 "grep ip_csrf_cookie cjar | cut -f 7 | tr -d '\n'"
85 f"curl -sSfL --cookie cjar --cookie-jar cjar -d '_ip_csrf={csrf_token}&btn_continue=Continue' {site_name}/setup/prerequisites"
87 csrf_token = machine.succeed(
88 "grep ip_csrf_cookie cjar | cut -f 7 | tr -d '\n'"
91 f"curl -sSfL --cookie cjar --cookie-jar cjar -d '_ip_csrf={csrf_token}&btn_continue=Continue' {site_name}/setup/configure_database"
93 csrf_token = machine.succeed(
94 "grep ip_csrf_cookie cjar | cut -f 7 | tr -d '\n'"
97 f"curl -sSfl --cookie cjar --cookie-jar cjar -d '_ip_csrf={csrf_token}&btn_continue=Continue' {site_name}/setup/install_tables"
99 csrf_token = machine.succeed(
100 "grep ip_csrf_cookie cjar | cut -f 7 | tr -d '\n'"
103 f"curl -sSfl --cookie cjar --cookie-jar cjar -d '_ip_csrf={csrf_token}&btn_continue=Continue' {site_name}/setup/upgrade_tables"