New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nixos/dokuwiki: add test for login #94617
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests are successful but IMHO they're not testing the actual login and don't fail because of the failed login message containing the keyword Admin
. I've found this nice tutorial on how to test it: https://www.dokuwiki.org/tips:curl_login but there seems to be issues with the usersFile (permissions?), too.
While debugging, I've also noticed an error in the original service: https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/services/web-apps/dokuwiki.nix#L98
There is users.auth.php
instead of acl.auth.php
nixos/tests/dokuwiki.nix
Outdated
) | ||
users_file.close() | ||
machine.succeed( | ||
"curl -sSfL --data 'u=admin' --data 'p=password' 'http://site2.local/doku.php?do=login' | grep 'Admin'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't work, it catches Admin
from the error: User authentication is temporarily unavailable. If this situation persists, please inform your Wiki Admin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I think I got it working... but I had to specify the usersFile like this:
let
usersFile = pkgs.writeText "users.auth.php" ''
admin:$2y$10$ijdBQMzSVV20SrKtCna8gue36vnsbVm2wItAXvdm876sshI4uwy6S:Admin:admin@example.test:user
'';
...
in
{
...
services.dokuwiki."site2.local" = {
usersFile = toString usersFile;
...
and then check it like this:
...
machine.succeed(
"curl -d 'u=admin&p=password' --cookie-jar cjar http://site2.local/doku.php?do=login",
"curl --cookie cjar --cookie-jar cjar http://site2.local/doku.php?do=login | grep 'Logged in as: <bdi>Admin</bdi>'",
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the cookie jar seems like the sensible option.
/tmp/users.auth.php
did not work because the file was lost somewhere between the testScript
and machine.succeed
. Using machine.succeed
to write the file works. I would prefer this in favor of the approach involving let usersFile
, since in that case the file would be write-only, which is different from production.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job!
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.
@GrahamcOfBorg test dokuwiki |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work!!!
Add a test to see if the login page is working when ACL is enabled. Follow-up to #94551
Motivation for this change
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)