wiki.pl: Port some fixes from upstream
[Orgmuse.git] / t / password.t
blob37a2cda86fe623f6af576b28acdb42ca9662eb50
1 # Copyright (C) 2009  Alex Schroeder <alex@gnu.org>
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.
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.
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/>.
16 require 't/test.pl';
17 package OddMuse;
18 use Test::More tests => 6;
19 clear_pages();
20 AppendStringToFile($ConfigFile, "\$EditPass = 'bar';\n");
21 test_page(update_page('test', 'normal edit'),
22           'normal edit');
23 test_page(get_page('action=password'),
24           'You are a normal user on this site');
26 # test problem reported by Gauthier
27 WriteStringToFile($ConfigFile, <<'EOT');
28 $EditAllowed = 2;
29 $AdminPass   = 'foo' unless defined $AdminPass;
30 $EditPass    = 'bar' unless defined $EditPass;
31 $ScriptName = 'http://localhost/wiki.pl';
32 $SurgeProtection = 0;
33 $CommentsPrefix = 'Comments on ';
34 $LocalNamesCollect = 1;
35 EOT
37 # using the above settings results in no permission to edit normal
38 # pages
39 test_page(update_page('normal_page', 'normal edit'),
40           'This page is empty');
41 test_page(update_page('normal_page', 'admin edit', 0, 0, 1),
42           'This page is empty');
44 # test suggested fix
45 WriteStringToFile($ConfigFile, <<'EOT');
46 $EditAllowed = 2;
47 $AdminPass   = 'foo';
48 $EditPass    = 'bar';
49 $ScriptName = 'http://localhost/wiki.pl';
50 $SurgeProtection = 0;
51 $CommentsPrefix = 'Comments on ';
52 $LocalNamesCollect = 1;
53 EOT
55 # using the password works, now
56 test_page(update_page('normal_page', 'normal edit'),
57           'This page is empty');
58 test_page(update_page('normal_page', 'admin edit', 0, 0, 1),
59           'admin edit');