From 20f052b6f69845ac92428524e22418fe4fc188eb Mon Sep 17 00:00:00 2001 From: dadada Date: Mon, 3 Aug 2020 09:53:27 +0200 Subject: [PATCH] nixos/dokuwiki: add test for login page Cookie jar can be used to accurately test if the login was successful. Simply searching for the user name is not sufficient, since it is always part of the returned page after login. The page should display a phrase containing the username after login. --- nixos/tests/dokuwiki.nix | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/nixos/tests/dokuwiki.nix b/nixos/tests/dokuwiki.nix index 4f00521c2021..cc3eb8ffb192 100644 --- a/nixos/tests/dokuwiki.nix +++ b/nixos/tests/dokuwiki.nix @@ -45,7 +45,7 @@ in { }; }; services.dokuwiki."site2.local" = { - aclUse = true; + usersFile = "/var/lib/dokuwiki/site2.local/users.auth.php"; superUser = "admin"; nginx = { forceSSL = false; @@ -70,6 +70,15 @@ in { machine.wait_for_open_port(80) machine.succeed("curl -sSfL http://site1.local/ | grep 'DokuWiki'") + machine.fail("curl -sSfL 'http://site1.local/doku.php?do=login' | grep 'Login'") + machine.succeed("curl -sSfL http://site2.local/ | grep 'DokuWiki'") + machine.succeed("curl -sSfL 'http://site2.local/doku.php?do=login' | grep 'Login'") + + machine.succeed( + "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: Admin'", + ) ''; })