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 machine =
14 { ... }:
15 { services.httpd.adminAddr = "webmaster@site.local";
16 services.httpd.logPerVirtualHost = true;
17
18 services.wordpress."site1.local" = {
19 database.tablePrefix = "site1_";
20 };
21
22 services.wordpress."site2.local" = {
23 database.tablePrefix = "site2_";
24 };
25
26 networking.hosts."127.0.0.1" = [ "site1.local" "site2.local" ];
27 };
28
29 testScript = ''
30 import re
31
32 start_all()
33
34 machine.wait_for_unit("httpd")
35
36 machine.wait_for_unit("phpfpm-wordpress-site1.local")
37 machine.wait_for_unit("phpfpm-wordpress-site2.local")
38
39 site_names = ["site1.local", "site2.local"]
40
41 with subtest("website returns welcome screen"):
42 for site_name in site_names:
43 assert "Welcome to the famous" in machine.succeed(f"curl -fL {site_name}")
44
45 with subtest("wordpress-init went through"):
46 for site_name in site_names:
47 info = machine.get_unit_info(f"wordpress-init-{site_name}")
48 assert info["Result"] == "success"
49
50 with subtest("secret keys are set"):
51 pattern = re.compile(r"^define.*NONCE_SALT.{64,};$", re.MULTILINE)
52 for site_name in site_names:
53 assert pattern.search(
54 machine.succeed(f"cat /var/lib/wordpress/{site_name}/secret-keys.php")
55 )
56 '';
57})