python310Packages.pydeconz: 104 -> 105
[NixPkgs.git] / nixos / tests / wordpress.nix
blob416a20aa7fe81e4564c9cbd3fa28a41568ccabb2
1 import ./make-test-python.nix ({ pkgs, ... }:
4   name = "wordpress";
5   meta = with pkgs.lib.maintainers; {
6     maintainers = [
7       flokli
8       grahamc # under duress!
9       mmilata
10     ];
11   };
13   nodes = {
14     wp_httpd = { ... }: {
15       services.httpd.adminAddr = "webmaster@site.local";
16       services.httpd.logPerVirtualHost = true;
18       services.wordpress.sites = {
19         "site1.local" = {
20           database.tablePrefix = "site1_";
21         };
22         "site2.local" = {
23           database.tablePrefix = "site2_";
24         };
25       };
27       networking.firewall.allowedTCPPorts = [ 80 ];
28       networking.hosts."127.0.0.1" = [ "site1.local" "site2.local" ];
29     };
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       };
42       networking.firewall.allowedTCPPorts = [ 80 ];
43       networking.hosts."127.0.0.1" = [ "site1.local" "site2.local" ];
44     };
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       };
57       networking.firewall.allowedTCPPorts = [ 80 ];
58       networking.hosts."127.0.0.1" = [ "site1.local" "site2.local" ];
59     };
60   };
62   testScript = ''
63     import re
65     start_all()
67     wp_httpd.wait_for_unit("httpd")
68     wp_nginx.wait_for_unit("nginx")
69     wp_caddy.wait_for_unit("caddy")
71     site_names = ["site1.local", "site2.local"]
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}")
77             with subtest("website returns welcome screen"):
78                 assert "Welcome to the famous" in machine.succeed(f"curl -L {site_name}")
80             with subtest("wordpress-init went through"):
81                 info = machine.get_unit_info(f"wordpress-init-{site_name}")
82                 assert info["Result"] == "success"
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   '';