···
1
-
import ./make-test-python.nix (
5
-
meta = with pkgs.lib.maintainers; {
4
+
meta = with pkgs.lib.maintainers; {
15
+
services.caddy.enable = true;
16
+
services.caddy.extraConfig = ''
22
+
pkgs.runCommand "testdir" { } ''
24
+
echo hello world > "$out/example.html"
29
+
services.caddy.enableReload = true;
16
-
services.caddy.enable = true;
31
+
specialisation.config-reload.configuration = {
services.caddy.extraConfig = ''
23
-
pkgs.runCommand "testdir" { } ''
25
-
echo hello world > "$out/example.html"
33
+
http://localhost:8080 {
30
-
services.caddy.enableReload = true;
32
-
specialisation.config-reload.configuration = {
33
-
services.caddy.extraConfig = ''
34
-
http://localhost:8080 {
37
+
specialisation.multiple-configs.configuration = {
38
+
services.caddy.virtualHosts = {
39
+
"http://localhost:8080" = { };
40
+
"http://localhost:8081" = { };
38
-
specialisation.multiple-configs.configuration = {
39
-
services.caddy.virtualHosts = {
40
-
"http://localhost:8080" = { };
41
-
"http://localhost:8081" = { };
43
+
specialisation.multiple-hostnames.configuration = {
44
+
services.caddy.virtualHosts = {
45
+
"http://localhost:8080 http://localhost:8081" = { };
44
-
specialisation.multiple-hostnames.configuration = {
45
-
services.caddy.virtualHosts = {
46
-
"http://localhost:8080 http://localhost:8081" = { };
48
+
specialisation.rfc42.configuration = {
49
+
services.caddy.settings = {
50
+
apps.http.servers.default = {
56
+
body = "hello world";
57
+
handler = "static_response";
49
-
specialisation.rfc42.configuration = {
50
-
services.caddy.settings = {
51
-
apps.http.servers.default = {
57
-
body = "hello world";
58
-
handler = "static_response";
66
+
specialisation.explicit-config-file.configuration = {
67
+
services.caddy.configFile = pkgs.writeText "Caddyfile" ''
70
+
respond "hello world"
73
+
specialisation.with-plugins.configuration = {
75
+
package = pkgs.caddy.withPlugins {
76
+
plugins = [ "github.com/caddyserver/replace-response@v0.0.0-20241211194404-3865845790a7" ];
77
+
hash = "sha256-WPmJPnyOrAnuJxvn3ywswqvLGV8SZzzn3gU1Tbtpao4=";
67
-
specialisation.explicit-config-file.configuration = {
68
-
services.caddy.configFile = pkgs.writeText "Caddyfile" ''
79
+
configFile = pkgs.writeText "Caddyfile" ''
81
+
order replace after encode
71
-
respond "hello world"
85
+
respond "hello world"
74
-
specialisation.with-plugins.configuration = {
76
-
package = pkgs.caddy.withPlugins {
77
-
plugins = [ "github.com/caddyserver/replace-response@v0.0.0-20241211194404-3865845790a7" ];
78
-
hash = "sha256-WPmJPnyOrAnuJxvn3ywswqvLGV8SZzzn3gU1Tbtpao4=";
80
-
configFile = pkgs.writeText "Caddyfile" ''
82
-
order replace after encode
86
-
respond "hello world"
98
-
explicitConfigFile = "${nodes.webserver.system.build.toplevel}/specialisation/explicit-config-file";
99
-
justReloadSystem = "${nodes.webserver.system.build.toplevel}/specialisation/config-reload";
100
-
multipleConfigs = "${nodes.webserver.system.build.toplevel}/specialisation/multiple-configs";
101
-
multipleHostnames = "${nodes.webserver.system.build.toplevel}/specialisation/multiple-hostnames";
102
-
rfc42Config = "${nodes.webserver.system.build.toplevel}/specialisation/rfc42";
103
-
withPluginsConfig = "${nodes.webserver.system.build.toplevel}/specialisation/with-plugins";
106
-
url = "http://localhost/example.html"
107
-
webserver.wait_for_unit("caddy")
108
-
webserver.wait_for_open_port(80)
97
+
explicitConfigFile = "${nodes.webserver.system.build.toplevel}/specialisation/explicit-config-file";
98
+
justReloadSystem = "${nodes.webserver.system.build.toplevel}/specialisation/config-reload";
99
+
multipleConfigs = "${nodes.webserver.system.build.toplevel}/specialisation/multiple-configs";
100
+
multipleHostnames = "${nodes.webserver.system.build.toplevel}/specialisation/multiple-hostnames";
101
+
rfc42Config = "${nodes.webserver.system.build.toplevel}/specialisation/rfc42";
102
+
withPluginsConfig = "${nodes.webserver.system.build.toplevel}/specialisation/with-plugins";
105
+
url = "http://localhost/example.html"
106
+
webserver.wait_for_unit("caddy")
107
+
webserver.wait_for_open_port(80)
111
-
with subtest("config is reloaded on nixos-rebuild switch"):
113
-
"${justReloadSystem}/bin/switch-to-configuration test >&2"
115
-
webserver.wait_for_open_port(8080)
116
-
webserver.fail("journalctl -u caddy | grep -q -i stopped")
117
-
webserver.succeed("journalctl -u caddy | grep -q -i reloaded")
110
+
with subtest("config is reloaded on nixos-rebuild switch"):
112
+
"${justReloadSystem}/bin/switch-to-configuration test >&2"
114
+
webserver.wait_for_open_port(8080)
115
+
webserver.fail("journalctl -u caddy | grep -q -i stopped")
116
+
webserver.succeed("journalctl -u caddy | grep -q -i reloaded")
119
-
with subtest("multiple configs are correctly merged"):
121
-
"${multipleConfigs}/bin/switch-to-configuration test >&2"
123
-
webserver.wait_for_open_port(8080)
124
-
webserver.wait_for_open_port(8081)
118
+
with subtest("multiple configs are correctly merged"):
120
+
"${multipleConfigs}/bin/switch-to-configuration test >&2"
122
+
webserver.wait_for_open_port(8080)
123
+
webserver.wait_for_open_port(8081)
126
-
with subtest("a virtual host with multiple hostnames works"):
128
-
"${multipleHostnames}/bin/switch-to-configuration test >&2"
130
-
webserver.wait_for_open_port(8080)
131
-
webserver.wait_for_open_port(8081)
125
+
with subtest("a virtual host with multiple hostnames works"):
127
+
"${multipleHostnames}/bin/switch-to-configuration test >&2"
129
+
webserver.wait_for_open_port(8080)
130
+
webserver.wait_for_open_port(8081)
133
-
with subtest("rfc42 settings config"):
135
-
"${rfc42Config}/bin/switch-to-configuration test >&2"
137
-
webserver.wait_for_open_port(80)
138
-
webserver.succeed("curl http://localhost | grep hello")
132
+
with subtest("rfc42 settings config"):
134
+
"${rfc42Config}/bin/switch-to-configuration test >&2"
136
+
webserver.wait_for_open_port(80)
137
+
webserver.succeed("curl http://localhost | grep hello")
140
-
with subtest("explicit configFile"):
142
-
"${explicitConfigFile}/bin/switch-to-configuration test >&2"
144
-
webserver.wait_for_open_port(80)
145
-
webserver.succeed("curl http://localhost | grep hello")
139
+
with subtest("explicit configFile"):
141
+
"${explicitConfigFile}/bin/switch-to-configuration test >&2"
143
+
webserver.wait_for_open_port(80)
144
+
webserver.succeed("curl http://localhost | grep hello")
147
-
with subtest("plugins are correctled installed and configurable"):
149
-
"${withPluginsConfig}/bin/switch-to-configuration test >&2"
151
-
webserver.wait_for_open_port(80)
152
-
webserver.succeed("curl http://localhost | grep caddy")
146
+
with subtest("plugins are correctled installed and configurable"):
148
+
"${withPluginsConfig}/bin/switch-to-configuration test >&2"
150
+
webserver.wait_for_open_port(80)
151
+
webserver.succeed("curl http://localhost | grep caddy")