vuls: init at 0.27.0 (#348530)
[NixPkgs.git] / nixos / tests / invoiceplane.nix
blob0b51707171996711a7a86f8f2d4678215b97d7ea
1 import ./make-test-python.nix ({ pkgs, ... }:
4   name = "invoiceplane";
5   meta = with pkgs.lib.maintainers; {
6     maintainers = [
7       onny
8     ];
9   };
11   nodes = {
12     invoiceplane_caddy = { ... }: {
13       services.invoiceplane.webserver = "caddy";
14       services.invoiceplane.sites = {
15         "site1.local" = {
16           database.name = "invoiceplane1";
17           database.createLocally = true;
18           enable = true;
19         };
20         "site2.local" = {
21           database.name = "invoiceplane2";
22           database.createLocally = true;
23           enable = true;
24         };
25       };
27       networking.firewall.allowedTCPPorts = [ 80 ];
28       networking.hosts."127.0.0.1" = [ "site1.local" "site2.local" ];
29     };
31     invoiceplane_nginx = { ... }: {
32       services.invoiceplane.webserver = "nginx";
33       services.invoiceplane.sites = {
34         "site1.local" = {
35           database.name = "invoiceplane1";
36           database.createLocally = true;
37           enable = true;
38         };
39         "site2.local" = {
40           database.name = "invoiceplane2";
41           database.createLocally = true;
42           enable = true;
43         };
44       };
46       networking.firewall.allowedTCPPorts = [ 80 ];
47       networking.hosts."127.0.0.1" = [ "site1.local" "site2.local" ];
48     };
49   };
51   testScript = ''
52     start_all()
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"):
72             machine.succeed(
73               f"curl -sSfL --cookie-jar cjar {site_name}/setup/language"
74             )
75             csrf_token = machine.succeed(
76               "grep ip_csrf_cookie cjar | cut -f 7 | tr -d '\n'"
77             )
78             machine.succeed(
79               f"curl -sSfL --cookie cjar --cookie-jar cjar -d '_ip_csrf={csrf_token}&ip_lang=english&btn_continue=Continue' {site_name}/setup/language"
80             )
81             csrf_token = machine.succeed(
82               "grep ip_csrf_cookie cjar | cut -f 7 | tr -d '\n'"
83             )
84             machine.succeed(
85               f"curl -sSfL --cookie cjar --cookie-jar cjar -d '_ip_csrf={csrf_token}&btn_continue=Continue' {site_name}/setup/prerequisites"
86             )
87             csrf_token = machine.succeed(
88               "grep ip_csrf_cookie cjar | cut -f 7 | tr -d '\n'"
89             )
90             machine.succeed(
91               f"curl -sSfL --cookie cjar --cookie-jar cjar -d '_ip_csrf={csrf_token}&btn_continue=Continue' {site_name}/setup/configure_database"
92             )
93             csrf_token = machine.succeed(
94               "grep ip_csrf_cookie cjar | cut -f 7 | tr -d '\n'"
95             )
96             machine.succeed(
97               f"curl -sSfl --cookie cjar --cookie-jar cjar -d '_ip_csrf={csrf_token}&btn_continue=Continue' {site_name}/setup/install_tables"
98             )
99             csrf_token = machine.succeed(
100               "grep ip_csrf_cookie cjar | cut -f 7 | tr -d '\n'"
101             )
102             machine.succeed(
103               f"curl -sSfl --cookie cjar --cookie-jar cjar -d '_ip_csrf={csrf_token}&btn_continue=Continue' {site_name}/setup/upgrade_tables"
104             )
105   '';