2019-11-23 23:54:06 +01:00
|
|
|
import ./make-test-python.nix ({ pkgs, ... }:
|
2016-09-27 00:06:56 +02:00
|
|
|
|
|
|
|
{
|
|
|
|
name = "wordpress";
|
|
|
|
meta = with pkgs.stdenv.lib.maintainers; {
|
2019-11-24 16:48:35 +01:00
|
|
|
maintainers = [
|
|
|
|
flokli
|
|
|
|
grahamc # under duress!
|
|
|
|
mmilata
|
|
|
|
];
|
2016-09-27 00:06:56 +02:00
|
|
|
};
|
|
|
|
|
2019-06-02 16:36:14 +02:00
|
|
|
machine =
|
2018-07-20 22:56:59 +02:00
|
|
|
{ ... }:
|
2019-06-02 16:36:14 +02:00
|
|
|
{ services.httpd.adminAddr = "webmaster@site.local";
|
|
|
|
services.httpd.logPerVirtualHost = true;
|
|
|
|
|
|
|
|
services.wordpress."site1.local" = {
|
|
|
|
database.tablePrefix = "site1_";
|
|
|
|
};
|
2016-09-27 00:06:56 +02:00
|
|
|
|
2019-06-02 16:36:14 +02:00
|
|
|
services.wordpress."site2.local" = {
|
|
|
|
database.tablePrefix = "site2_";
|
|
|
|
};
|
|
|
|
|
|
|
|
networking.hosts."127.0.0.1" = [ "site1.local" "site2.local" ];
|
|
|
|
};
|
2016-09-27 00:06:56 +02:00
|
|
|
|
2019-06-02 16:36:14 +02:00
|
|
|
testScript = ''
|
2019-11-23 23:54:06 +01:00
|
|
|
import re
|
2016-09-27 00:06:56 +02:00
|
|
|
|
2019-11-23 23:54:06 +01:00
|
|
|
start_all()
|
2016-09-27 00:06:56 +02:00
|
|
|
|
2019-11-23 23:54:06 +01:00
|
|
|
machine.wait_for_unit("httpd")
|
2019-09-22 13:29:03 +02:00
|
|
|
|
2019-11-23 23:54:06 +01:00
|
|
|
machine.wait_for_unit("phpfpm-wordpress-site1.local")
|
|
|
|
machine.wait_for_unit("phpfpm-wordpress-site2.local")
|
|
|
|
|
|
|
|
site_names = ["site1.local", "site2.local"]
|
|
|
|
|
|
|
|
with subtest("website returns welcome screen"):
|
|
|
|
for site_name in site_names:
|
2020-09-16 17:52:42 +02:00
|
|
|
assert "Welcome to the famous" in machine.succeed(f"curl -fL {site_name}")
|
2016-09-27 00:06:56 +02:00
|
|
|
|
2019-11-23 23:54:06 +01:00
|
|
|
with subtest("wordpress-init went through"):
|
|
|
|
for site_name in site_names:
|
|
|
|
info = machine.get_unit_info(f"wordpress-init-{site_name}")
|
2019-11-25 00:01:06 +01:00
|
|
|
assert info["Result"] == "success"
|
2019-11-23 23:54:06 +01:00
|
|
|
|
|
|
|
with subtest("secret keys are set"):
|
2019-11-25 00:01:06 +01:00
|
|
|
pattern = re.compile(r"^define.*NONCE_SALT.{64,};$", re.MULTILINE)
|
2019-11-23 23:54:06 +01:00
|
|
|
for site_name in site_names:
|
2019-11-25 00:01:06 +01:00
|
|
|
assert pattern.search(
|
2019-11-23 23:54:06 +01:00
|
|
|
machine.succeed(f"cat /var/lib/wordpress/{site_name}/secret-keys.php")
|
|
|
|
)
|
|
|
|
'';
|
2016-09-27 00:06:56 +02:00
|
|
|
})
|