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 * charger bweb-(mysql|postgresql).sql
46 * configure bweb to point to bconsole and the catalog
54 use Test::More qw(no_plan);
59 my ($login, $pass, $url, $verbose);
60 GetOptions ("login=s" => \$login,
63 "verbose" => \$verbose,
66 die "Usage: $0 --url http://.../cgi-bin/bweb/bweb.pl [-l user -p pass]"
69 print "Making tests on $url\n";
70 my ($req, $res, $c, $cli, $job_url);
72 my $agent = new WWW::Mechanize(autocheck=>1);
74 $agent->credentials($login, $pass);
77 ################################################################
78 # Check bweb libraries
79 ################################################################
81 # first, try to load all bweb libraries
83 require_ok('Bconsole');
84 require_ok('CCircle');
85 require_ok('GBalloon');
88 # test first page and check for the last job
89 $agent->get($url); ok($agent->success, "Get main page"); $c = $agent->content;
90 like($c, qr!</html>!, "Check EOP");
91 ok($c =~ m!(action=job_zoom;jobid=\d+)!, "Get the first JobId");
92 die "Can't get first jobid ($c)" unless $1;
100 $agent->get("$url?$job_url");
101 ok($agent->success,"Get job zoom"); $c=$agent->content;
102 like($c, qr!</html>!, "Check EOP");
103 like($c, qr!Using Device!, "Check for job log");
105 ok($agent->form_name('fileset_view'), "Find form");
106 $agent->click(); $c=$agent->content;
107 ok($agent->success, "Get fileset");
108 like($c, qr!</html>!, "Check EOP");
109 ok($c =~ m!<pre>\s*(/[^>]+?)</pre>!s,"Check fileset");
110 print $1 if $verbose;
111 $agent->back(); ok($agent->success,"Return from fileset");
113 ok($agent->form_name("rerun"), "Find form");
114 $agent->click(); $c=$agent->content;
115 ok($agent->success, "ReRun job");
116 ok($agent->form_name("form1"), "Find form");
117 ok($c =~ m!<select name='job'>\s*<option value='(.+?)'!,"jobs");
118 ok($agent->field('job', $1), "set field job=1");
119 ok($c =~ m!<select name='client'>\s*<option value='(.+?)'!, "clients");
120 ok($agent->field('client', $1), "set field client=$1");
121 ok($c =~ m!<select name='storage'>\s*<option value='(.+?)'!, "storages");
122 ok($agent->field('storage', $1), "set field storage=$1");
123 ok($c =~ m!<select name='fileset'>\s*<option value='(.+?)'!, "filesets");
124 ok($agent->field('fileset', $1), "set field fileset=1");
125 ok($c =~ m!<select name='pool'>\s*<option value=''></option>\s*<option value='(.+?)'!, "pools");
126 $agent->field('pool', $1);
127 $agent->click_button(value => 'run_job_now');
128 ok($agent->success(), "submit");
130 ok($agent->follow_link(text_regex=>qr/here/i), "follow link");
131 ok($agent->success(), "get job page"); $c=$agent->content;
132 like($c, qr/Using Device/, "Check job log");
134 # try to delete this job
135 $agent->get("$url?$job_url");
136 ok($agent->success,"Get job zoom");
137 ok($agent->form_name('delete'), "Find form");
138 $agent->click(); $c=$agent->content;
139 ok($agent->success, "Delete it");
140 like($c, qr!deleted!, "Check deleted message");
142 $agent->get("$url?$job_url");
143 ok($agent->success,"Get job zoom");
145 like($c, qr!An error has occurred!, "Check deleted job");
148 ok($agent->follow_link(text_regex=>qr/Defined Jobs/), "Go to Defined Jobs page");
150 like($c, qr/BackupCatalog/, "Check for BackupCatalog job");
152 ################################################################
154 ################################################################
156 ok($agent->follow_link(text_regex=>qr/Clients/), "Go to Clients page");
158 ok($c =~ m!chkbox.value = '(.+?)';!, "get client name");
161 $agent->get("$url?action=client_status;client=$cli");
162 ok($agent->success(), "submit"); $c=$agent->content;
163 like($c, qr/Terminated Jobs/, "check for client status");
165 $agent->get("$url?action=job;client=$cli");
166 ok($agent->success(), "submit"); $c=$agent->content;
167 like($c, qr/'$cli'\).selected = true;/, "list jobs for this client");
169 ################################################################
170 # Test location basic functions
171 ################################################################
174 ok($agent->follow_link(text_regex=>qr/Location/), "Go to Location page");
175 ok($agent->form_number(2), "Find form");
176 $agent->click_button(value => 'location_add');
177 ok($agent->success(), "submit");
178 ok($agent->form_number(2), "Find form");
179 $agent->field("location", $loc);
180 ok($agent->field("cost", 20), "set field cost=20");
181 ok($agent->field("enabled", "yes"), "set field enabled=yes");
182 ok($agent->field("enabled", "no"), "try set field enabled=no");
183 ok($agent->field("enabled", "archived"), "try set field enabled=archived");
184 $agent->click_button(value => 'location_add');
185 ok($agent->success(), "submit"); $c=$agent->content;
186 like($c, qr/$loc/, "Check if location is ok");
187 like($c, qr/inflag2.png/, "Check if enabled is archived");
189 $agent->get("$url?location=$loc&action=location_edit");
190 ok($agent->success(), "Try to edit location"); $c=$agent->content;
191 like($c, qr/$loc/, "Check for location");
192 ok($agent->form_number(2), "Find form");
193 $agent->field("cost", 40);
194 $agent->field("enabled", "no");
196 $agent->field("newlocation", $loc);
197 $agent->click_button(value => 'location_save');
198 ok($agent->success(), "submit to edit location"); $c=$agent->content;
199 like($c, qr/$loc/, "Check if location is ok");
200 like($c, qr/inflag0.png/, "Check if enabled is 'no'");
201 like($c, qr/40/, "Check for cost");
203 ################################################################
205 ################################################################
207 ok($agent->follow_link(text_regex=>qr/All Media/), "Go to All Media page");
208 ok($agent->success(), "submit"); $c=$agent->content;
209 ok($c =~ m/chkbox.value = '(.+?)'/, "get first media");
212 $agent->get("$url?media=$vol;action=update_media");
213 ok($agent->success(), "submit"); $c=$agent->content;
214 like($c, qr/$vol/, "Check if volume is ok");
216 ################################################################
217 # Test group basic functions
218 ################################################################
220 $agent->get("$url?action=client;notingroup=yes");
221 ok($agent->success(), "submit"); $c=$agent->content;
222 like($c, qr/$cli/, "check client=$cli is groupless");
226 ok($agent->follow_link(text_regex=>qr/Groups/), "Go to Groups page");
227 ok($agent->success(), "submit"); $c=$agent->content;
228 unlike($c, qr/error/i, "Check for group installation");
229 ok($agent->form_number(2), "Find form");
230 $agent->click_button(value => 'groups_edit');
231 ok($agent->success(), "submit action=groups_edit");
232 ok($agent->form_number(2), "Find form to create a group");
233 $agent->field("newgroup", $grp);
234 $agent->click_button(value => 'groups_save');
235 ok($agent->success(), "submit action=groups_save");
237 like($c, qr/$grp/, "Check if group have been created");
239 # rename group (client is loss because it was set by javascript)
240 $agent->get("$url?client_group=$grp;action=groups_edit");
241 ok($agent->success(), "submit action=groups_edit"); $c=$agent->content;
242 like($c, qr/$grp/, "Check if group is present to rename it");
243 ok($agent->form_number(2), "Find form");
245 $agent->field("newgroup", $grp);
246 $agent->field("client", $cli);
247 $agent->click_button(value => 'groups_save');
248 ok($agent->success(), "submit"); $c=$agent->content;
249 like($c, qr/'$grp'/, "Check if newgroup is present");
251 # check if group is ok
252 $agent->get("$url?client_group=$grp;action=client");
253 ok($agent->success(), "submit"); $c=$agent->content;
254 like($c, qr/'$cli'/, "Check if client is present in newgrp");
256 $agent->get("$url?action=client;notingroup=yes");
257 ok($agent->success(), "check if client=$cli is already 'not in group'");
259 unlike($c, qr/$cli/, "check client=$cli");
261 $agent->get("$url?client_group=other$grp;action=groups_edit");
262 ok($agent->success(), "create an empty other$grp"); $c=$agent->content;
263 like($c, qr/'other$grp'/, "check if other$grp was created");
266 ok($agent->follow_link(text_regex=>qr/Jobs by group/), "Go to Job by group page");
267 ok($agent->success(), "Get it"); $c=$agent->content;
268 like($c, qr/"$grp"/, "check if $grp is here");
271 ok($agent->follow_link(text_regex=>qr/Jobs overview/), "Go to Job overview");
272 ok($agent->success(), "Get it"); $c=$agent->content;
273 like($c, qr/"$grp"/, "check if $grp is here");
276 ok($agent->follow_link(text_regex=>qr/Next Jobs/), "Go to Next jobs");
277 ok($agent->success(), "Get it"); $c=$agent->content;
278 like($c, qr/'BackupCatalog'/, "check if BackupCatalog is here");
281 ok($agent->follow_link(text_regex=>qr/Add Media/), "Go to Add Media");
282 ok($agent->success(), "Get it");
283 ok($agent->form_number(2), "Find form");
284 $agent->field('pool', 'Scratch');
285 $agent->field('storage', 'File');
286 $agent->field('nb', '3');
287 $agent->field('offset', '1');
288 $agent->field('media', "Vol$$");
289 $agent->click_button(value => 'add_media');
290 ok($agent->success(), "Create them"); $c=$agent->content;
291 like($c, qr/Vol${$}0001/, "Check if media are there");
294 ok($agent->follow_link(text_regex=>qr/Pools/), "Go to Pool");
295 ok($agent->success(), "Get it"); $c=$agent->content;
296 like($c, qr/"Default"/, "check if Default pool is here");
297 like($c, qr/"Scratch"/, "check if Scratch pool is here");
299 ################################################################
300 # other checks and cleanup
301 ################################################################
304 $agent->get("$url?client_group=$grp;action=groups_del");
305 ok($agent->success(), "submit"); $c=$agent->content;
306 unlike($c, qr/'$grp'/, "Check if group was deleted");
308 $agent->get("$url?client_group=other$grp;action=groups_del");
309 ok($agent->success(), "submit"); $c=$agent->content;
310 unlike($c, qr/'other$grp'/, "Check if group was deleted");
313 $agent->get("$url?location=$loc;action=location_del");
314 ok($agent->success(), "submit"); $c=$agent->content;
315 unlike($c, qr/$loc/, "Check if location was deleted");