git.iko.soy/typeable/nixpkgs
on master help sign in
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.

commit20f052b6f69845ac92428524e22418fe4fc188eb authordadada <dadada@dadada.li> dateMon 3 Aug 2020, 09:53 (6 years ago) parent38dc94b
1 file changed+10−1
nixos/tests/dokuwiki.nix+10−1
nixos/tests/dokuwiki.nix+10−1
@@ -45,7 +45,7 @@ in {
4545 };
4646 };
4747 services.dokuwiki."site2.local" = {
48− aclUse = true;
48+ usersFile = "/var/lib/dokuwiki/site2.local/users.auth.php";
4949 superUser = "admin";
5050 nginx = {
5151 forceSSL = false;
@@ -70,6 +70,15 @@ in {
7070 machine.wait_for_open_port(80)
7171
7272 machine.succeed("curl -sSfL http://site1.local/ | grep 'DokuWiki'")
73+ machine.fail("curl -sSfL 'http://site1.local/doku.php?do=login' | grep 'Login'")
74+
7375 machine.succeed("curl -sSfL http://site2.local/ | grep 'DokuWiki'")
76+ machine.succeed("curl -sSfL 'http://site2.local/doku.php?do=login' | grep 'Login'")
77+
78+ machine.succeed(
79+ "echo 'admin:$2y$10$ijdBQMzSVV20SrKtCna8gue36vnsbVm2wItAXvdm876sshI4uwy6S:Admin:admin@example.test:user' >> /var/lib/dokuwiki/site2.local/users.auth.php",
80+ "curl -sSfL -d 'u=admin&p=password' --cookie-jar cjar 'http://site2.local/doku.php?do=login'",
81+ "curl -sSfL --cookie cjar --cookie-jar cjar 'http://site2.local/doku.php?do=login' | grep 'Logged in as: <bdi>Admin</bdi>'",
82+ )
7483 '';
7584})