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; [ _1000101 ];
37 };
38 machine = { ... }: {
39 services.dokuwiki."site1.local" = {
40 aclUse = false;
41 superUser = "admin";
42 };
43 services.dokuwiki."site2.local" = {
44 usersFile = "/var/lib/dokuwiki/site2.local/users.auth.php";
45 superUser = "admin";
46 templates = [ template-bootstrap3 ];
47 plugins = [ plugin-icalevents ];
48 };
49 networking.hosts."127.0.0.1" = [ "site1.local" "site2.local" ];
50 };
51
52 testScript = ''
53 site_names = ["site1.local", "site2.local"]
54
55 start_all()
56
57 machine.wait_for_unit("phpfpm-dokuwiki-site1.local.service")
58 machine.wait_for_unit("phpfpm-dokuwiki-site2.local.service")
59
60 machine.wait_for_unit("nginx.service")
61
62 machine.wait_for_open_port(80)
63
64 machine.succeed("curl -sSfL http://site1.local/ | grep 'DokuWiki'")
65 machine.fail("curl -sSfL 'http://site1.local/doku.php?do=login' | grep 'Login'")
66
67 machine.succeed("curl -sSfL http://site2.local/ | grep 'DokuWiki'")
68 machine.succeed("curl -sSfL 'http://site2.local/doku.php?do=login' | grep 'Login'")
69
70 machine.succeed(
71 "echo 'admin:$2y$10$ijdBQMzSVV20SrKtCna8gue36vnsbVm2wItAXvdm876sshI4uwy6S:Admin:admin@example.test:user' >> /var/lib/dokuwiki/site2.local/users.auth.php",
72 "curl -sSfL -d 'u=admin&p=password' --cookie-jar cjar 'http://site2.local/doku.php?do=login'",
73 "curl -sSfL --cookie cjar --cookie-jar cjar 'http://site2.local/doku.php?do=login' | grep 'Logged in as: <bdi>Admin</bdi>'",
74 )
75 '';
76})