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