Skip to content

Commit

Permalink
nixos/acme: Move regression test into acme.nix
Browse files Browse the repository at this point in the history
  • Loading branch information
arianvp committed Apr 14, 2020
1 parent 13d643c commit 600cfe6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 61 deletions.
61 changes: 0 additions & 61 deletions nixos/tests/acme-issue-81842.nix

This file was deleted.

31 changes: 31 additions & 0 deletions nixos/tests/acme.nix
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ in import ./make-test-python.nix {
'';
};
};

specialisation.dns-01.configuration = {pkgs, config, nodes, lib, ...}: {
security.acme.certs."example.com" = {
domain = "*.example.com";
Expand Down Expand Up @@ -132,6 +133,26 @@ in import ./make-test-python.nix {
'';
};
};

# When nginx depends on a service that is slow to start up, requesting used to fail
# certificates fail. Reproducer for https://github.com/NixOS/nixpkgs/issues/81842
specialisation.slow-startup.configuration = { pkgs, config, nodes, lib, ...}: {
systemd.services.my-slow-service = {
wantedBy = [ "multi-user.target" "nginx.service" ];
before = [ "nginx.service" ];
preStart = "sleep 5";
script = "${pkgs.python3}/bin/python -m http.server";
};
systemd.targets."acme-finished-d.example.com" = {
after = [ "acme-d.example.com.service" ];
wantedBy = [ "acme-d.example.com.service" ];
};
services.nginx.virtualHosts."d.example.com" = {
forceSSL = true;
enableACME = true;
locations."/".proxyPass = "http://localhost:8000";
};
};
};

client = {nodes, lib, ...}: {
Expand Down Expand Up @@ -209,5 +230,15 @@ in import ./make-test-python.nix {
client.succeed(
"curl --cacert /tmp/ca.crt https://c.example.com/ | grep -qF 'hello world'"
)
with subtest("Can request certificate of nginx when startup is delayed"):
webserver.succeed(
"${switchToNewServer}"
)
webserver.succeed(
"/run/current-system/specialisation/slow-startup/bin/switch-to-configuration test"
)
webserver.wait_for_unit("acme-finished-d.example.com.target")
client.succeed("curl --cacert /tmp/ca.crt https://d.example.com/")
'';
}

0 comments on commit 600cfe6

Please sign in to comment.