nixpkgs/nixos/tests/mediawiki.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

78 lines
2.2 KiB
Nix
Raw Normal View History

2023-04-03 15:05:21 +00:00
{
system ? builtins.currentSystem,
config ? {},
pkgs ? import ../.. { inherit system config; },
}:
2023-04-03 15:05:21 +00:00
let
shared = {
services.mediawiki.enable = true;
services.mediawiki.httpd.virtualHost.hostName = "localhost";
services.mediawiki.httpd.virtualHost.adminAddr = "root@example.com";
2023-04-03 15:05:21 +00:00
services.mediawiki.passwordFile = pkgs.writeText "password" "correcthorsebatterystaple";
services.mediawiki.extensions = {
Matomo = pkgs.fetchzip {
url = "https://github.com/DaSchTour/matomo-mediawiki-extension/archive/v4.0.1.tar.gz";
sha256 = "0g5rd3zp0avwlmqagc59cg9bbkn3r7wx7p6yr80s644mj6dlvs1b";
};
2023-04-03 15:05:21 +00:00
ParserFunctions = null;
};
2023-04-03 15:05:21 +00:00
};
2023-04-03 15:05:21 +00:00
testLib = import ../lib/testing-python.nix {
inherit system pkgs;
extraConfigurations = [ shared ];
};
in
{
mysql = testLib.makeTest {
name = "mediawiki-mysql";
nodes.machine = {
services.mediawiki.database.type = "mysql";
};
testScript = ''
start_all()
machine.wait_for_unit("phpfpm-mediawiki.service")
page = machine.succeed("curl -fL http://localhost/")
assert "MediaWiki has been installed" in page
'';
};
postgresql = testLib.makeTest {
name = "mediawiki-postgres";
nodes.machine = {
services.mediawiki.database.type = "postgres";
};
testScript = ''
start_all()
2023-04-03 15:05:21 +00:00
machine.wait_for_unit("phpfpm-mediawiki.service")
2019-12-01 01:44:49 +00:00
2023-04-03 15:05:21 +00:00
page = machine.succeed("curl -fL http://localhost/")
assert "MediaWiki has been installed" in page
'';
};
2023-04-24 12:21:06 +00:00
nohttpd = testLib.makeTest {
name = "mediawiki-nohttpd";
nodes.machine = {
services.mediawiki.webserver = "none";
};
2023-04-28 21:05:55 +00:00
testScript = { nodes, ... }: ''
2023-04-24 12:21:06 +00:00
start_all()
machine.wait_for_unit("phpfpm-mediawiki.service")
2023-04-28 21:05:55 +00:00
env = (
"SCRIPT_NAME=/index.php",
"SCRIPT_FILENAME=${nodes.machine.services.mediawiki.finalPackage}/share/mediawiki/index.php",
"REMOTE_ADDR=127.0.0.1",
'QUERY_STRING=title=Main_Page',
"REQUEST_METHOD=GET",
);
page = machine.succeed(f"{' '.join(env)} ${pkgs.fcgi}/bin/cgi-fcgi -bind -connect ${nodes.machine.services.phpfpm.pools.mediawiki.socket}")
assert "MediaWiki has been installed" in page, f"no 'MediaWiki has been installed' in:\n{page}"
2023-04-24 12:21:06 +00:00
'';
};
2023-04-03 15:05:21 +00:00
}