at master 3.1 kB view raw
1{ lib, ... }: 2 3{ 4 name = "pgadmin4"; 5 meta.maintainers = with lib.maintainers; [ 6 mkg20001 7 gador 8 ]; 9 10 nodes = { 11 machine = 12 { pkgs, ... }: 13 { 14 15 imports = [ ./common/user-account.nix ]; 16 17 environment.systemPackages = with pkgs; [ 18 wget 19 curl 20 pgadmin4-desktopmode 21 ]; 22 23 services.postgresql = { 24 enable = true; 25 authentication = '' 26 host all all localhost trust 27 ''; 28 }; 29 30 services.pgadmin = { 31 port = 5051; 32 enable = true; 33 initialEmail = "bruh@localhost.de"; 34 initialPasswordFile = pkgs.writeText "pw" "bruh2012!"; 35 }; 36 }; 37 machine2 = 38 { pkgs, ... }: 39 { 40 41 imports = [ ./common/user-account.nix ]; 42 43 services.postgresql = { 44 enable = true; 45 }; 46 47 services.pgadmin = { 48 enable = true; 49 initialEmail = "bruh@localhost.de"; 50 initialPasswordFile = pkgs.writeText "pw" "bruh2012!"; 51 minimumPasswordLength = 12; 52 }; 53 }; 54 }; 55 56 testScript = '' 57 with subtest("Check pgadmin module"): 58 machine.wait_for_unit("postgresql.target") 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") 69 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") 81 82 with subtest("Check pgadmin minimum password length"): 83 machine2.wait_for_unit("postgresql.target") 84 machine2.wait_for_console_text("Password must be at least 12 characters long") 85 ''; 86}