ban-contributors.t 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. # Copyright (C) 2013 Alex Schroeder <alex@gnu.org>
  2. #
  3. # This program is free software; you can redistribute it and/or modify it under
  4. # the terms of the GNU General Public License as published by the Free Software
  5. # Foundation; either version 3 of the License, or (at your option) any later
  6. # version.
  7. #
  8. # This program is distributed in the hope that it will be useful, but WITHOUT
  9. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  10. # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  11. #
  12. # You should have received a copy of the GNU General Public License along with
  13. # this program. If not, see <http://www.gnu.org/licenses/>.
  14. require 't/test.pl';
  15. package OddMuse;
  16. use Test::More tests => 21;
  17. add_module('ban-contributors.pl');
  18. $localhost = '127.0.0.1';
  19. $ENV{'REMOTE_ADDR'} = $localhost;
  20. update_page('Test', 'insults');
  21. test_page_negative(get_page('action=admin id=Test'), 'Ban contributors');
  22. test_page(get_page('action=admin id=Test pwd=foo'), 'Ban contributors');
  23. test_page(get_page('action=ban id=Test pwd=foo'), $localhost, 'Ban!');
  24. test_page(get_page("action=ban id=Test host=$localhost pwd=foo"),
  25. 'Location: http://localhost/wiki.pl/BannedHosts');
  26. test_page(get_page('BannedHosts'), $localhost, 'Test');
  27. clear_pages();
  28. add_module('ban-contributors.pl');
  29. update_page('Test', 'no spam');
  30. ok(get_page('action=browse id=Test raw=2')
  31. =~ /(\d+) # Do not delete this line/,
  32. 'raw=2 returns timestamp');
  33. $to = $1;
  34. ok($to, 'timestamp stored');
  35. sleep(1);
  36. update_page('Test', "http://spam/amoxil/ http://spam/doxycycline/");
  37. test_page(get_page("action=rollback id=Test to=$to pwd=foo"),
  38. 'Rolling back changes', 'These URLs were rolled back',
  39. 'amoxil', 'doxycycline', 'Consider banning the IP number');
  40. test_page(get_page("action=ban id=Test content=amoxil pwd=foo"),
  41. 'Location: http://localhost/wiki.pl/BannedContent');
  42. test_page(get_page('BannedContent'), 'amoxil', 'Test');
  43. update_page('Test', "http://spam/amoxil/ http://spam/doxycycline/");
  44. $page = get_page("action=rollback id=Test to=$to pwd=foo");
  45. test_page($page, 'Rolling back changes', 'These URLs were rolled back',
  46. 'doxycycline');
  47. test_page_negative($page, 'amoxil');