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