nixpkgs/nixos/tests/wordpress.nix
Silvan Mosberger 374e6bcc40 treewide: Format all Nix files
Format all Nix files using the officially approved formatter,
making the CI check introduced in the previous commit succeed:

  nix-build ci -A fmt.check

This is the next step of the of the [implementation](https://github.com/NixOS/nixfmt/issues/153)
of the accepted [RFC 166](https://github.com/NixOS/rfcs/pull/166).

This commit will lead to merge conflicts for a number of PRs,
up to an estimated ~1100 (~33%) among the PRs with activity in the past 2
months, but that should be lower than what it would be without the previous
[partial treewide format](https://github.com/NixOS/nixpkgs/pull/322537).

Merge conflicts caused by this commit can now automatically be resolved while rebasing using the
[auto-rebase script](8616af08d9/maintainers/scripts/auto-rebase).

If you run into any problems regarding any of this, please reach out to the
[formatting team](https://nixos.org/community/teams/formatting/) by
pinging @NixOS/nix-formatting.
2025-04-01 20:10:43 +02:00

124 lines
3.3 KiB
Nix

{ lib, config, ... }:
rec {
name = "wordpress";
meta = with lib.maintainers; {
maintainers = [
flokli
grahamc # under duress!
mmilata
];
};
nodes =
lib.foldl
(
a: version:
let
package = config.node.pkgs."wordpress_${version}";
in
a
// {
"wp${version}_httpd" = _: {
services.httpd.adminAddr = "webmaster@site.local";
services.httpd.logPerVirtualHost = true;
services.wordpress.webserver = "httpd";
services.wordpress.sites = {
"site1.local" = {
database.tablePrefix = "site1_";
inherit package;
};
"site2.local" = {
database.tablePrefix = "site2_";
inherit package;
};
};
networking.firewall.allowedTCPPorts = [ 80 ];
networking.hosts."127.0.0.1" = [
"site1.local"
"site2.local"
];
};
"wp${version}_nginx" = _: {
services.wordpress.webserver = "nginx";
services.wordpress.sites = {
"site1.local" = {
database.tablePrefix = "site1_";
inherit package;
};
"site2.local" = {
database.tablePrefix = "site2_";
inherit package;
};
};
networking.firewall.allowedTCPPorts = [ 80 ];
networking.hosts."127.0.0.1" = [
"site1.local"
"site2.local"
];
};
"wp${version}_caddy" = _: {
services.wordpress.webserver = "caddy";
services.wordpress.sites = {
"site1.local" = {
database.tablePrefix = "site1_";
inherit package;
};
"site2.local" = {
database.tablePrefix = "site2_";
inherit package;
};
};
networking.firewall.allowedTCPPorts = [
80
443
];
networking.hosts."127.0.0.1" = [
"site1.local"
"site2.local"
];
};
}
)
{ }
[
"6_7"
];
testScript = ''
import re
start_all()
${lib.concatStrings (
lib.mapAttrsToList (name: value: ''
${name}.wait_for_unit("${(value null).services.wordpress.webserver}")
'') nodes
)}
site_names = ["site1.local", "site2.local"]
for machine in (${lib.concatStringsSep ", " (builtins.attrNames nodes)}):
for site_name in site_names:
machine.wait_for_unit(f"phpfpm-wordpress-{site_name}")
with subtest("website returns welcome screen"):
assert "Welcome to the famous" in machine.succeed(f"curl -k -L {site_name}")
with subtest("wordpress-init went through"):
info = machine.get_unit_info(f"wordpress-init-{site_name}")
assert info["Result"] == "success"
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")
)
'';
}