|
1 | | -import ./make-test-python.nix ( |
2 | | - { pkgs, lib, ... }: |
| 1 | +{ lib, ... }: |
3 | 2 |
|
4 | | - { |
5 | | - name = "pgadmin4"; |
6 | | - meta.maintainers = with lib.maintainers; [ |
7 | | - mkg20001 |
8 | | - gador |
9 | | - ]; |
| 3 | +{ |
| 4 | + name = "pgadmin4"; |
| 5 | + meta.maintainers = with lib.maintainers; [ |
| 6 | + mkg20001 |
| 7 | + gador |
| 8 | + ]; |
10 | 9 |
|
11 | | - nodes = { |
12 | | - machine = |
13 | | - { pkgs, ... }: |
14 | | - { |
| 10 | + nodes = { |
| 11 | + machine = |
| 12 | + { pkgs, ... }: |
| 13 | + { |
15 | 14 |
|
16 | | - imports = [ ./common/user-account.nix ]; |
| 15 | + imports = [ ./common/user-account.nix ]; |
17 | 16 |
|
18 | | - environment.systemPackages = with pkgs; [ |
19 | | - wget |
20 | | - curl |
21 | | - pgadmin4-desktopmode |
22 | | - ]; |
| 17 | + environment.systemPackages = with pkgs; [ |
| 18 | + wget |
| 19 | + curl |
| 20 | + pgadmin4-desktopmode |
| 21 | + ]; |
23 | 22 |
|
24 | | - services.postgresql = { |
25 | | - enable = true; |
26 | | - authentication = '' |
27 | | - host all all localhost trust |
28 | | - ''; |
29 | | - }; |
| 23 | + services.postgresql = { |
| 24 | + enable = true; |
| 25 | + authentication = '' |
| 26 | + host all all localhost trust |
| 27 | + ''; |
| 28 | + }; |
30 | 29 |
|
31 | | - services.pgadmin = { |
32 | | - port = 5051; |
33 | | - enable = true; |
34 | | - initialEmail = "[email protected]"; |
35 | | - initialPasswordFile = pkgs.writeText "pw" "bruh2012!"; |
36 | | - }; |
| 30 | + services.pgadmin = { |
| 31 | + port = 5051; |
| 32 | + enable = true; |
| 33 | + initialEmail = "[email protected]"; |
| 34 | + initialPasswordFile = pkgs.writeText "pw" "bruh2012!"; |
37 | 35 | }; |
38 | | - machine2 = |
39 | | - { pkgs, ... }: |
40 | | - { |
| 36 | + }; |
| 37 | + machine2 = |
| 38 | + { pkgs, ... }: |
| 39 | + { |
41 | 40 |
|
42 | | - imports = [ ./common/user-account.nix ]; |
| 41 | + imports = [ ./common/user-account.nix ]; |
43 | 42 |
|
44 | | - services.postgresql = { |
45 | | - enable = true; |
46 | | - }; |
| 43 | + services.postgresql = { |
| 44 | + enable = true; |
| 45 | + }; |
47 | 46 |
|
48 | | - services.pgadmin = { |
49 | | - enable = true; |
50 | | - initialEmail = "[email protected]"; |
51 | | - initialPasswordFile = pkgs.writeText "pw" "bruh2012!"; |
52 | | - minimumPasswordLength = 12; |
53 | | - }; |
| 47 | + services.pgadmin = { |
| 48 | + enable = true; |
| 49 | + initialEmail = "[email protected]"; |
| 50 | + initialPasswordFile = pkgs.writeText "pw" "bruh2012!"; |
| 51 | + minimumPasswordLength = 12; |
54 | 52 | }; |
55 | | - }; |
| 53 | + }; |
| 54 | + }; |
56 | 55 |
|
57 | | - testScript = '' |
58 | | - with subtest("Check pgadmin module"): |
59 | | - machine.wait_for_unit("postgresql") |
60 | | - machine.wait_for_unit("pgadmin") |
61 | | - machine.wait_until_succeeds("curl -sS localhost:5051") |
62 | | - machine.wait_until_succeeds("curl -sS localhost:5051/login | grep \"<title>pgAdmin 4</title>\" > /dev/null") |
63 | | - # check for missing support files (css, js etc). Should catch not-generated files during build. See e.g. https://github.com/NixOS/nixpkgs/pull/229184 |
64 | | - machine.succeed("wget -nv --level=1 --spider --recursive localhost:5051/login") |
65 | | - # test idempotenceny |
66 | | - machine.systemctl("restart pgadmin.service") |
67 | | - machine.wait_for_unit("pgadmin") |
68 | | - machine.wait_until_succeeds("curl -sS localhost:5051") |
69 | | - machine.wait_until_succeeds("curl -sS localhost:5051/login | grep \"<title>pgAdmin 4</title>\" > /dev/null") |
| 56 | + testScript = '' |
| 57 | + with subtest("Check pgadmin module"): |
| 58 | + machine.wait_for_unit("postgresql") |
| 59 | + machine.wait_for_unit("pgadmin") |
| 60 | + machine.wait_until_succeeds("curl -sS localhost:5051") |
| 61 | + machine.wait_until_succeeds("curl -sS localhost:5051/login | grep \"<title>pgAdmin 4</title>\" > /dev/null") |
| 62 | + # check for missing support files (css, js etc). Should catch not-generated files during build. See e.g. https://github.com/NixOS/nixpkgs/pull/229184 |
| 63 | + machine.succeed("wget -nv --level=1 --spider --recursive localhost:5051/login") |
| 64 | + # test idempotenceny |
| 65 | + machine.systemctl("restart pgadmin.service") |
| 66 | + machine.wait_for_unit("pgadmin") |
| 67 | + machine.wait_until_succeeds("curl -sS localhost:5051") |
| 68 | + machine.wait_until_succeeds("curl -sS localhost:5051/login | grep \"<title>pgAdmin 4</title>\" > /dev/null") |
70 | 69 |
|
71 | | - # pgadmin4 module saves the configuration to /etc/pgadmin/config_system.py |
72 | | - # pgadmin4-desktopmode tries to read that as well. This normally fails with a PermissionError, as the config file |
73 | | - # is owned by the user of the pgadmin module. With the check-system-config-dir.patch this will just throw a warning |
74 | | - # but will continue and not read the file. |
75 | | - # If we run pgadmin4-desktopmode as root (something one really shouldn't do), it can read the config file and fail, |
76 | | - # because of the wrong config for desktopmode. |
77 | | - with subtest("Check pgadmin standalone desktop mode"): |
78 | | - machine.execute("sudo -u alice pgadmin4 >&2 &", timeout=60) |
79 | | - machine.wait_until_succeeds("curl -sS localhost:5050") |
80 | | - machine.wait_until_succeeds("curl -sS localhost:5050/browser/ | grep \"<title>pgAdmin 4</title>\" > /dev/null") |
81 | | - machine.succeed("wget -nv --level=1 --spider --recursive localhost:5050/browser") |
| 70 | + # pgadmin4 module saves the configuration to /etc/pgadmin/config_system.py |
| 71 | + # pgadmin4-desktopmode tries to read that as well. This normally fails with a PermissionError, as the config file |
| 72 | + # is owned by the user of the pgadmin module. With the check-system-config-dir.patch this will just throw a warning |
| 73 | + # but will continue and not read the file. |
| 74 | + # If we run pgadmin4-desktopmode as root (something one really shouldn't do), it can read the config file and fail, |
| 75 | + # because of the wrong config for desktopmode. |
| 76 | + with subtest("Check pgadmin standalone desktop mode"): |
| 77 | + machine.execute("sudo -u alice pgadmin4 >&2 &", timeout=60) |
| 78 | + machine.wait_until_succeeds("curl -sS localhost:5050") |
| 79 | + machine.wait_until_succeeds("curl -sS localhost:5050/browser/ | grep \"<title>pgAdmin 4</title>\" > /dev/null") |
| 80 | + machine.succeed("wget -nv --level=1 --spider --recursive localhost:5050/browser") |
82 | 81 |
|
83 | | - with subtest("Check pgadmin minimum password length"): |
84 | | - machine2.wait_for_unit("postgresql") |
85 | | - machine2.wait_for_console_text("Password must be at least 12 characters long") |
86 | | - ''; |
87 | | - } |
88 | | -) |
| 82 | + with subtest("Check pgadmin minimum password length"): |
| 83 | + machine2.wait_for_unit("postgresql") |
| 84 | + machine2.wait_for_console_text("Password must be at least 12 characters long") |
| 85 | + ''; |
| 86 | +} |
0 commit comments