3 # This is the beginning of a test suite for the web interface.
4 # It's also excellent for populating your database with some meaningful test
5 # data. (a derivative is used by the web demo)
6 # It only works on an empty database (probably need empty counters too, and
7 # no arbirary RADIUS attributes).
8 # Usage: cgi-test http://base.freeside.url/with/path/ username password
9 # (Yes, if you were properly paranoid and are using SSL, you'll need to get
10 # libwww-perl working with SSL to use this.)
14 use subs qw( big_ugly_data_structure );
18 my ( $base_url, $username, $password ) = ( shift, shift, shift );
20 $base_url =~ /^(.*)$/; $base_url = $1;
21 $username =~ /^(.*)$/; $username = $1;
22 $password =~ /^(.*)$/; $password = $1;
24 my @data = &big_ugly_data_structure;
26 my $ua = new LWP::UserAgent;
30 sub LWP::UserAgent::get_basic_credentials {
32 ( $username, $password );
38 while ( $data = shift @data ) {
39 my $cgi = new CGI ( $data->{'params'} );
40 my $full_url = $base_url. $data->{'url'}. '?'. $cgi->query_string;
41 #my $request = new HTTP::Request( 'POST', $full_url );
42 my $request = new HTTP::Request( 'GET', $full_url );
43 my $response = $ua->request( $request );
44 if ( $response->is_redirect ) {
45 die "Unexpected redirect!\n".
47 "To: ". $response->base. "\n"
49 } elsif ( $response->is_success ) {
50 my $location = $response->base;
51 my $expected_location = $data->{'location'};
52 #if ( $location =~ /^$base_url$expected_location$/ ) {
53 if ( $location eq $base_url. $expected_location ) {
54 #warn "cool, got expected response $location from $full_url\n";
56 die "Strange, regular response, but unexpected base!\n".
58 "Base : ". $response->base. "\n".
59 "Expected: $base_url$expected_location\n".
60 "Output: ". $response->content. "\n"
63 } elsif ( $response->is_error ) {
64 die "Strange, I got an error\n".
66 "Error: ". $response->error_as_HTML. "\n".
67 "Output: ". $response->content. "\n"
69 } elsif ( $response->is_info ) {
70 die "Strange, I got an info reponse\n".
72 "Output: ". $response->content. "\n"
75 die "Really strange, got an unrecognized response from LWP::UserAgent!\n";
81 sub big_ugly_data_structure {
84 { 'url' => 'edit/process/part_svc.cgi',
88 'svcdb' => 'svc_acct',
89 'svc_acct__popnum_flag' => '',
90 'svc_acct__popnum' => '',
91 'svc_acct__dir_flag' => '',
92 'svc_acct__dir' => '',
93 'svc_acct__username_flag' => '',
94 'svc_acct__username' => '',
95 'svc_acct__uid_flag' => '',
96 'svc_acct__uid' => '',
97 'svc_acct__quota_flag' => 'F',
98 'svc_acct__quota' => '10',
99 'svc_acct__slipip_flag' => 'F',
100 'svc_acct__slipip' => '',
101 'svc_acct___password_flag' => '',
102 'svc_acct___password' => '',
103 'svc_acct__gid_flag' => '',
104 'svc_acct__gid' => '',
105 'svc_acct__shell_flag' => 'D',
106 'svc_acct__shell' => '/bin/sh',
107 'svc_acct__finger_flag' => '',
108 'svc_acct__finger' => '',
109 'svc_domain__domain_flag' => '',
110 'svc_domain__domain' => '',
111 'svc_acct_sm__domuser_flag' => '',
112 'svc_acct_sm__domuser' => '',
113 'svc_acct_sm__domuid_flag' => '',
114 'svc_acct_sm__domuid' => '',
115 'svc_acct_sm__domsvc_flag' => '',
116 'svc_acct_sm__domsvc' => '',
118 'location' => 'browse/part_svc.cgi',
120 { 'url' => 'edit/process/part_svc.cgi',
124 'svcdb' => 'svc_acct',
125 'svc_acct__popnum_flag' => '',
126 'svc_acct__popnum' => '',
127 'svc_acct__dir_flag' => '',
128 'svc_acct__dir' => '',
129 'svc_acct__username_flag' => '',
130 'svc_acct__username' => '',
131 'svc_acct__uid_flag' => '',
132 'svc_acct__uid' => '',
133 'svc_acct__quota_flag' => 'F',
134 'svc_acct__quota' => '10',
135 'svc_acct__slipip_flag' => 'D',
136 'svc_acct__slipip' => '0.0.0.0',
137 'svc_acct___password_flag' => '',
138 'svc_acct___password' => '',
139 'svc_acct__gid_flag' => '',
140 'svc_acct__gid' => '',
141 'svc_acct__shell_flag' => 'D',
142 'svc_acct__shell' => '/bin/sh',
143 'svc_acct__finger_flag' => '',
144 'svc_acct__finger' => '',
145 'svc_domain__domain_flag' => '',
146 'svc_domain__domain' => '',
147 'svc_acct_sm__domuser_flag' => '',
148 'svc_acct_sm__domuser' => '',
149 'svc_acct_sm__domuid_flag' => '',
150 'svc_acct_sm__domuid' => '',
151 'svc_acct_sm__domsvc_flag' => '',
152 'svc_acct_sm__domsvc' => '',
154 'location' => 'browse/part_svc.cgi',
156 { 'url' => 'edit/process/part_svc.cgi',
159 'svc' => 'POP Mailbox',
160 'svcdb' => 'svc_acct',,
161 'svc_acct__popnum_flag' => 'F',
162 'svc_acct__popnum' => '',
163 'svc_acct__dir_flag' => '',
164 'svc_acct__dir' => '',
165 'svc_acct__username_flag' => '',
166 'svc_acct__username' => '',
167 'svc_acct__uid_flag' => '',
168 'svc_acct__uid' => '',
169 'svc_acct__quota_flag' => 'F',
170 'svc_acct__quota' => '10',
171 'svc_acct__slipip_flag' => 'F',
172 'svc_acct__slipip' => '',
173 'svc_acct___password_flag' => '',
174 'svc_acct___password' => '',
175 'svc_acct__gid_flag' => '',
176 'svc_acct__gid' => '',
177 'svc_acct__shell_flag' => 'F',
178 'svc_acct__shell' => '/bin/passwd',
179 'svc_acct__finger_flag' => '',
180 'svc_acct__finger' => '',
181 'svc_domain__domain_flag' => '',
182 'svc_domain__domain' => '',
183 'svc_acct_sm__domuser_flag' => '',
184 'svc_acct_sm__domuser' => '',
185 'svc_acct_sm__domuid_flag' => '',
186 'svc_acct_sm__domuid' => '',
187 'svc_acct_sm__domsvc_flag' => '',
188 'svc_acct_sm__domsvc' => '',
190 'location' => 'browse/part_svc.cgi',
192 { 'url' => 'edit/process/part_svc.cgi',
196 'svcdb' => 'svc_domain',,
197 'svc_acct__popnum_flag' => '',
198 'svc_acct__popnum' => '',
199 'svc_acct__dir_flag' => '',
200 'svc_acct__dir' => '',
201 'svc_acct__username_flag' => '',
202 'svc_acct__username' => '',
203 'svc_acct__uid_flag' => '',
204 'svc_acct__uid' => '',
205 'svc_acct__quota_flag' => '',
206 'svc_acct__quota' => '',
207 'svc_acct__slipip_flag' => '',
208 'svc_acct__slipip' => '',
209 'svc_acct___password_flag' => '',
210 'svc_acct___password' => '',
211 'svc_acct__gid_flag' => '',
212 'svc_acct__gid' => '',
213 'svc_acct__shell_flag' => '',
214 'svc_acct__shell' => '',
215 'svc_acct__finger_flag' => '',
216 'svc_acct__finger' => '',
217 'svc_domain__domain_flag' => '',
218 'svc_domain__domain' => '',
219 'svc_acct_sm__domuser_flag' => '',
220 'svc_acct_sm__domuser' => '',
221 'svc_acct_sm__domuid_flag' => '',
222 'svc_acct_sm__domuid' => '',
223 'svc_acct_sm__domsvc_flag' => '',
224 'svc_acct_sm__domsvc' => '',
226 'location' => 'browse/part_svc.cgi',
228 { 'url' => 'edit/process/part_svc.cgi',
231 'svc' => 'Domain email alias',
232 'svcdb' => 'svc_acct_sm',,
233 'svc_acct__popnum_flag' => '',
234 'svc_acct__popnum' => '',
235 'svc_acct__dir_flag' => '',
236 'svc_acct__dir' => '',
237 'svc_acct__username_flag' => '',
238 'svc_acct__username' => '',
239 'svc_acct__uid_flag' => '',
240 'svc_acct__uid' => '',
241 'svc_acct__quota_flag' => '',
242 'svc_acct__quota' => '',
243 'svc_acct__slipip_flag' => '',
244 'svc_acct__slipip' => '',
245 'svc_acct___password_flag' => '',
246 'svc_acct___password' => '',
247 'svc_acct__gid_flag' => '',
248 'svc_acct__gid' => '',
249 'svc_acct__shell_flag' => '',
250 'svc_acct__shell' => '',
251 'svc_acct__finger_flag' => '',
252 'svc_acct__finger' => '',
253 'svc_domain__domain_flag' => '',
254 'svc_domain__domain' => '',
255 'svc_acct_sm__domuser_flag' => '',
256 'svc_acct_sm__domuser' => '',
257 'svc_acct_sm__domuid_flag' => '',
258 'svc_acct_sm__domuid' => '',
259 'svc_acct_sm__domsvc_flag' => '',
260 'svc_acct_sm__domsvc' => '',
262 'location' => 'browse/part_svc.cgi',
265 { 'url' => 'edit/process/part_pkg.cgi',
268 'pkg' => 'Personal SLIP/PPP',
269 'comment' => '$30/setup, $19.99/month',
279 'location' => 'browse/part_pkg.cgi',
281 { 'url' => 'edit/process/part_pkg.cgi',
284 'pkg' => 'Personal SLIP/PPP',
285 'comment' => '$0/setup, $179.88/year',
295 'location' => 'browse/part_pkg.cgi',
297 { 'url' => 'edit/process/part_pkg.cgi',
300 'pkg' => 'Personal POP mailbox',
301 'comment' => '$10/setup, $5/month',
311 'location' => 'browse/part_pkg.cgi',
313 { 'url' => 'edit/process/part_pkg.cgi',
316 'pkg' => 'Business SLIP/PPP',
317 'comment' => '$30/setup, $29.99/month',
327 'location' => 'browse/part_pkg.cgi',
329 { 'url' => 'edit/process/part_pkg.cgi',
332 'pkg' => 'Business SLIP/PPP',
333 'comment' => '$0/setup, $299.88/year',
343 'location' => 'browse/part_pkg.cgi',
345 { 'url' => 'edit/process/part_pkg.cgi',
348 'pkg' => 'Business POP mailbox',
349 'comment' => '$10/setup, $5/month',
359 'location' => 'browse/part_pkg.cgi',
361 { 'url' => 'edit/process/part_pkg.cgi',
364 'pkg' => 'UNIX shell',
365 'comment' => '$20/setup, $9.99/month',
375 'location' => 'browse/part_pkg.cgi',
377 { 'url' => 'edit/process/part_pkg.cgi',
380 'pkg' => 'Point-to-point T1',
381 'comment' => '$1000/setup, $1000/month',
391 'location' => 'browse/part_pkg.cgi',
393 { 'url' => 'edit/process/part_pkg.cgi',
396 'pkg' => 'Cisco 2501 Router',
397 'comment' => '$2500',
407 'location' => 'browse/part_pkg.cgi',
410 { 'url' => 'edit/process/agent_type.cgi',
413 'atype' => 'Internal Sales',
424 'location' => 'browse/agent_type.cgi',
427 { 'url' => 'edit/process/agent.cgi',
430 'agent' => 'Internal Sales',
435 'location' => 'browse/agent.cgi',
438 { 'url' => 'edit/process/part_referral.cgi',
441 'referral' => 'Another customer',
443 'location' => 'browse/part_referral.cgi',
445 { 'url' => 'edit/process/part_referral.cgi',
448 'referral' => 'Newspaper ad',
450 'location' => 'browse/part_referral.cgi',
453 { 'url' => 'edit/process/svc_acct_pop.cgi',
456 'city' => 'Line Lexington',
461 'location' => 'browse/svc_acct_pop.cgi',
463 { 'url' => 'edit/process/svc_acct_pop.cgi',
471 'location' => 'browse/svc_acct_pop.cgi',
474 { 'url' => 'edit/process/cust_main.cgi',
480 'first' => 'Shawn D.',
482 'company' => 'Digital Point Solutions',
483 'address1' => '3570 Tony Drive',
485 'city' => 'San Diego',
486 'state' => 'CA / US',
487 'zip' => '92122-2307',
492 'invoicing_list_POST' => '',
493 'invoicing_list' => '',
495 'CARD_payinfo' => '',
497 'CARD_year' => '1999',
498 'CARD_payname' => '',
499 'BILL_payinfo' => '',
500 'BILL_month' => '12',
501 'BILL_year' => '2037',
502 'BILL_payname' => 'Accounts Payable',
503 'COMP_payinfo' => '',
505 'COMP_year' => '1999',
506 'pkgpart_svcpart' => '1_2',
507 'username' => 'cyborg',
510 'otaker' => 'example',
512 'location' => 'view/cust_main.cgi?1',
514 { 'url' => 'edit/process/cust_main.cgi',
522 'company' => 'Boardtown Corporation',
523 'address1' => '116 East Main Street',
525 'city' => 'Starkville',
526 'state' => 'MS / US',
532 'invoicing_list_POST' => '',
533 'invoicing_list' => '',
535 'CARD_payinfo' => '',
537 'CARD_year' => '1999',
538 'CARD_payname' => '',
539 'BILL_payinfo' => '',
540 'BILL_month' => '12',
541 'BILL_year' => '2037',
542 'BILL_payname' => 'Accounts Payable',
543 'COMP_payinfo' => '',
545 'COMP_year' => '1999',
546 'pkgpart_svcpart' => '3_3',
547 'username' => 'billf',
550 'otaker' => 'example',
552 'location' => 'view/cust_main.cgi?2',