depot/third_party/nixpkgs/nixos/tests/pgmanage.nix
Default email 8ac5e011d6 Project import generated by Copybara.
GitOrigin-RevId: 2c3273caa153ee8eb5786bc8141b85b859e7efd7
2020-04-24 19:36:52 -04:00

41 lines
1 KiB
Nix

import ./make-test-python.nix ({ pkgs, ... } :
let
role = "test";
password = "secret";
conn = "local";
in
{
name = "pgmanage";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ basvandijk ];
};
nodes = {
one = { config, pkgs, ... }: {
services = {
postgresql = {
enable = true;
initialScript = pkgs.writeText "pg-init-script" ''
CREATE ROLE ${role} SUPERUSER LOGIN PASSWORD '${password}';
'';
};
pgmanage = {
enable = true;
connections = {
${conn} = "hostaddr=127.0.0.1 port=${toString config.services.postgresql.port} dbname=postgres";
};
};
};
};
};
testScript = ''
start_all()
one.wait_for_unit("default.target")
one.require_unit_state("pgmanage.service", "active")
# Test if we can log in.
one.wait_until_succeeds(
"curl 'http://localhost:8080/pgmanage/auth' --data 'action=login&connname=${conn}&username=${role}&password=${password}' --fail"
)
'';
})