From a466b8cc12e79ae27fc2de1b303682aa81212a36 Mon Sep 17 00:00:00 2001 From: Yifei Sun Date: Fri, 27 Dec 2024 18:26:54 -0500 Subject: [PATCH] nixos/tests/caddy: add pkgs.caddy.withPlugins test --- nixos/tests/caddy.nix | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/nixos/tests/caddy.nix b/nixos/tests/caddy.nix index 57fe16f92d377..36d0051cf0370 100644 --- a/nixos/tests/caddy.nix +++ b/nixos/tests/caddy.nix @@ -3,12 +3,15 @@ import ./make-test-python.nix ( { name = "caddy"; meta = with pkgs.lib.maintainers; { - maintainers = [ Br1ght0ne ]; + maintainers = [ + Br1ght0ne + stepbrobd + ]; }; nodes = { webserver = - { pkgs, lib, ... }: + { pkgs, ... }: { services.caddy.enable = true; services.caddy.extraConfig = '' @@ -63,6 +66,24 @@ import ./make-test-python.nix ( respond "hello world" ''; }; + specialisation.with-plugins.configuration = { + services.caddy = { + package = pkgs.caddy.withPlugins { + plugins = [ "github.com/caddyserver/replace-response@v0.0.0-20241211194404-3865845790a7" ]; + hash = "sha256-zgMdtOJbmtRSfTlrrg8njr11in2C7OAXLB+34V23jek="; + }; + configFile = pkgs.writeText "Caddyfile" '' + { + order replace after encode + } + + localhost:80 { + respond "hello world" + replace world caddy + } + ''; + }; + }; }; }; @@ -73,6 +94,7 @@ import ./make-test-python.nix ( justReloadSystem = "${nodes.webserver.system.build.toplevel}/specialisation/config-reload"; multipleConfigs = "${nodes.webserver.system.build.toplevel}/specialisation/multiple-configs"; rfc42Config = "${nodes.webserver.system.build.toplevel}/specialisation/rfc42"; + withPluginsConfig = "${nodes.webserver.system.build.toplevel}/specialisation/with-plugins"; in '' url = "http://localhost/example.html" @@ -108,6 +130,13 @@ import ./make-test-python.nix ( ) webserver.wait_for_open_port(80) webserver.succeed("curl http://localhost | grep hello") + + with subtest("plugins are correctled installed and configurable"): + webserver.succeed( + "${withPluginsConfig}/bin/switch-to-configuration test >&2" + ) + webserver.wait_for_open_port(80) + webserver.succeed("curl http://localhost | grep caddy") ''; } )