1 import ./make-test-python.nix ({ pkgs, ... }:
4 template-bootstrap3 = pkgs.stdenv.mkDerivation rec {
6 version = "2022-07-27";
7 src = pkgs.fetchFromGitHub {
9 repo = "dokuwiki-template-bootstrap3";
11 hash = "sha256-B3Yd4lxdwqfCnfmZdp+i/Mzwn/aEuZ0ovagDxuR6lxo=";
13 installPhase = "mkdir -p $out; cp -R * $out/";
17 plugin-icalevents = pkgs.stdenv.mkDerivation rec {
19 version = "2017-06-16";
22 url = "https://github.com/real-or-random/dokuwiki-plugin-icalevents/releases/download/${version}/dokuwiki-plugin-icalevents-${version}.zip";
23 hash = "sha256-IPs4+qgEfe8AAWevbcCM9PnyI0uoyamtWeg4rEb+9Wc=";
25 installPhase = "mkdir -p $out; cp -R * $out/";
28 acronymsFile = pkgs.writeText "acronyms.local.conf" ''
32 dwWithAcronyms = pkgs.dokuwiki.overrideAttrs (prev: {
33 installPhase = prev.installPhase or "" + ''
34 ln -sf ${acronymsFile} $out/share/dokuwiki/conf/acronyms.local.conf
38 mkNode = webserver: { ... }: {
44 templates = [ template-bootstrap3 ];
48 template = "bootstrap3";
52 package = dwWithAcronyms;
53 usersFile = "/var/lib/dokuwiki/site2.local/users.auth.php";
54 plugins = [ plugin-icalevents ];
58 title._file = titleFile;
59 plugin.dummy.empty = "This is just for testing purposes";
81 networking.firewall.allowedTCPPorts = [ 80 ];
82 networking.hosts."127.0.0.1" = [ "site1.local" "site2.local" ];
85 titleFile = pkgs.writeText "dokuwiki-title" "DokuWiki on site2";
88 meta = with pkgs.lib; {
89 maintainers = with maintainers; [
97 dokuwiki_nginx = mkNode "nginx";
98 dokuwiki_caddy = mkNode "caddy";
105 dokuwiki_nginx.wait_for_unit("nginx")
106 dokuwiki_caddy.wait_for_unit("caddy")
108 site_names = ["site1.local", "site2.local"]
110 for machine in (dokuwiki_nginx, dokuwiki_caddy):
111 for site_name in site_names:
112 machine.wait_for_unit(f"phpfpm-dokuwiki-{site_name}")
114 machine.succeed("curl -sSfL http://site1.local/ | grep 'DokuWiki'")
115 machine.fail("curl -sSfL 'http://site1.local/doku.php?do=login' | grep 'Login'")
117 machine.succeed("curl -sSfL http://site2.local/ | grep 'DokuWiki on site2'")
118 machine.succeed("curl -sSfL 'http://site2.local/doku.php?do=login' | grep 'Login'")
120 with subtest("ACL Operations"):
122 "echo 'admin:$2y$10$ijdBQMzSVV20SrKtCna8gue36vnsbVm2wItAXvdm876sshI4uwy6S:Admin:admin@example.test:user' >> /var/lib/dokuwiki/site2.local/users.auth.php",
123 "curl -sSfL -d 'u=admin&p=password' --cookie-jar cjar 'http://site2.local/doku.php?do=login'",
124 "curl -sSfL --cookie cjar --cookie-jar cjar 'http://site2.local/doku.php?do=login' | grep 'Logged in as: <bdi>Admin</bdi>'",
127 # Ensure the generated ACL is valid
129 "echo 'No Hello World! for @ALL here' >> /var/lib/dokuwiki/site2.local/data/pages/acl-test.txt",
130 "curl -sSL 'http://site2.local/doku.php?id=acl-test' | grep 'Permission Denied'"
133 with subtest("Customizing Dokuwiki"):
135 "echo 'r13y is awesome!' >> /var/lib/dokuwiki/site2.local/data/pages/acronyms-test.txt",
136 "curl -sSfL 'http://site2.local/doku.php?id=acronyms-test' | grep '<abbr title=\"reproducibility\">r13y</abbr>'",
139 # Testing if plugins (a) be correctly loaded and (b) configuration to enable them works
141 "echo '~~INFO:syntaxplugins~~' >> /var/lib/dokuwiki/site2.local/data/pages/plugin-list.txt",
142 "curl -sSfL 'http://site2.local/doku.php?id=plugin-list' | grep 'plugin:icalevents'",
143 "curl -sSfL 'http://site2.local/doku.php?id=plugin-list' | (! grep 'plugin:tag')",
146 # Test if theme is applied and working correctly (no weird relative PHP import errors)
148 "curl -sSfL 'http://site1.local/doku.php' | grep 'bootstrap3/images/logo.png'",
149 "curl -sSfL 'http://site1.local/lib/exe/css.php' | grep 'bootstrap3'",
150 "curl -sSfL 'http://site1.local/lib/tpl/bootstrap3/css.php'",
154 # Just to ensure both Webserver configurations are consistent in allowing that
155 with subtest("Rewriting"):
157 "echo 'Hello, NixOS!' >> /var/lib/dokuwiki/site1.local/data/pages/rewrite-test.txt",
158 "curl -sSfL http://site1.local/rewrite-test | grep 'Hello, NixOS!'",