3 # $Id: cgi-test,v 1.1 1999-04-08 13:05:40 ivan Exp $
5 # This is the beginning of a test suite for the web interface.
6 # It's also excellent for populating your database with some meaningful test
7 # data. (a derivative is used by the web demo)
8 # It only works on an empty database (probably need empty counters too, and
9 # no arbirary RADIUS attributes).
10 # Usage: cgi-test http://base.freeside.url/with/path/ username password
11 # (Yes, if you were properly paranoid and are using SSL, you'll need to get
12 # libwww-perl working with SSL to use this.)
15 # Revision 1.1 1999-04-08 13:05:40 ivan
16 # web interface tester / sample data creator
21 use subs qw( big_ugly_data_structure );
25 my ( $base_url, $username, $password ) = ( shift, shift, shift );
27 my @data = &big_ugly_data_structure;
29 my $ua = new LWP::UserAgent;
33 sub LWP::UserAgent::get_basic_credentials {
35 ( $username, $password );
41 while ( $data = shift @data ) {
42 my $cgi = new CGI ( $data->{'params'} );
43 my $full_url = $base_url. $data->{'url'}. '?'. $cgi->query_string;
44 #my $request = new HTTP::Request( 'POST', $full_url );
45 my $request = new HTTP::Request( 'GET', $full_url );
46 my $response = $ua->request( $request );
47 if ( $response->is_redirect ) {
48 die "Unexpected redirect!\n".
50 "To: ". $response->base. "\n"
52 } elsif ( $response->is_success ) {
53 my $location = $response->base;
54 my $expected_location = $data->{'location'};
55 #if ( $location =~ /^$base_url$expected_location$/ ) {
56 if ( $location eq $base_url. $expected_location ) {
57 #warn "cool, got expected response $location from $full_url\n";
59 die "Strange, regular response, but unexpected base!\n".
61 "Base : ". $response->base. "\n".
62 "Expected: $base_url$expected_location\n".
63 "Output: ". $response->content. "\n"
66 } elsif ( $response->is_error ) {
67 die "Strange, I got an error\n".
69 "Error: ". $response->error_as_HTML. "\n".
70 "Output: ". $response->content. "\n"
72 } elsif ( $response->is_info ) {
73 die "Strange, I got an info reponse\n".
75 "Output: ". $response->content. "\n"
78 die "Really strange, got an unrecognized response from LWP::UserAgent!\n";
84 sub big_ugly_data_structure {
87 { 'url' => 'edit/process/part_svc.cgi',
91 'svcdb' => 'svc_acct',
92 'svc_acct__popnum_flag' => '',
93 'svc_acct__popnum' => '',
94 'svc_acct__dir_flag' => '',
95 'svc_acct__dir' => '',
96 'svc_acct__username_flag' => '',
97 'svc_acct__username' => '',
98 'svc_acct__uid_flag' => '',
99 'svc_acct__uid' => '',
100 'svc_acct__quota_flag' => 'F',
101 'svc_acct__quota' => '10',
102 'svc_acct__slipip_flag' => 'F',
103 'svc_acct__slipip' => '',
104 'svc_acct___password_flag' => '',
105 'svc_acct___password' => '',
106 'svc_acct__gid_flag' => '',
107 'svc_acct__gid' => '',
108 'svc_acct__shell_flag' => 'D',
109 'svc_acct__shell' => '/bin/sh',
110 'svc_acct__finger_flag' => '',
111 'svc_acct__finger' => '',
112 'svc_domain__domain_flag' => '',
113 'svc_domain__domain' => '',
114 'svc_acct_sm__domuser_flag' => '',
115 'svc_acct_sm__domuser' => '',
116 'svc_acct_sm__domuid_flag' => '',
117 'svc_acct_sm__domuid' => '',
118 'svc_acct_sm__domsvc_flag' => '',
119 'svc_acct_sm__domsvc' => '',
121 'location' => 'browse/part_svc.cgi',
123 { 'url' => 'edit/process/part_svc.cgi',
127 'svcdb' => 'svc_acct',
128 'svc_acct__popnum_flag' => '',
129 'svc_acct__popnum' => '',
130 'svc_acct__dir_flag' => '',
131 'svc_acct__dir' => '',
132 'svc_acct__username_flag' => '',
133 'svc_acct__username' => '',
134 'svc_acct__uid_flag' => '',
135 'svc_acct__uid' => '',
136 'svc_acct__quota_flag' => 'F',
137 'svc_acct__quota' => '10',
138 'svc_acct__slipip_flag' => 'D',
139 'svc_acct__slipip' => '0.0.0.0',
140 'svc_acct___password_flag' => '',
141 'svc_acct___password' => '',
142 'svc_acct__gid_flag' => '',
143 'svc_acct__gid' => '',
144 'svc_acct__shell_flag' => 'D',
145 'svc_acct__shell' => '/bin/sh',
146 'svc_acct__finger_flag' => '',
147 'svc_acct__finger' => '',
148 'svc_domain__domain_flag' => '',
149 'svc_domain__domain' => '',
150 'svc_acct_sm__domuser_flag' => '',
151 'svc_acct_sm__domuser' => '',
152 'svc_acct_sm__domuid_flag' => '',
153 'svc_acct_sm__domuid' => '',
154 'svc_acct_sm__domsvc_flag' => '',
155 'svc_acct_sm__domsvc' => '',
157 'location' => 'browse/part_svc.cgi',
159 { 'url' => 'edit/process/part_svc.cgi',
162 'svc' => 'POP Mailbox',
163 'svcdb' => 'svc_acct',,
164 'svc_acct__popnum_flag' => 'F',
165 'svc_acct__popnum' => '',
166 'svc_acct__dir_flag' => '',
167 'svc_acct__dir' => '',
168 'svc_acct__username_flag' => '',
169 'svc_acct__username' => '',
170 'svc_acct__uid_flag' => '',
171 'svc_acct__uid' => '',
172 'svc_acct__quota_flag' => 'F',
173 'svc_acct__quota' => '10',
174 'svc_acct__slipip_flag' => 'F',
175 'svc_acct__slipip' => '',
176 'svc_acct___password_flag' => '',
177 'svc_acct___password' => '',
178 'svc_acct__gid_flag' => '',
179 'svc_acct__gid' => '',
180 'svc_acct__shell_flag' => 'F',
181 'svc_acct__shell' => '/bin/passwd',
182 'svc_acct__finger_flag' => '',
183 'svc_acct__finger' => '',
184 'svc_domain__domain_flag' => '',
185 'svc_domain__domain' => '',
186 'svc_acct_sm__domuser_flag' => '',
187 'svc_acct_sm__domuser' => '',
188 'svc_acct_sm__domuid_flag' => '',
189 'svc_acct_sm__domuid' => '',
190 'svc_acct_sm__domsvc_flag' => '',
191 'svc_acct_sm__domsvc' => '',
193 'location' => 'browse/part_svc.cgi',
195 { 'url' => 'edit/process/part_svc.cgi',
199 'svcdb' => 'svc_domain',,
200 'svc_acct__popnum_flag' => '',
201 'svc_acct__popnum' => '',
202 'svc_acct__dir_flag' => '',
203 'svc_acct__dir' => '',
204 'svc_acct__username_flag' => '',
205 'svc_acct__username' => '',
206 'svc_acct__uid_flag' => '',
207 'svc_acct__uid' => '',
208 'svc_acct__quota_flag' => '',
209 'svc_acct__quota' => '',
210 'svc_acct__slipip_flag' => '',
211 'svc_acct__slipip' => '',
212 'svc_acct___password_flag' => '',
213 'svc_acct___password' => '',
214 'svc_acct__gid_flag' => '',
215 'svc_acct__gid' => '',
216 'svc_acct__shell_flag' => '',
217 'svc_acct__shell' => '',
218 'svc_acct__finger_flag' => '',
219 'svc_acct__finger' => '',
220 'svc_domain__domain_flag' => '',
221 'svc_domain__domain' => '',
222 'svc_acct_sm__domuser_flag' => '',
223 'svc_acct_sm__domuser' => '',
224 'svc_acct_sm__domuid_flag' => '',
225 'svc_acct_sm__domuid' => '',
226 'svc_acct_sm__domsvc_flag' => '',
227 'svc_acct_sm__domsvc' => '',
229 'location' => 'browse/part_svc.cgi',
231 { 'url' => 'edit/process/part_svc.cgi',
234 'svc' => 'Domain email alias',
235 'svcdb' => 'svc_acct_sm',,
236 'svc_acct__popnum_flag' => '',
237 'svc_acct__popnum' => '',
238 'svc_acct__dir_flag' => '',
239 'svc_acct__dir' => '',
240 'svc_acct__username_flag' => '',
241 'svc_acct__username' => '',
242 'svc_acct__uid_flag' => '',
243 'svc_acct__uid' => '',
244 'svc_acct__quota_flag' => '',
245 'svc_acct__quota' => '',
246 'svc_acct__slipip_flag' => '',
247 'svc_acct__slipip' => '',
248 'svc_acct___password_flag' => '',
249 'svc_acct___password' => '',
250 'svc_acct__gid_flag' => '',
251 'svc_acct__gid' => '',
252 'svc_acct__shell_flag' => '',
253 'svc_acct__shell' => '',
254 'svc_acct__finger_flag' => '',
255 'svc_acct__finger' => '',
256 'svc_domain__domain_flag' => '',
257 'svc_domain__domain' => '',
258 'svc_acct_sm__domuser_flag' => '',
259 'svc_acct_sm__domuser' => '',
260 'svc_acct_sm__domuid_flag' => '',
261 'svc_acct_sm__domuid' => '',
262 'svc_acct_sm__domsvc_flag' => '',
263 'svc_acct_sm__domsvc' => '',
265 'location' => 'browse/part_svc.cgi',
268 { 'url' => 'edit/process/part_pkg.cgi',
271 'pkg' => 'Personal SLIP/PPP',
272 'comment' => '$30/setup, $19.99/month',
282 'location' => 'browse/part_pkg.cgi',
284 { 'url' => 'edit/process/part_pkg.cgi',
287 'pkg' => 'Personal SLIP/PPP',
288 'comment' => '$0/setup, $179.88/year',
298 'location' => 'browse/part_pkg.cgi',
300 { 'url' => 'edit/process/part_pkg.cgi',
303 'pkg' => 'Personal POP mailbox',
304 'comment' => '$10/setup, $5/month',
314 'location' => 'browse/part_pkg.cgi',
316 { 'url' => 'edit/process/part_pkg.cgi',
319 'pkg' => 'Business SLIP/PPP',
320 'comment' => '$30/setup, $29.99/month',
330 'location' => 'browse/part_pkg.cgi',
332 { 'url' => 'edit/process/part_pkg.cgi',
335 'pkg' => 'Business SLIP/PPP',
336 'comment' => '$0/setup, $299.88/year',
346 'location' => 'browse/part_pkg.cgi',
348 { 'url' => 'edit/process/part_pkg.cgi',
351 'pkg' => 'Business POP mailbox',
352 'comment' => '$10/setup, $5/month',
362 'location' => 'browse/part_pkg.cgi',
364 { 'url' => 'edit/process/part_pkg.cgi',
367 'pkg' => 'UNIX shell',
368 'comment' => '$20/setup, $9.99/month',
378 'location' => 'browse/part_pkg.cgi',
380 { 'url' => 'edit/process/part_pkg.cgi',
383 'pkg' => 'Point-to-point T1',
384 'comment' => '$1000/setup, $1000/month',
394 'location' => 'browse/part_pkg.cgi',
396 { 'url' => 'edit/process/part_pkg.cgi',
399 'pkg' => 'Cisco 2501 Router',
400 'comment' => '$2500',
410 'location' => 'browse/part_pkg.cgi',
413 { 'url' => 'edit/process/agent_type.cgi',
416 'atype' => 'Internal Sales',
427 'location' => 'browse/agent_type.cgi',
430 { 'url' => 'edit/process/agent.cgi',
433 'agent' => 'Internal Sales',
438 'location' => 'browse/agent.cgi',
441 { 'url' => 'edit/process/part_referral.cgi',
444 'referral' => 'Another customer',
446 'location' => 'browse/part_referral.cgi',
448 { 'url' => 'edit/process/part_referral.cgi',
451 'referral' => 'Newspaper ad',
453 'location' => 'browse/part_referral.cgi',
456 { 'url' => 'edit/process/svc_acct_pop.cgi',
459 'city' => 'Line Lexington',
464 'location' => 'browse/svc_acct_pop.cgi',
466 { 'url' => 'edit/process/svc_acct_pop.cgi',
474 'location' => 'browse/svc_acct_pop.cgi',
477 { 'url' => 'edit/process/cust_main.cgi',
483 'first' => 'Shawn D.',
485 'company' => 'Digital Point Solutions',
486 'address1' => '3570 Tony Drive',
488 'city' => 'San Diego',
489 'state' => 'CA / US',
490 'zip' => '92122-2307',
495 'invoicing_list_POST' => '',
496 'invoicing_list' => '',
498 'CARD_payinfo' => '',
500 'CARD_year' => '1999',
501 'CARD_payname' => '',
502 'BILL_payinfo' => '',
503 'BILL_month' => '12',
504 'BILL_year' => '2037',
505 'BILL_payname' => 'Accounts Payable',
506 'COMP_payinfo' => '',
508 'COMP_year' => '1999',
509 'pkgpart_svcpart' => '1_2',
510 'username' => 'cyborg',
513 'otaker' => 'example',
515 'location' => 'view/cust_main.cgi?1',
517 { 'url' => 'edit/process/cust_main.cgi',
525 'company' => 'Boardtown Corporation',
526 'address1' => '116 East Main Street',
528 'city' => 'Starkville',
529 'state' => 'MS / US',
535 'invoicing_list_POST' => '',
536 'invoicing_list' => '',
538 'CARD_payinfo' => '',
540 'CARD_year' => '1999',
541 'CARD_payname' => '',
542 'BILL_payinfo' => '',
543 'BILL_month' => '12',
544 'BILL_year' => '2037',
545 'BILL_payname' => 'Accounts Payable',
546 'COMP_payinfo' => '',
548 'COMP_year' => '1999',
549 'pkgpart_svcpart' => '3_3',
550 'username' => 'billf',
553 'otaker' => 'example',
555 'location' => 'view/cust_main.cgi?2',