3 system ? builtins.currentSystem,
5 pkgs ? import ../.. { inherit system config; },
8 with import ../lib/testing-python.nix { inherit system pkgs; };
12 BIND_ADDRESS = '127.0.0.1'
14 CAPTCHA_ENABLE = False
20 name = "powerdns-admin-${name}";
21 meta = with pkgs.lib.maintainers; {
29 { pkgs, config, ... }:
33 services.powerdns-admin = {
35 secretKeyFile = "/etc/powerdns-admin/secret";
36 saltFile = "/etc/powerdns-admin/salt";
38 # It's insecure to have secrets in the world-readable nix store, but this is just a test
39 environment.etc."powerdns-admin/secret".text = "secret key";
40 environment.etc."powerdns-admin/salt".text = "salt";
41 environment.systemPackages = [
42 (pkgs.writeShellScriptBin "run-test" config.system.build.testScript)
50 server.wait_for_unit("powerdns-admin.service")
51 server.wait_until_succeeds("run-test", timeout=10)
58 services.powerdns-admin = {
61 SQLALCHEMY_DATABASE_URI = 'mysql://powerdnsadmin@/powerdnsadmin?unix_socket=/run/mysqld/mysqld.sock'
64 systemd.services.powerdns-admin = {
65 after = [ "mysql.service" ];
66 serviceConfig.BindPaths = "/run/mysqld";
71 package = pkgs.mariadb;
72 ensureDatabases = [ "powerdnsadmin" ];
75 name = "powerdnsadmin";
77 "powerdnsadmin.*" = "ALL PRIVILEGES";
84 services.powerdns-admin = {
87 SQLALCHEMY_DATABASE_URI = 'postgresql://powerdnsadmin@/powerdnsadmin?host=/run/postgresql'
90 systemd.services.powerdns-admin = {
91 after = [ "postgresql.service" ];
92 serviceConfig.BindPaths = "/run/postgresql";
95 services.postgresql = {
97 ensureDatabases = [ "powerdnsadmin" ];
100 name = "powerdnsadmin";
101 ensureDBOwnership = true;
109 services.powerdns-admin.extraArgs = [
113 system.build.testScript = ''
115 curl -sSf http://127.0.0.1:8000/
117 # Create account to check that the database migrations ran
118 csrf_token="$(curl -sSfc session http://127.0.0.1:8000/register | grep _csrf_token | cut -d\" -f6)"
119 # Outputs 'Redirecting' if successful
120 curl -sSfb session http://127.0.0.1:8000/register \
121 -F "_csrf_token=$csrf_token" \
122 -F "firstname=first" \
124 -F "email=a@example.com" \
126 -F "password=password" \
127 -F "rpassword=password" | grep Redirecting
130 # Outputs 'Redirecting' if successful
131 curl -sSfb session http://127.0.0.1:8000/login \
132 -F "_csrf_token=$csrf_token" \
134 -F "password=password" | grep Redirecting
136 # Check that we are logged in, this redirects to /admin/setting/pdns if we are
137 curl -sSfb session http://127.0.0.1:8000/dashboard/ | grep /admin/setting
141 services.powerdns-admin.extraArgs = [
143 "unix:/run/powerdns-admin/http.sock"
145 system.build.testScript = ''
146 curl -sSf --unix-socket /run/powerdns-admin/http.sock http://somehost/
154 postgresql = makeAppTest "postgresql" [
158 mysql = makeAppTest "mysql" [
162 unix-listener = makeAppTest "unix-listener" [