1import ./make-test-python.nix ({ pkgs, ... }:
2
3let
4 template-bootstrap3 = pkgs.stdenv.mkDerivation {
5 name = "bootstrap3";
6 # Download the theme from the dokuwiki site
7 src = pkgs.fetchurl {
8 url = "https://github.com/giterlizzi/dokuwiki-template-bootstrap3/archive/v2019-05-22.zip";
9 sha256 = "4de5ff31d54dd61bbccaf092c9e74c1af3a4c53e07aa59f60457a8f00cfb23a6";
10 };
11 # We need unzip to build this package
12 nativeBuildInputs = [ pkgs.unzip ];
13 # Installing simply means copying all files to the output directory
14 installPhase = "mkdir -p $out; cp -R * $out/";
15 };
16
17
18 # Let's package the icalevents plugin
19 plugin-icalevents = pkgs.stdenv.mkDerivation {
20 name = "icalevents";
21 # Download the plugin from the dokuwiki site
22 src = pkgs.fetchurl {
23 url = "https://github.com/real-or-random/dokuwiki-plugin-icalevents/releases/download/2017-06-16/dokuwiki-plugin-icalevents-2017-06-16.zip";
24 sha256 = "e40ed7dd6bbe7fe3363bbbecb4de481d5e42385b5a0f62f6a6ce6bf3a1f9dfa8";
25 };
26 # We need unzip to build this package
27 nativeBuildInputs = [ pkgs.unzip ];
28 sourceRoot = ".";
29 # Installing simply means copying all files to the output directory
30 installPhase = "mkdir -p $out; cp -R * $out/";
31 };
32
33in {
34 name = "dokuwiki";
35 meta = with pkgs.lib; {
36 maintainers = with maintainers; [
37 _1000101
38 onny
39 ];
40 };
41
42 nodes = {
43 dokuwiki_nginx = {...}: {
44 services.dokuwiki = {
45 sites = {
46 "site1.local" = {
47 aclUse = false;
48 superUser = "admin";
49 };
50 "site2.local" = {
51 usersFile = "/var/lib/dokuwiki/site2.local/users.auth.php";
52 superUser = "admin";
53 templates = [ template-bootstrap3 ];
54 plugins = [ plugin-icalevents ];
55 };
56 };
57 };
58
59 networking.firewall.allowedTCPPorts = [ 80 ];
60 networking.hosts."127.0.0.1" = [ "site1.local" "site2.local" ];
61 };
62
63 dokuwiki_caddy = {...}: {
64 services.dokuwiki = {
65 webserver = "caddy";
66 sites = {
67 "site1.local" = {
68 aclUse = false;
69 superUser = "admin";
70 };
71 "site2.local" = {
72 usersFile = "/var/lib/dokuwiki/site2.local/users.auth.php";
73 superUser = "admin";
74 templates = [ template-bootstrap3 ];
75 plugins = [ plugin-icalevents ];
76 };
77 };
78 };
79
80 networking.firewall.allowedTCPPorts = [ 80 ];
81 networking.hosts."127.0.0.1" = [ "site1.local" "site2.local" ];
82 };
83
84 };
85
86 testScript = ''
87
88 start_all()
89
90 dokuwiki_nginx.wait_for_unit("nginx")
91 dokuwiki_caddy.wait_for_unit("caddy")
92
93 site_names = ["site1.local", "site2.local"]
94
95 for machine in (dokuwiki_nginx, dokuwiki_caddy):
96 for site_name in site_names:
97 machine.wait_for_unit(f"phpfpm-dokuwiki-{site_name}")
98
99 machine.succeed("curl -sSfL http://site1.local/ | grep 'DokuWiki'")
100 machine.fail("curl -sSfL 'http://site1.local/doku.php?do=login' | grep 'Login'")
101
102 machine.succeed("curl -sSfL http://site2.local/ | grep 'DokuWiki'")
103 machine.succeed("curl -sSfL 'http://site2.local/doku.php?do=login' | grep 'Login'")
104
105 machine.succeed(
106 "echo 'admin:$2y$10$ijdBQMzSVV20SrKtCna8gue36vnsbVm2wItAXvdm876sshI4uwy6S:Admin:admin@example.test:user' >> /var/lib/dokuwiki/site2.local/users.auth.php",
107 "curl -sSfL -d 'u=admin&p=password' --cookie-jar cjar 'http://site2.local/doku.php?do=login'",
108 "curl -sSfL --cookie cjar --cookie-jar cjar 'http://site2.local/doku.php?do=login' | grep 'Logged in as: <bdi>Admin</bdi>'",
109 )
110 '';
111})