2019-12-15 17:48:18 +00:00
|
|
|
import ./make-test-python.nix ({ pkgs, ... } :
|
2017-11-02 19:35:05 +00:00
|
|
|
let
|
|
|
|
role = "test";
|
|
|
|
password = "secret";
|
|
|
|
conn = "local";
|
|
|
|
in
|
|
|
|
{
|
|
|
|
name = "pgmanage";
|
2021-01-10 19:08:30 +00:00
|
|
|
meta = with pkgs.lib.maintainers; {
|
2017-11-02 19:35:05 +00:00
|
|
|
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 = {
|
2019-08-13 21:52:01 +00:00
|
|
|
${conn} = "hostaddr=127.0.0.1 port=${toString config.services.postgresql.port} dbname=postgres";
|
2017-11-02 19:35:05 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
testScript = ''
|
2019-12-15 17:48:18 +00:00
|
|
|
start_all()
|
|
|
|
one.wait_for_unit("default.target")
|
|
|
|
one.require_unit_state("pgmanage.service", "active")
|
2017-11-02 19:35:05 +00:00
|
|
|
|
|
|
|
# Test if we can log in.
|
2019-12-15 17:48:18 +00:00
|
|
|
one.wait_until_succeeds(
|
|
|
|
"curl 'http://localhost:8080/pgmanage/auth' --data 'action=login&connname=${conn}&username=${role}&password=${password}' --fail"
|
|
|
|
)
|
2017-11-02 19:35:05 +00:00
|
|
|
'';
|
|
|
|
})
|