1 # Copyright (C) 2013 Alex Schroeder <alex@gnu.org>
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
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.
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/>.
17 use Test::More tests => 21;
21 add_module('ban-contributors.pl');
22 $localhost = 'pyrobombus';
23 $ENV{'REMOTE_ADDR'} = $localhost;
25 update_page('Test', 'insults');
26 test_page_negative(get_page('action=admin id=Test'), 'Ban contributors');
27 test_page(get_page('action=admin id=Test pwd=foo'), 'Ban contributors');
28 test_page(get_page('action=ban id=Test pwd=foo'), 'pyrobombus', 'Ban!');
29 test_page(get_page('action=ban id=Test host=pyrobombus pwd=foo'),
30 'Location: http://localhost/wiki.pl/BannedHosts');
31 test_page(get_page('BannedHosts'), 'pyrobombus', 'Test');
34 add_module('ban-contributors.pl');
36 update_page('Test', 'no spam');
37 ok(get_page('action=browse id=Test raw=2')
38 =~ /(\d+) # Do not delete this line/,
39 'raw=2 returns timestamp');
41 ok($to, 'timestamp stored');
44 update_page('Test', "http://spam/amoxil/ http://spam/doxycycline/");
45 test_page(get_page("action=rollback id=Test to=$to pwd=foo"),
46 'Rolling back changes', 'These URLs were rolled back',
47 'amoxil', 'doxycycline', 'Consider banning the hostname');
48 test_page(get_page("action=ban id=Test content=amoxil pwd=foo"),
49 'Location: http://localhost/wiki.pl/BannedContent');
50 test_page(get_page('BannedContent'), 'amoxil', 'Test');
51 update_page('Test', "http://spam/amoxil/ http://spam/doxycycline/");
52 $page = get_page("action=rollback id=Test to=$to pwd=foo");
53 test_page($page, 'Rolling back changes', 'These URLs were rolled back',
55 test_page_negative($page, 'amoxil');