2023-01-05 02:38:22 +00:00
|
|
|
import ./make-test-python.nix (
|
|
|
|
{ lib, pkgs, ... }:
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2023-01-05 02:38:22 +00:00
|
|
|
rec {
|
2016-09-26 18:06:56 -04:00
|
|
|
name = "wordpress";
|
2024-09-19 22:25:37 +02:00
|
|
|
meta = with pkgs.lib.maintainers; {
|
2020-04-06 09:25:07 +02:00
|
|
|
maintainers = [
|
2019-06-02 10:36:14 -04:00
|
|
|
flokli
|
2023-01-05 02:38:22 +00:00
|
|
|
grahamc # under duress!
|
2022-01-23 15:17:01 +01:00
|
|
|
mmilata
|
2020-04-06 09:25:07 +02:00
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2024-12-10 20:26:33 +01:00
|
|
|
nodes =
|
2023-01-05 02:38:22 +00:00
|
|
|
lib.foldl
|
2024-12-10 20:26:33 +01:00
|
|
|
(
|
2023-01-05 02:38:22 +00:00
|
|
|
a: version:
|
2024-12-10 20:26:33 +01:00
|
|
|
let
|
2024-09-19 22:25:37 +02:00
|
|
|
package = pkgs."wordpress_${version}";
|
2023-01-05 02:38:22 +00:00
|
|
|
in
|
2024-12-10 20:26:33 +01:00
|
|
|
a
|
|
|
|
// {
|
2023-01-05 02:38:22 +00:00
|
|
|
"wp${version}_httpd" = _: {
|
2020-04-06 09:25:07 +02:00
|
|
|
services.httpd.adminAddr = "webmaster@site.local";
|
2019-06-02 10:36:14 -04:00
|
|
|
services.httpd.logPerVirtualHost = true;
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2020-04-06 09:25:07 +02:00
|
|
|
services.wordpress.webserver = "httpd";
|
|
|
|
services.wordpress.sites = {
|
|
|
|
"site1.local" = {
|
|
|
|
database.tablePrefix = "site1_";
|
2023-01-05 02:38:22 +00:00
|
|
|
inherit package;
|
2020-04-06 09:25:07 +02:00
|
|
|
};
|
|
|
|
"site2.local" = {
|
|
|
|
database.tablePrefix = "site2_";
|
2023-01-05 02:38:22 +00:00
|
|
|
inherit package;
|
2019-06-02 10:36:14 -04:00
|
|
|
};
|
2024-12-10 20:26:33 +01:00
|
|
|
};
|
|
|
|
|
2020-04-06 09:25:07 +02:00
|
|
|
networking.firewall.allowedTCPPorts = [ 80 ];
|
2019-06-02 10:36:14 -04:00
|
|
|
networking.hosts."127.0.0.1" = [
|
|
|
|
"site1.local"
|
|
|
|
"site2.local"
|
|
|
|
];
|
|
|
|
};
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2023-01-05 02:38:22 +00:00
|
|
|
"wp${version}_nginx" = _: {
|
2021-08-03 15:24:34 +02:00
|
|
|
services.wordpress.webserver = "nginx";
|
|
|
|
services.wordpress.sites = {
|
|
|
|
"site1.local" = {
|
|
|
|
database.tablePrefix = "site1_";
|
2023-01-05 02:38:22 +00:00
|
|
|
inherit package;
|
2021-08-03 15:24:34 +02:00
|
|
|
};
|
|
|
|
"site2.local" = {
|
|
|
|
database.tablePrefix = "site2_";
|
2023-01-05 02:38:22 +00:00
|
|
|
inherit package;
|
2024-12-10 20:26:33 +01:00
|
|
|
};
|
2021-08-03 15:24:34 +02:00
|
|
|
};
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2021-08-03 15:24:34 +02:00
|
|
|
networking.firewall.allowedTCPPorts = [ 80 ];
|
|
|
|
networking.hosts."127.0.0.1" = [
|
|
|
|
"site1.local"
|
|
|
|
"site2.local"
|
|
|
|
];
|
|
|
|
};
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2023-01-05 02:38:22 +00:00
|
|
|
"wp${version}_caddy" = _: {
|
|
|
|
services.wordpress.webserver = "caddy";
|
2022-01-23 15:17:01 +01:00
|
|
|
services.wordpress.sites = {
|
2023-01-05 02:38:22 +00:00
|
|
|
"site1.local" = {
|
2020-04-06 09:25:07 +02:00
|
|
|
database.tablePrefix = "site1_";
|
2023-01-05 02:38:22 +00:00
|
|
|
inherit package;
|
|
|
|
};
|
2022-01-23 15:17:01 +01:00
|
|
|
"site2.local" = {
|
|
|
|
database.tablePrefix = "site2_";
|
2023-01-05 02:38:22 +00:00
|
|
|
inherit package;
|
2024-12-10 20:26:33 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-01-05 02:38:22 +00:00
|
|
|
networking.firewall.allowedTCPPorts = [ 80 ];
|
2020-04-06 09:25:07 +02:00
|
|
|
networking.hosts."127.0.0.1" = [
|
2024-11-16 12:05:41 +02:00
|
|
|
"site1.local"
|
2020-04-06 09:25:07 +02:00
|
|
|
"site2.local"
|
2024-12-10 20:26:33 +01:00
|
|
|
];
|
|
|
|
};
|
|
|
|
}
|
|
|
|
)
|
|
|
|
{ }
|
|
|
|
[
|
|
|
|
"6_7"
|
2023-01-05 02:38:22 +00:00
|
|
|
];
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2019-06-02 10:36:14 -04:00
|
|
|
testScript = ''
|
2019-11-23 23:54:06 +01:00
|
|
|
import re
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2019-11-23 23:54:06 +01:00
|
|
|
start_all()
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2023-01-05 02:38:22 +00:00
|
|
|
${lib.concatStrings (
|
|
|
|
lib.mapAttrsToList (name: value: ''
|
|
|
|
${name}.wait_for_unit("${(value null).services.wordpress.webserver}")
|
|
|
|
'') nodes
|
|
|
|
)}
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2019-11-23 23:54:06 +01:00
|
|
|
site_names = ["site1.local", "site2.local"]
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2023-01-05 02:38:22 +00:00
|
|
|
for machine in (${lib.concatStringsSep ", " (builtins.attrNames nodes)}):
|
2019-11-23 23:54:06 +01:00
|
|
|
for site_name in site_names:
|
2020-04-06 09:25:07 +02:00
|
|
|
machine.wait_for_unit(f"phpfpm-wordpress-{site_name}")
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2020-04-06 09:25:07 +02:00
|
|
|
with subtest("website returns welcome screen"):
|
|
|
|
assert "Welcome to the famous" in machine.succeed(f"curl -L {site_name}")
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2020-04-06 09:25:07 +02:00
|
|
|
with subtest("wordpress-init went through"):
|
|
|
|
info = machine.get_unit_info(f"wordpress-init-{site_name}")
|
|
|
|
assert info["Result"] == "success"
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2020-04-06 09:25:07 +02:00
|
|
|
with subtest("secret keys are set"):
|
|
|
|
pattern = re.compile(r"^define.*NONCE_SALT.{64,};$", re.MULTILINE)
|
|
|
|
assert pattern.search(
|
|
|
|
machine.succeed(f"cat /var/lib/wordpress/{site_name}/secret-keys.php")
|
|
|
|
)
|
2019-11-23 23:54:06 +01:00
|
|
|
'';
|
2016-09-26 18:06:56 -04:00
|
|
|
}
|
|
|
|
)
|