2020-03-29 20:39:14 +00:00
|
|
|
import ./make-test-python.nix ({ pkgs, ... }:
|
2019-12-25 22:04:55 +00:00
|
|
|
|
2020-03-30 11:08:16 +00:00
|
|
|
let
|
2023-01-06 13:49:38 +00:00
|
|
|
template-bootstrap3 = pkgs.stdenv.mkDerivation rec {
|
2020-03-30 11:08:16 +00:00
|
|
|
name = "bootstrap3";
|
2023-01-06 13:49:38 +00:00
|
|
|
version = "2022-07-27";
|
|
|
|
src = pkgs.fetchFromGitHub {
|
|
|
|
owner = "giterlizzi";
|
|
|
|
repo = "dokuwiki-template-bootstrap3";
|
|
|
|
rev = "v${version}";
|
|
|
|
hash = "sha256-B3Yd4lxdwqfCnfmZdp+i/Mzwn/aEuZ0ovagDxuR6lxo=";
|
2020-03-30 11:08:16 +00:00
|
|
|
};
|
|
|
|
installPhase = "mkdir -p $out; cp -R * $out/";
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2023-01-06 13:49:38 +00:00
|
|
|
plugin-icalevents = pkgs.stdenv.mkDerivation rec {
|
2020-03-30 11:08:16 +00:00
|
|
|
name = "icalevents";
|
2023-01-06 13:49:38 +00:00
|
|
|
version = "2017-06-16";
|
|
|
|
src = pkgs.fetchzip {
|
|
|
|
stripRoot = false;
|
|
|
|
url = "https://github.com/real-or-random/dokuwiki-plugin-icalevents/releases/download/${version}/dokuwiki-plugin-icalevents-${version}.zip";
|
|
|
|
hash = "sha256-IPs4+qgEfe8AAWevbcCM9PnyI0uoyamtWeg4rEb+9Wc=";
|
2020-03-30 11:08:16 +00:00
|
|
|
};
|
|
|
|
installPhase = "mkdir -p $out; cp -R * $out/";
|
|
|
|
};
|
|
|
|
|
2023-01-06 13:42:43 +00:00
|
|
|
acronymsFile = pkgs.writeText "acronyms.local.conf" ''
|
|
|
|
r13y reproducibility
|
|
|
|
'';
|
|
|
|
|
|
|
|
dwWithAcronyms = pkgs.dokuwiki.overrideAttrs (prev: {
|
|
|
|
installPhase = prev.installPhase or "" + ''
|
|
|
|
ln -sf ${acronymsFile} $out/share/dokuwiki/conf/acronyms.local.conf
|
|
|
|
'';
|
|
|
|
});
|
|
|
|
|
|
|
|
mkNode = webserver: { ... }: {
|
|
|
|
services.dokuwiki = {
|
|
|
|
inherit webserver;
|
|
|
|
|
|
|
|
sites = {
|
|
|
|
"site1.local" = {
|
2023-01-06 01:36:30 +00:00
|
|
|
templates = [ template-bootstrap3 ];
|
|
|
|
settings = {
|
|
|
|
useacl = false;
|
|
|
|
userewrite = true;
|
|
|
|
template = "bootstrap3";
|
|
|
|
};
|
2023-01-06 13:42:43 +00:00
|
|
|
};
|
|
|
|
"site2.local" = {
|
|
|
|
package = dwWithAcronyms;
|
|
|
|
usersFile = "/var/lib/dokuwiki/site2.local/users.auth.php";
|
|
|
|
plugins = [ plugin-icalevents ];
|
2023-01-06 01:36:30 +00:00
|
|
|
settings = {
|
|
|
|
useacl = true;
|
|
|
|
superuser = "admin";
|
|
|
|
title._file = titleFile;
|
|
|
|
plugin.dummy.empty = "This is just for testing purposes";
|
|
|
|
};
|
|
|
|
acl = [
|
|
|
|
{ page = "*";
|
|
|
|
actor = "@ALL";
|
|
|
|
level = "read"; }
|
|
|
|
{ page = "acl-test";
|
|
|
|
actor = "@ALL";
|
|
|
|
level = "none"; }
|
|
|
|
];
|
|
|
|
pluginsConfig = {
|
|
|
|
authad = false;
|
|
|
|
authldap = false;
|
|
|
|
authmysql = false;
|
|
|
|
authpgsql = false;
|
|
|
|
tag = false;
|
|
|
|
icalevents = true;
|
|
|
|
};
|
2023-01-06 13:42:43 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
networking.firewall.allowedTCPPorts = [ 80 ];
|
|
|
|
networking.hosts."127.0.0.1" = [ "site1.local" "site2.local" ];
|
|
|
|
};
|
|
|
|
|
2023-01-06 01:36:30 +00:00
|
|
|
titleFile = pkgs.writeText "dokuwiki-title" "DokuWiki on site2";
|
2020-03-30 11:08:16 +00:00
|
|
|
in {
|
2019-12-25 22:04:55 +00:00
|
|
|
name = "dokuwiki";
|
2021-01-10 19:08:30 +00:00
|
|
|
meta = with pkgs.lib; {
|
2021-08-03 12:50:21 +00:00
|
|
|
maintainers = with maintainers; [
|
|
|
|
_1000101
|
|
|
|
onny
|
2023-01-06 22:40:09 +00:00
|
|
|
e1mo
|
2021-08-03 12:50:21 +00:00
|
|
|
];
|
2020-06-12 10:42:41 +00:00
|
|
|
};
|
2021-08-03 12:50:21 +00:00
|
|
|
|
|
|
|
nodes = {
|
2023-01-06 13:42:43 +00:00
|
|
|
dokuwiki_nginx = mkNode "nginx";
|
|
|
|
dokuwiki_caddy = mkNode "caddy";
|
2020-03-29 20:39:14 +00:00
|
|
|
};
|
2019-12-25 22:04:55 +00:00
|
|
|
|
|
|
|
testScript = ''
|
2020-03-29 20:39:14 +00:00
|
|
|
|
|
|
|
start_all()
|
|
|
|
|
2021-08-03 12:50:21 +00:00
|
|
|
dokuwiki_nginx.wait_for_unit("nginx")
|
|
|
|
dokuwiki_caddy.wait_for_unit("caddy")
|
2020-03-29 20:39:14 +00:00
|
|
|
|
2021-08-03 12:50:21 +00:00
|
|
|
site_names = ["site1.local", "site2.local"]
|
2020-03-29 20:39:14 +00:00
|
|
|
|
2021-08-03 12:50:21 +00:00
|
|
|
for machine in (dokuwiki_nginx, dokuwiki_caddy):
|
|
|
|
for site_name in site_names:
|
|
|
|
machine.wait_for_unit(f"phpfpm-dokuwiki-{site_name}")
|
2020-03-29 20:39:14 +00:00
|
|
|
|
2021-08-03 12:50:21 +00:00
|
|
|
machine.succeed("curl -sSfL http://site1.local/ | grep 'DokuWiki'")
|
|
|
|
machine.fail("curl -sSfL 'http://site1.local/doku.php?do=login' | grep 'Login'")
|
2020-08-03 07:53:27 +00:00
|
|
|
|
2023-01-06 01:36:30 +00:00
|
|
|
machine.succeed("curl -sSfL http://site2.local/ | grep 'DokuWiki on site2'")
|
2021-08-03 12:50:21 +00:00
|
|
|
machine.succeed("curl -sSfL 'http://site2.local/doku.php?do=login' | grep 'Login'")
|
2020-08-03 07:53:27 +00:00
|
|
|
|
2023-01-06 13:42:43 +00:00
|
|
|
with subtest("ACL Operations"):
|
|
|
|
machine.succeed(
|
2021-08-03 12:50:21 +00:00
|
|
|
"echo 'admin:$2y$10$ijdBQMzSVV20SrKtCna8gue36vnsbVm2wItAXvdm876sshI4uwy6S:Admin:admin@example.test:user' >> /var/lib/dokuwiki/site2.local/users.auth.php",
|
|
|
|
"curl -sSfL -d 'u=admin&p=password' --cookie-jar cjar 'http://site2.local/doku.php?do=login'",
|
|
|
|
"curl -sSfL --cookie cjar --cookie-jar cjar 'http://site2.local/doku.php?do=login' | grep 'Logged in as: <bdi>Admin</bdi>'",
|
2023-01-06 13:42:43 +00:00
|
|
|
)
|
|
|
|
|
2023-01-06 01:36:30 +00:00
|
|
|
# Ensure the generated ACL is valid
|
|
|
|
machine.succeed(
|
|
|
|
"echo 'No Hello World! for @ALL here' >> /var/lib/dokuwiki/site2.local/data/pages/acl-test.txt",
|
|
|
|
"curl -sSL 'http://site2.local/doku.php?id=acl-test' | grep 'Permission Denied'"
|
|
|
|
)
|
|
|
|
|
2023-01-06 13:42:43 +00:00
|
|
|
with subtest("Customizing Dokuwiki"):
|
|
|
|
machine.succeed(
|
|
|
|
"echo 'r13y is awesome!' >> /var/lib/dokuwiki/site2.local/data/pages/acronyms-test.txt",
|
|
|
|
"curl -sSfL 'http://site2.local/doku.php?id=acronyms-test' | grep '<abbr title=\"reproducibility\">r13y</abbr>'",
|
|
|
|
)
|
|
|
|
|
2023-01-06 01:36:30 +00:00
|
|
|
# Testing if plugins (a) be correctly loaded and (b) configuration to enable them works
|
|
|
|
machine.succeed(
|
|
|
|
"echo '~~INFO:syntaxplugins~~' >> /var/lib/dokuwiki/site2.local/data/pages/plugin-list.txt",
|
|
|
|
"curl -sSfL 'http://site2.local/doku.php?id=plugin-list' | grep 'plugin:icalevents'",
|
|
|
|
"curl -sSfL 'http://site2.local/doku.php?id=plugin-list' | (! grep 'plugin:tag')",
|
|
|
|
)
|
|
|
|
|
2023-01-05 23:14:43 +00:00
|
|
|
# Test if theme is applied and working correctly (no weired relative PHP import errors)
|
|
|
|
machine.succeed(
|
|
|
|
"curl -sSfL 'http://site1.local/doku.php' | grep 'bootstrap3/images/logo.png'",
|
|
|
|
"curl -sSfL 'http://site1.local/lib/exe/css.php' | grep 'bootstrap3'",
|
|
|
|
"curl -sSfL 'http://site1.local/lib/tpl/bootstrap3/css.php'",
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2023-01-06 13:42:43 +00:00
|
|
|
# Just to ensure both Webserver configurations are consistent in allowing that
|
|
|
|
with subtest("Rewriting"):
|
|
|
|
machine.succeed(
|
|
|
|
"echo 'Hello, NixOS!' >> /var/lib/dokuwiki/site1.local/data/pages/rewrite-test.txt",
|
|
|
|
"curl -sSfL http://site1.local/rewrite-test | grep 'Hello, NixOS!'",
|
|
|
|
)
|
2019-12-25 22:04:55 +00:00
|
|
|
'';
|
|
|
|
})
|