at 23.11-pre 2.4 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.machine = { pkgs, ... }: { 8 9 imports = [ ./common/user-account.nix ]; 10 11 environment.systemPackages = with pkgs; [ 12 wget 13 curl 14 pgadmin4-desktopmode 15 ]; 16 17 services.postgresql = { 18 enable = true; 19 authentication = '' 20 host all all localhost trust 21 ''; 22 ensureUsers = [ 23 { 24 name = "postgres"; 25 ensurePermissions = { 26 "DATABASE \"postgres\"" = "ALL PRIVILEGES"; 27 }; 28 } 29 ]; 30 }; 31 32 services.pgadmin = { 33 port = 5051; 34 enable = true; 35 initialEmail = "bruh@localhost.de"; 36 initialPasswordFile = pkgs.writeText "pw" "bruh2012!"; 37 }; 38 }; 39 40 testScript = '' 41 with subtest("Check pgadmin module"): 42 machine.wait_for_unit("postgresql") 43 machine.wait_for_unit("pgadmin") 44 machine.wait_until_succeeds("curl -sS localhost:5051") 45 machine.wait_until_succeeds("curl -sS localhost:5051/login | grep \"<title>pgAdmin 4</title>\" > /dev/null") 46 # 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 47 machine.succeed("wget -nv --level=1 --spider --recursive localhost:5051/login") 48 49 # pgadmin4 module saves the configuration to /etc/pgadmin/config_system.py 50 # pgadmin4-desktopmode tries to read that as well. This normally fails with a PermissionError, as the config file 51 # is owned by the user of the pgadmin module. With the check-system-config-dir.patch this will just throw a warning 52 # but will continue and not read the file. 53 # If we run pgadmin4-desktopmode as root (something one really shouldn't do), it can read the config file and fail, 54 # because of the wrong config for desktopmode. 55 with subtest("Check pgadmin standalone desktop mode"): 56 machine.execute("sudo -u alice pgadmin4 >&2 &", timeout=60) 57 machine.wait_until_succeeds("curl -sS localhost:5050") 58 machine.wait_until_succeeds("curl -sS localhost:5050/browser/ | grep \"<title>pgAdmin 4</title>\" > /dev/null") 59 machine.succeed("wget -nv --level=1 --spider --recursive localhost:5050/browser") 60 ''; 61})