6 Bweb - A Bacula web interface
7 Bacula® - The Network Backup Solution
9 Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
11 The main author of Bweb is Eric Bollengier.
12 The main author of Bacula is Kern Sibbald, with contributions from
13 many others, a complete list can be found in the file AUTHORS.
15 This program is Free Software; you can redistribute it and/or
16 modify it under the terms of version two of the GNU General Public
17 License as published by the Free Software Foundation plus additions
18 that are listed in the file LICENSE.
20 This program is distributed in the hope that it will be useful, but
21 WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 General Public License for more details.
25 You should have received a copy of the GNU General Public License
26 along with this program; if not, write to the Free Software
27 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
30 Bacula® is a registered trademark of John Walker.
31 The licensor of Bacula is the Free Software Foundation Europe
32 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zurich,
33 Switzerland, email:ftf@fsfeurope.org.
37 Get it working with a regress environment:
38 * get regress module from SVN
39 * use postgresql or mysql in config
41 * add catalog = all, !skipped, !saved into Messages Standard (scripts/bacula-dir.conf)
42 * add exit 0 to scripts/cleanup
43 * run bacula-backup-test
44 * uncomment job schedule in bacula-dir.conf
45 * load bweb-(mysql|postgresql).sql
47 * configure bweb to point to bconsole and the catalog
55 use Test::More qw(no_plan);
60 my ($login, $pass, $url, $verbose);
61 GetOptions ("login=s" => \$login,
64 "verbose" => \$verbose,
67 die "Usage: $0 --url http://.../cgi-bin/bweb/bweb.pl [-l user -p pass]"
70 print "Making tests on $url\n";
71 my ($req, $res, $c, $cli, $job_url);
73 my $agent = new WWW::Mechanize(autocheck=>1);
75 $agent->credentials($login, $pass);
78 ################################################################
79 # Check bweb libraries
80 ################################################################
82 # first, try to load all bweb libraries
84 require_ok('Bconsole');
85 require_ok('CCircle');
86 require_ok('GBalloon');
89 # test first page and check for the last job
90 $agent->get($url); ok($agent->success, "Get main page"); $c = $agent->content;
91 like($c, qr!</html>!, "Check EOP");
92 ok($c =~ m!(action=job_zoom;jobid=\d+)!, "Get the first JobId");
93 die "Can't get first jobid ($c)" unless $1;
101 $agent->get("$url?$job_url");
102 ok($agent->success,"Get job zoom"); $c=$agent->content;
103 like($c, qr!</html>!, "Check EOP");
104 like($c, qr!Using Device!, "Check for job log");
106 ok($agent->form_name('fileset_view'), "Find form");
107 $agent->click(); $c=$agent->content;
108 ok($agent->success, "Get fileset");
109 like($c, qr!</html>!, "Check EOP");
110 ok($c =~ m!<pre>\s*(/[^>]+?)</pre>!s,"Check fileset");
111 print $1 if $verbose;
112 $agent->back(); ok($agent->success,"Return from fileset");
114 ok($agent->form_name("rerun"), "Find form");
115 $agent->click(); $c=$agent->content;
116 ok($agent->success, "ReRun job");
117 ok($agent->form_name("form1"), "Find form");
118 ok($c =~ m!<select name='job'>\s*<option value='(.+?)'!,"jobs");
119 ok($agent->field('job', $1), "set field job=1");
120 ok($c =~ m!<select name='client'>\s*<option value='(.+?)'!, "clients");
121 ok($agent->field('client', $1), "set field client=$1");
122 ok($c =~ m!<select name='storage'>\s*<option value='(.+?)'!, "storages");
123 ok($agent->field('storage', $1), "set field storage=$1");
124 ok($c =~ m!<select name='fileset'>\s*<option value='(.+?)'!, "filesets");
125 ok($agent->field('fileset', $1), "set field fileset=1");
126 ok($c =~ m!<select name='pool'>\s*<option value=''></option>\s*<option value='(.+?)'!, "pools");
127 $agent->field('pool', $1);
128 $agent->click_button(value => 'run_job_now');
129 ok($agent->success(), "submit");
131 ok($agent->follow_link(text_regex=>qr/here/i), "follow link");
132 ok($agent->success(), "get job page"); $c=$agent->content;
133 like($c, qr/Using Device/, "Check job log");
135 # try to delete this job
136 $agent->get("$url?$job_url");
137 ok($agent->success,"Get job zoom");
138 ok($agent->form_name('delete'), "Find form");
139 $agent->click(); $c=$agent->content;
140 ok($agent->success, "Delete it");
141 like($c, qr!deleted!, "Check deleted message");
143 $agent->get("$url?$job_url");
144 ok($agent->success,"Get job zoom");
146 like($c, qr!An error has occurred!, "Check deleted job");
149 ok($agent->follow_link(text_regex=>qr/Defined Jobs/), "Go to Defined Jobs page");
151 like($c, qr/BackupCatalog/, "Check for BackupCatalog job");
153 ################################################################
155 ################################################################
157 ok($agent->follow_link(text_regex=>qr/Clients/), "Go to Clients page");
159 ok($c =~ m!chkbox.value = '(.+?)';!, "get client name");
162 $agent->get("$url?action=client_status;client=$cli");
163 ok($agent->success(), "submit"); $c=$agent->content;
164 like($c, qr/Terminated Jobs/, "check for client status");
166 $agent->get("$url?action=job;client=$cli");
167 ok($agent->success(), "submit"); $c=$agent->content;
168 like($c, qr/'$cli'\).selected = true;/, "list jobs for this client");
170 ################################################################
171 # Test location basic functions
172 ################################################################
175 ok($agent->follow_link(text_regex=>qr/Location/), "Go to Location page");
176 ok($agent->form_number(2), "Find form");
177 $agent->click_button(value => 'location_add');
178 ok($agent->success(), "submit");
179 ok($agent->form_number(2), "Find form");
180 $agent->field("location", $loc);
181 ok($agent->field("cost", 20), "set field cost=20");
182 ok($agent->field("enabled", "yes"), "set field enabled=yes");
183 ok($agent->field("enabled", "no"), "try set field enabled=no");
184 ok($agent->field("enabled", "archived"), "try set field enabled=archived");
185 $agent->click_button(value => 'location_add');
186 ok($agent->success(), "submit"); $c=$agent->content;
187 like($c, qr/$loc/, "Check if location is ok");
188 like($c, qr/inflag2.png/, "Check if enabled is archived");
190 $agent->get("$url?location=$loc&action=location_edit");
191 ok($agent->success(), "Try to edit location"); $c=$agent->content;
192 like($c, qr/$loc/, "Check for location");
193 ok($agent->form_number(2), "Find form");
194 $agent->field("cost", 40);
195 $agent->field("enabled", "no");
197 $agent->field("newlocation", $loc);
198 $agent->click_button(value => 'location_save');
199 ok($agent->success(), "submit to edit location"); $c=$agent->content;
200 like($c, qr/$loc/, "Check if location is ok");
201 like($c, qr/inflag0.png/, "Check if enabled is 'no'");
202 like($c, qr/40/, "Check for cost");
204 ################################################################
206 ################################################################
208 ok($agent->follow_link(text_regex=>qr/All Media/), "Go to All Media page");
209 ok($agent->success(), "submit"); $c=$agent->content;
210 ok($c =~ m/chkbox.value = '(.+?)'/, "get first media");
213 $agent->get("$url?media=$vol;action=update_media");
214 ok($agent->success(), "submit"); $c=$agent->content;
215 like($c, qr/$vol/, "Check if volume is ok");
217 ################################################################
218 # Test group basic functions
219 ################################################################
221 $agent->get("$url?action=client;notingroup=yes");
222 ok($agent->success(), "submit"); $c=$agent->content;
223 like($c, qr/$cli/, "check client=$cli is groupless");
227 ok($agent->follow_link(text_regex=>qr/Groups/), "Go to Groups page");
228 ok($agent->success(), "submit"); $c=$agent->content;
229 unlike($c, qr/error/i, "Check for group installation");
230 ok($agent->form_number(2), "Find form");
231 $agent->click_button(value => 'groups_edit');
232 ok($agent->success(), "submit action=groups_edit");
233 ok($agent->form_number(2), "Find form to create a group");
234 $agent->field("newgroup", $grp);
235 $agent->click_button(value => 'groups_save');
236 ok($agent->success(), "submit action=groups_save");
238 like($c, qr/$grp/, "Check if group have been created");
240 # rename group (client is loss because it was set by javascript)
241 $agent->get("$url?client_group=$grp;action=groups_edit");
242 ok($agent->success(), "submit action=groups_edit"); $c=$agent->content;
243 like($c, qr/$grp/, "Check if group is present to rename it");
244 ok($agent->form_number(2), "Find form");
246 $agent->field("newgroup", $grp);
247 $agent->field("client", $cli);
248 $agent->click_button(value => 'groups_save');
249 ok($agent->success(), "submit"); $c=$agent->content;
250 like($c, qr/'$grp'/, "Check if newgroup is present");
252 # check if group is ok
253 $agent->get("$url?client_group=$grp;action=client");
254 ok($agent->success(), "submit"); $c=$agent->content;
255 like($c, qr/'$cli'/, "Check if client is present in newgrp");
257 $agent->get("$url?action=client;notingroup=yes");
258 ok($agent->success(), "check if client=$cli is already 'not in group'");
260 unlike($c, qr/$cli/, "check client=$cli");
262 $agent->get("$url?client_group=other$grp;action=groups_edit");
263 ok($agent->success(), "create an empty other$grp"); $c=$agent->content;
264 like($c, qr/'other$grp'/, "check if other$grp was created");
267 ok($agent->follow_link(text_regex=>qr/Jobs by group/), "Go to Job by group page");
268 ok($agent->success(), "Get it"); $c=$agent->content;
269 like($c, qr/"$grp"/, "check if $grp is here");
272 ok($agent->follow_link(text_regex=>qr/Jobs overview/), "Go to Job overview");
273 ok($agent->success(), "Get it"); $c=$agent->content;
274 like($c, qr/"$grp"/, "check if $grp is here");
277 ok($agent->follow_link(url_regex=>qr/action=group_stats/), "Go to groups stats");
278 ok($agent->success(), "Get it"); $c=$agent->content;
279 like($c, qr/"$grp"/, "check if $grp is here");
282 ok($agent->follow_link(text_regex=>qr/Next Jobs/), "Go to Next jobs");
283 ok($agent->success(), "Get it"); $c=$agent->content;
284 like($c, qr/'BackupCatalog'/, "check if BackupCatalog is here");
287 ok($agent->follow_link(text_regex=>qr/Add Media/), "Go to Add Media");
288 ok($agent->success(), "Get it");
289 ok($agent->form_number(2), "Find form");
290 $agent->field('pool', 'Scratch');
291 $agent->field('storage', 'File');
292 $agent->field('nb', '3');
293 $agent->field('offset', '1');
294 $agent->field('media', "Vol$$");
295 $agent->click_button(value => 'add_media');
296 ok($agent->success(), "Create them"); $c=$agent->content;
297 like($c, qr/Vol${$}0001/, "Check if media are there");
300 ok($agent->follow_link(text_regex=>qr/Pools/), "Go to Pool");
301 ok($agent->success(), "Get it"); $c=$agent->content;
302 like($c, qr/"Default"/, "check if Default pool is here");
303 like($c, qr/"Scratch"/, "check if Scratch pool is here");
305 ################################################################
306 # other checks and cleanup
307 ################################################################
310 $agent->get("$url?client_group=$grp;action=groups_del");
311 ok($agent->success(), "submit"); $c=$agent->content;
312 unlike($c, qr/'$grp'/, "Check if group was deleted");
314 $agent->get("$url?client_group=other$grp;action=groups_del");
315 ok($agent->success(), "submit"); $c=$agent->content;
316 unlike($c, qr/'other$grp'/, "Check if group was deleted");
319 $agent->get("$url?location=$loc;action=location_del");
320 ok($agent->success(), "submit"); $c=$agent->content;
321 unlike($c, qr/$loc/, "Check if location was deleted");