password.t 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # Copyright (C) 2009 Alex Schroeder <alex@gnu.org>
  2. #
  3. # This program is free software: you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation, either version 3 of the License, or
  6. # (at your option) any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. require 't/test.pl';
  16. package OddMuse;
  17. use Test::More tests => 6;
  18. AppendStringToFile($ConfigFile, "\$EditPass = 'bar';\n");
  19. test_page(update_page('test', 'normal edit'),
  20. 'normal edit');
  21. test_page(get_page('action=password'),
  22. 'You are a normal user on this site');
  23. # test problem reported by Gauthier
  24. WriteStringToFile($ConfigFile, <<'EOT');
  25. $EditAllowed = 2;
  26. $AdminPass = 'foo' unless defined $AdminPass;
  27. $EditPass = 'bar' unless defined $EditPass;
  28. $ScriptName = 'http://localhost/wiki.pl';
  29. $SurgeProtection = 0;
  30. $CommentsPrefix = 'Comments on ';
  31. $LocalNamesCollect = 1;
  32. EOT
  33. # using the above settings results in no permission to edit normal
  34. # pages
  35. test_page(update_page('normal_page', 'normal edit'),
  36. 'This page does not exist');
  37. test_page(update_page('normal_page', 'admin edit', 0, 0, 1),
  38. 'This page does not exist');
  39. # test suggested fix
  40. WriteStringToFile($ConfigFile, <<'EOT');
  41. $EditAllowed = 2;
  42. $AdminPass = 'foo';
  43. $EditPass = 'bar';
  44. $ScriptName = 'http://localhost/wiki.pl';
  45. $SurgeProtection = 0;
  46. $CommentsPrefix = 'Comments on ';
  47. $LocalNamesCollect = 1;
  48. EOT
  49. # using the password works, now
  50. test_page(update_page('normal_page', 'normal edit'),
  51. 'This page does not exist');
  52. test_page(update_page('normal_page', 'admin edit', 0, 0, 1),
  53. 'admin edit');