1import ./make-test-python.nix ({ pkgs, ... }:
2
3{
4 name = "wordpress";
5 meta = with pkgs.lib.maintainers; {
6 maintainers = [
7 flokli
8 grahamc # under duress!
9 mmilata
10 ];
11 };
12
13 nodes = {
14 wp_httpd = { ... }: {
15 services.httpd.adminAddr = "webmaster@site.local";
16 services.httpd.logPerVirtualHost = true;
17
18 services.wordpress.sites = {
19 "site1.local" = {
20 database.tablePrefix = "site1_";
21 };
22 "site2.local" = {
23 database.tablePrefix = "site2_";
24 };
25 };
26
27 networking.firewall.allowedTCPPorts = [ 80 ];
28 networking.hosts."127.0.0.1" = [ "site1.local" "site2.local" ];
29 };
30
31 wp_nginx = { ... }: {
32 services.wordpress.webserver = "nginx";
33 services.wordpress.sites = {
34 "site1.local" = {
35 database.tablePrefix = "site1_";
36 };
37 "site2.local" = {
38 database.tablePrefix = "site2_";
39 };
40 };
41
42 networking.firewall.allowedTCPPorts = [ 80 ];
43 networking.hosts."127.0.0.1" = [ "site1.local" "site2.local" ];
44 };
45
46 wp_caddy = { ... }: {
47 services.wordpress.webserver = "caddy";
48 services.wordpress.sites = {
49 "site1.local" = {
50 database.tablePrefix = "site1_";
51 };
52 "site2.local" = {
53 database.tablePrefix = "site2_";
54 };
55 };
56
57 networking.firewall.allowedTCPPorts = [ 80 ];
58 networking.hosts."127.0.0.1" = [ "site1.local" "site2.local" ];
59 };
60 };
61
62 testScript = ''
63 import re
64
65 start_all()
66
67 wp_httpd.wait_for_unit("httpd")
68 wp_nginx.wait_for_unit("nginx")
69 wp_caddy.wait_for_unit("caddy")
70
71 site_names = ["site1.local", "site2.local"]
72
73 for machine in (wp_httpd, wp_nginx, wp_caddy):
74 for site_name in site_names:
75 machine.wait_for_unit(f"phpfpm-wordpress-{site_name}")
76
77 with subtest("website returns welcome screen"):
78 assert "Welcome to the famous" in machine.succeed(f"curl -L {site_name}")
79
80 with subtest("wordpress-init went through"):
81 info = machine.get_unit_info(f"wordpress-init-{site_name}")
82 assert info["Result"] == "success"
83
84 with subtest("secret keys are set"):
85 pattern = re.compile(r"^define.*NONCE_SALT.{64,};$", re.MULTILINE)
86 assert pattern.search(
87 machine.succeed(f"cat /var/lib/wordpress/{site_name}/secret-keys.php")
88 )
89 '';
90})