2017-11-02 20:35:05 +01:00
|
|
|
import ./make-test.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 = {
|
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 = ''
|
|
|
|
startAll;
|
|
|
|
$one->waitForUnit("default.target");
|
|
|
|
$one->requireActiveUnit("pgmanage.service");
|
|
|
|
|
|
|
|
# Test if we can log in.
|
|
|
|
$one->waitUntilSucceeds("curl 'http://localhost:8080/pgmanage/auth' --data 'action=login&connname=${conn}&username=${role}&password=${password}' --fail");
|
|
|
|
'';
|
|
|
|
})
|