···
-
import ./make-test-python.nix (
-
meta = with pkgs.lib.maintainers; {
-
services.caddy.enable = true;
services.caddy.extraConfig = ''
-
pkgs.runCommand "testdir" { } ''
-
echo hello world > "$out/example.html"
-
services.caddy.enableReload = true;
-
specialisation.config-reload.configuration = {
-
services.caddy.extraConfig = ''
-
http://localhost:8080 {
-
specialisation.multiple-configs.configuration = {
-
services.caddy.virtualHosts = {
-
"http://localhost:8080" = { };
-
"http://localhost:8081" = { };
-
specialisation.multiple-hostnames.configuration = {
-
services.caddy.virtualHosts = {
-
"http://localhost:8080 http://localhost:8081" = { };
-
specialisation.rfc42.configuration = {
-
services.caddy.settings = {
-
apps.http.servers.default = {
-
handler = "static_response";
-
specialisation.explicit-config-file.configuration = {
-
services.caddy.configFile = pkgs.writeText "Caddyfile" ''
-
specialisation.with-plugins.configuration = {
-
package = pkgs.caddy.withPlugins {
-
plugins = [ "github.com/caddyserver/replace-response@v0.0.0-20241211194404-3865845790a7" ];
-
hash = "sha256-WPmJPnyOrAnuJxvn3ywswqvLGV8SZzzn3gU1Tbtpao4=";
-
configFile = pkgs.writeText "Caddyfile" ''
-
order replace after encode
-
explicitConfigFile = "${nodes.webserver.system.build.toplevel}/specialisation/explicit-config-file";
-
justReloadSystem = "${nodes.webserver.system.build.toplevel}/specialisation/config-reload";
-
multipleConfigs = "${nodes.webserver.system.build.toplevel}/specialisation/multiple-configs";
-
multipleHostnames = "${nodes.webserver.system.build.toplevel}/specialisation/multiple-hostnames";
-
rfc42Config = "${nodes.webserver.system.build.toplevel}/specialisation/rfc42";
-
withPluginsConfig = "${nodes.webserver.system.build.toplevel}/specialisation/with-plugins";
-
url = "http://localhost/example.html"
-
webserver.wait_for_unit("caddy")
-
webserver.wait_for_open_port(80)
-
with subtest("config is reloaded on nixos-rebuild switch"):
-
"${justReloadSystem}/bin/switch-to-configuration test >&2"
-
webserver.wait_for_open_port(8080)
-
webserver.fail("journalctl -u caddy | grep -q -i stopped")
-
webserver.succeed("journalctl -u caddy | grep -q -i reloaded")
-
with subtest("multiple configs are correctly merged"):
-
"${multipleConfigs}/bin/switch-to-configuration test >&2"
-
webserver.wait_for_open_port(8080)
-
webserver.wait_for_open_port(8081)
-
with subtest("a virtual host with multiple hostnames works"):
-
"${multipleHostnames}/bin/switch-to-configuration test >&2"
-
webserver.wait_for_open_port(8080)
-
webserver.wait_for_open_port(8081)
-
with subtest("rfc42 settings config"):
-
"${rfc42Config}/bin/switch-to-configuration test >&2"
-
webserver.wait_for_open_port(80)
-
webserver.succeed("curl http://localhost | grep hello")
-
with subtest("explicit configFile"):
-
"${explicitConfigFile}/bin/switch-to-configuration test >&2"
-
webserver.wait_for_open_port(80)
-
webserver.succeed("curl http://localhost | grep hello")
-
with subtest("plugins are correctled installed and configurable"):
-
"${withPluginsConfig}/bin/switch-to-configuration test >&2"
-
webserver.wait_for_open_port(80)
-
webserver.succeed("curl http://localhost | grep caddy")