Skip to content

Commit

Permalink
nixos/tests/caddy: add pkgs.caddy.withPlugins test
Browse files Browse the repository at this point in the history
  • Loading branch information
stepbrobd committed Dec 27, 2024
1 parent f5bb81d commit 1ce5795
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions nixos/tests/caddy.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ''
Expand Down Expand Up @@ -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/[email protected]" ];
hash = "sha256-zgMdtOJbmtRSfTlrrg8njr11in2C7OAXLB+34V23jek=";
};
configFile = pkgs.writeText "Caddyfile" ''
{
order replace after encode
}
localhost:80 {
respond "hello world"
replace world caddy
}
'';
};
};
};
};

Expand All @@ -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"
Expand Down Expand Up @@ -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")
'';
}
)

0 comments on commit 1ce5795

Please sign in to comment.