2017-07-27 12:24:17 +01:00
|
|
|
let
|
2018-09-24 20:06:31 +01:00
|
|
|
commonConfig = ./common/letsencrypt/common.nix;
|
2017-07-27 12:24:17 +01:00
|
|
|
in import ./make-test.nix {
|
|
|
|
name = "acme";
|
|
|
|
|
|
|
|
nodes = {
|
2018-07-11 23:56:48 +01:00
|
|
|
letsencrypt = ./common/letsencrypt;
|
2017-07-27 12:24:17 +01:00
|
|
|
|
|
|
|
webserver = { config, pkgs, ... }: {
|
|
|
|
imports = [ commonConfig ];
|
|
|
|
networking.firewall.allowedTCPPorts = [ 80 443 ];
|
|
|
|
|
|
|
|
networking.extraHosts = ''
|
|
|
|
${config.networking.primaryIPAddress} example.com
|
|
|
|
'';
|
|
|
|
|
|
|
|
services.nginx.enable = true;
|
|
|
|
services.nginx.virtualHosts."example.com" = {
|
|
|
|
enableACME = true;
|
|
|
|
forceSSL = true;
|
|
|
|
locations."/".root = pkgs.runCommand "docroot" {} ''
|
|
|
|
mkdir -p "$out"
|
|
|
|
echo hello world > "$out/index.html"
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
client = commonConfig;
|
|
|
|
};
|
|
|
|
|
|
|
|
testScript = ''
|
2018-05-13 18:59:59 +01:00
|
|
|
$letsencrypt->waitForUnit("default.target");
|
2017-07-27 12:24:17 +01:00
|
|
|
$letsencrypt->waitForUnit("boulder.service");
|
2018-05-13 18:59:59 +01:00
|
|
|
$webserver->waitForUnit("default.target");
|
2017-07-27 12:24:17 +01:00
|
|
|
$webserver->waitForUnit("acme-certificates.target");
|
2018-05-13 18:59:59 +01:00
|
|
|
$client->waitForUnit("default.target");
|
2017-07-27 12:24:17 +01:00
|
|
|
$client->succeed('curl https://example.com/ | grep -qF "hello world"');
|
|
|
|
'';
|
|
|
|
}
|