recaptcha.t 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # Copyright (C) 2013–2015 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, but
  9. # WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. # 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 => 7;
  18. use utf8; # test data is UTF-8 and it matters
  19. use Captcha::reCAPTCHA;
  20. $ENV{'REMOTE_ADDR'}='127.0.0.1';
  21. add_module('recaptcha.pl');
  22. # The recaptcha module used to corrupt UTF-8 encoding and HTML
  23. # escaping.
  24. # non-existing page and no permission
  25. test_page(get_page('title=SandBox text="<b>K%C3%BChlschrank</b>"'),
  26. 'Status: 403',
  27. '&lt;b&gt;Kühlschrank&lt;/b&gt;');
  28. # update it as an admin
  29. test_page(update_page('SandBox', '<b>Kühlschrank</b>', undef, undef, 1),
  30. '&lt;b&gt;Kühlschrank&lt;/b&gt;');
  31. # existing page and no permission
  32. $page = get_page('title=SandBox text="<b>K%C3%BChlschrank-test</b>"');
  33. test_page($page,
  34. 'Status: 403',
  35. '&lt;b&gt;Kühlschrank-test&lt;/b&gt;');
  36. # edit form is modified by recaptcha
  37. test_page($page, 'var RecaptchaOptions');
  38. # comment form is modified by recaptcha
  39. AppendStringToFile($ConfigFile, "\$CommentsPrefix = 'Comments on ';\n");
  40. test_page(get_page('Comments_on_SandBox'),
  41. 'var RecaptchaOptions');