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 Jun 15, 2020
1 parent cfd672a commit 0952336
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 @@ -99,6 +99,7 @@ in import ./make-test-python.nix ({ lib, ... }: {
'';
};
};

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

# 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 @@ -204,5 +225,15 @@ in import ./make-test-python.nix ({ lib, ... }: {
client.succeed(
"curl --cacert /tmp/ca.crt https://c.example.test/ | 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 0952336

Please sign in to comment.