2022-01-20 13:45:35 +00:00
|
|
|
import ./make-test-python.nix ({ pkgs, ... }:
|
|
|
|
|
|
|
|
{
|
|
|
|
name = "invoiceplane";
|
|
|
|
meta = with pkgs.lib.maintainers; {
|
|
|
|
maintainers = [
|
|
|
|
onny
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
nodes = {
|
|
|
|
invoiceplane_caddy = { ... }: {
|
|
|
|
services.invoiceplane.webserver = "caddy";
|
|
|
|
services.invoiceplane.sites = {
|
|
|
|
"site1.local" = {
|
2022-10-02 13:46:51 +01:00
|
|
|
database.name = "invoiceplane1";
|
2022-01-20 13:45:35 +00:00
|
|
|
database.createLocally = true;
|
|
|
|
enable = true;
|
|
|
|
};
|
|
|
|
"site2.local" = {
|
2022-10-02 13:46:51 +01:00
|
|
|
database.name = "invoiceplane2";
|
2022-01-20 13:45:35 +00:00
|
|
|
database.createLocally = true;
|
|
|
|
enable = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
networking.firewall.allowedTCPPorts = [ 80 ];
|
|
|
|
networking.hosts."127.0.0.1" = [ "site1.local" "site2.local" ];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
testScript = ''
|
|
|
|
start_all()
|
|
|
|
|
|
|
|
invoiceplane_caddy.wait_for_unit("caddy")
|
|
|
|
invoiceplane_caddy.wait_for_open_port(80)
|
|
|
|
invoiceplane_caddy.wait_for_open_port(3306)
|
|
|
|
|
|
|
|
site_names = ["site1.local", "site2.local"]
|
|
|
|
|
|
|
|
for site_name in site_names:
|
|
|
|
machine.wait_for_unit(f"phpfpm-invoiceplane-{site_name}")
|
|
|
|
|
|
|
|
with subtest("Website returns welcome screen"):
|
|
|
|
assert "Please install InvoicePlane" in machine.succeed(f"curl -L {site_name}")
|
|
|
|
|
|
|
|
with subtest("Finish InvoicePlane setup"):
|
|
|
|
machine.succeed(
|
2022-11-07 19:36:57 +00:00
|
|
|
f"curl -sSfL --cookie-jar cjar {site_name}/setup/language"
|
2022-01-20 13:45:35 +00:00
|
|
|
)
|
|
|
|
csrf_token = machine.succeed(
|
|
|
|
"grep ip_csrf_cookie cjar | cut -f 7 | tr -d '\n'"
|
|
|
|
)
|
|
|
|
machine.succeed(
|
2022-11-07 19:36:57 +00:00
|
|
|
f"curl -sSfL --cookie cjar --cookie-jar cjar -d '_ip_csrf={csrf_token}&ip_lang=english&btn_continue=Continue' {site_name}/setup/language"
|
2022-01-20 13:45:35 +00:00
|
|
|
)
|
|
|
|
csrf_token = machine.succeed(
|
|
|
|
"grep ip_csrf_cookie cjar | cut -f 7 | tr -d '\n'"
|
|
|
|
)
|
|
|
|
machine.succeed(
|
2022-11-07 19:36:57 +00:00
|
|
|
f"curl -sSfL --cookie cjar --cookie-jar cjar -d '_ip_csrf={csrf_token}&btn_continue=Continue' {site_name}/setup/prerequisites"
|
2022-01-20 13:45:35 +00:00
|
|
|
)
|
|
|
|
csrf_token = machine.succeed(
|
|
|
|
"grep ip_csrf_cookie cjar | cut -f 7 | tr -d '\n'"
|
|
|
|
)
|
|
|
|
machine.succeed(
|
2022-11-07 19:36:57 +00:00
|
|
|
f"curl -sSfL --cookie cjar --cookie-jar cjar -d '_ip_csrf={csrf_token}&btn_continue=Continue' {site_name}/setup/configure_database"
|
2022-01-20 13:45:35 +00:00
|
|
|
)
|
|
|
|
csrf_token = machine.succeed(
|
|
|
|
"grep ip_csrf_cookie cjar | cut -f 7 | tr -d '\n'"
|
|
|
|
)
|
|
|
|
machine.succeed(
|
2022-11-07 19:36:57 +00:00
|
|
|
f"curl -sSfl --cookie cjar --cookie-jar cjar -d '_ip_csrf={csrf_token}&btn_continue=Continue' {site_name}/setup/install_tables"
|
2022-01-20 13:45:35 +00:00
|
|
|
)
|
|
|
|
csrf_token = machine.succeed(
|
|
|
|
"grep ip_csrf_cookie cjar | cut -f 7 | tr -d '\n'"
|
|
|
|
)
|
|
|
|
machine.succeed(
|
2022-11-07 19:36:57 +00:00
|
|
|
f"curl -sSfl --cookie cjar --cookie-jar cjar -d '_ip_csrf={csrf_token}&btn_continue=Continue' {site_name}/setup/upgrade_tables"
|
2022-01-20 13:45:35 +00:00
|
|
|
)
|
|
|
|
'';
|
|
|
|
})
|