enable package class condition for invoices, #14499
[freeside.git] / test / cgi-test
1 #!/usr/bin/perl -Tw
2 #
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.)
11
12 use strict;
13 #use diagnostics;
14 use subs qw( big_ugly_data_structure );
15 use CGI;
16 use LWP::UserAgent;
17
18 my ( $base_url, $username, $password ) = ( shift, shift, shift );
19 #trust 'em
20 $base_url =~ /^(.*)$/; $base_url = $1;
21 $username =~ /^(.*)$/; $username = $1;
22 $password =~ /^(.*)$/; $password = $1;
23
24 my @data = &big_ugly_data_structure;
25
26 my $ua = new LWP::UserAgent;
27 {
28   local $^W = 0;
29   eval '
30     sub LWP::UserAgent::get_basic_credentials {
31       #my $self = shift;
32       ( $username, $password );
33     }
34   ';
35 }
36
37 my $data;
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".
46            "URL: $full_url\n".
47            "To: ". $response->base. "\n"
48     ;
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";
55     } else {
56       die "Strange, regular response, but unexpected base!\n".
57         "URL: $full_url\n".
58         "Base    : ". $response->base. "\n".
59         "Expected: $base_url$expected_location\n".
60         "Output: ". $response->content. "\n"
61       ;
62     }
63   } elsif ( $response->is_error ) {
64     die "Strange, I got an error\n".
65         "URL: $full_url\n".
66         "Error: ". $response->error_as_HTML. "\n".
67         "Output: ". $response->content. "\n"
68     ;
69   } elsif ( $response->is_info ) {
70     die "Strange, I got an info reponse\n".
71         "URL: $full_url\n".
72         "Output: ". $response->content. "\n"
73     ;
74   } else {
75     die "Really strange, got an unrecognized response from LWP::UserAgent!\n";
76   }
77 }
78
79 #---
80
81 sub big_ugly_data_structure {
82
83   (
84     { 'url'      => 'edit/process/part_svc.cgi',
85       'params'   => {
86                       'svcpart' => '',
87                       'svc'     => 'Shell',
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' => '',
117                     },
118       'location' => 'browse/part_svc.cgi',
119     },
120     { 'url'      => 'edit/process/part_svc.cgi',
121       'params'   => {
122                       'svcpart' => '',
123                       'svc'     => 'SLIP/PPP',
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' => '',
153                     },
154       'location' => 'browse/part_svc.cgi',
155     },
156     { 'url'      => 'edit/process/part_svc.cgi',
157       'params'   => {
158                       'svcpart' => '',
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' => '',
189                     },
190       'location' => 'browse/part_svc.cgi',
191     },
192     { 'url'      => 'edit/process/part_svc.cgi',
193       'params'   => {
194                       'svcpart' => '',
195                       'svc'     => 'Domain',
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' => '',
225                     },
226       'location' => 'browse/part_svc.cgi',
227     },
228     { 'url'      => 'edit/process/part_svc.cgi',
229       'params'   => {
230                       'svcpart' => '',
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' => '',
261                     },
262       'location' => 'browse/part_svc.cgi',
263     },
264
265     { 'url'      => 'edit/process/part_pkg.cgi',
266       'params'   => {
267                       'pkgpart' => '',
268                       'pkg' => 'Personal SLIP/PPP',
269                       'comment' => '$30/setup, $19.99/month',
270                       'setup' => '30',
271                       'recur' => '19.99',
272                       'freq' => '1',
273                       'pkg_svc1' => '0',
274                       'pkg_svc2' => '1',
275                       'pkg_svc3' => '0',
276                       'pkg_svc4' => '0',
277                       'pkg_svc5' => '0',
278                     },
279       'location' => 'browse/part_pkg.cgi',
280     },
281     { 'url'      => 'edit/process/part_pkg.cgi',
282       'params'   => {
283                       'pkgpart' => '',
284                       'pkg' => 'Personal SLIP/PPP',
285                       'comment' => '$0/setup, $179.88/year',
286                       'setup' => '0',
287                       'recur' => '179.88',
288                       'freq' => '12',
289                       'pkg_svc1' => '0',
290                       'pkg_svc2' => '1',
291                       'pkg_svc3' => '0',
292                       'pkg_svc4' => '0',
293                       'pkg_svc5' => '0',
294                     },
295       'location' => 'browse/part_pkg.cgi',
296     },
297     { 'url'      => 'edit/process/part_pkg.cgi',
298       'params'   => {
299                       'pkgpart' => '',
300                       'pkg' => 'Personal POP mailbox',
301                       'comment' => '$10/setup, $5/month',
302                       'setup' => '10',
303                       'recur' => '5',
304                       'freq' => '1',
305                       'pkg_svc1' => '0',
306                       'pkg_svc2' => '0',
307                       'pkg_svc3' => '1',
308                       'pkg_svc4' => '0',
309                       'pkg_svc5' => '0',
310                     },
311       'location' => 'browse/part_pkg.cgi',
312     },
313     { 'url'      => 'edit/process/part_pkg.cgi',
314       'params'   => {
315                       'pkgpart' => '',
316                       'pkg' => 'Business SLIP/PPP',
317                       'comment' => '$30/setup, $29.99/month',
318                       'setup' => '30',
319                       'recur' => '29.99',
320                       'freq' => '1',
321                       'pkg_svc1' => '0',
322                       'pkg_svc2' => '1',
323                       'pkg_svc3' => '0',
324                       'pkg_svc4' => '1',
325                       'pkg_svc5' => '1',
326                     },
327       'location' => 'browse/part_pkg.cgi',
328     },
329     { 'url'      => 'edit/process/part_pkg.cgi',
330       'params'   => {
331                       'pkgpart' => '',
332                       'pkg' => 'Business SLIP/PPP',
333                       'comment' => '$0/setup, $299.88/year',
334                       'setup' => '0',
335                       'recur' => '299.88',
336                       'freq' => '12',
337                       'pkg_svc1' => '0',
338                       'pkg_svc2' => '1',
339                       'pkg_svc3' => '0',
340                       'pkg_svc4' => '1',
341                       'pkg_svc5' => '1',
342                     },
343       'location' => 'browse/part_pkg.cgi',
344     },
345     { 'url'      => 'edit/process/part_pkg.cgi',
346       'params'   => {
347                       'pkgpart' => '',
348                       'pkg' => 'Business POP mailbox',
349                       'comment' => '$10/setup, $5/month',
350                       'setup' => '10',
351                       'recur' => '5',
352                       'freq' => '1',
353                       'pkg_svc1' => '0',
354                       'pkg_svc2' => '0',
355                       'pkg_svc3' => '1',
356                       'pkg_svc4' => '0',
357                       'pkg_svc5' => '1',
358                     },
359       'location' => 'browse/part_pkg.cgi',
360     },
361     { 'url'      => 'edit/process/part_pkg.cgi',
362       'params'   => {
363                       'pkgpart' => '',
364                       'pkg' => 'UNIX shell',
365                       'comment' => '$20/setup, $9.99/month',
366                       'setup' => '20',
367                       'recur' => '9.99',
368                       'freq' => '1',
369                       'pkg_svc1' => '1',
370                       'pkg_svc2' => '0',
371                       'pkg_svc3' => '0',
372                       'pkg_svc4' => '0',
373                       'pkg_svc5' => '0',
374                     },
375       'location' => 'browse/part_pkg.cgi',
376     },
377     { 'url'      => 'edit/process/part_pkg.cgi',
378       'params'   => {
379                       'pkgpart' => '',
380                       'pkg' => 'Point-to-point T1',
381                       'comment' => '$1000/setup, $1000/month',
382                       'setup' => '1000',
383                       'recur' => '1000',
384                       'freq' => '1',
385                       'pkg_svc1' => '0',
386                       'pkg_svc2' => '0',
387                       'pkg_svc3' => '5',
388                       'pkg_svc4' => '1',
389                       'pkg_svc5' => '5',
390                     },
391       'location' => 'browse/part_pkg.cgi',
392     },
393     { 'url'      => 'edit/process/part_pkg.cgi',
394       'params'   => {
395                       'pkgpart' => '',
396                       'pkg' => 'Cisco 2501 Router',
397                       'comment' => '$2500',
398                       'setup' => '2500',
399                       'recur' => '0',
400                       'freq' => '0',
401                       'pkg_svc1' => '0',
402                       'pkg_svc2' => '0',
403                       'pkg_svc3' => '0',
404                       'pkg_svc4' => '0',
405                       'pkg_svc5' => '0',
406                     },
407       'location' => 'browse/part_pkg.cgi',
408     },
409
410     { 'url'      => 'edit/process/agent_type.cgi',
411       'params'   => {
412                       'typenum' => '',
413                       'atype' => 'Internal Sales',
414                       'pkgpart1' => 'ON',
415                       'pkgpart2' => 'ON',
416                       'pkgpart3' => 'ON',
417                       'pkgpart4' => 'ON',
418                       'pkgpart5' => 'ON',
419                       'pkgpart6' => 'ON',
420                       'pkgpart7' => 'ON',
421                       'pkgpart8' => 'ON',
422                       'pkgpart9' => 'ON',
423                     },
424       'location' => 'browse/agent_type.cgi',
425     },
426
427     { 'url'      => 'edit/process/agent.cgi',
428       'params'   => {
429                       'agentnum' => '',
430                       'agent' => 'Internal Sales',
431                       'typenum' => '1',
432                       'freq' => '',
433                       'prog' => '',
434                     },
435       'location' => 'browse/agent.cgi',
436     },
437
438     { 'url'      => 'edit/process/part_referral.cgi',
439       'params'   => {
440                       'refnum' => '',
441                       'referral' => 'Another customer',
442                     },
443       'location' => 'browse/part_referral.cgi',
444     },
445     { 'url'      => 'edit/process/part_referral.cgi',
446       'params'   => {
447                       'refnum' => '',
448                       'referral' => 'Newspaper ad',
449                     },
450       'location' => 'browse/part_referral.cgi',
451     },
452
453     { 'url'      => 'edit/process/svc_acct_pop.cgi',
454       'params'   => {
455                       'popnum' => '',
456                       'city' => 'Line Lexington',
457                       'state' => 'PA',
458                       'ac' => '215',
459                       'exch' => '996',
460                     },
461       'location' => 'browse/svc_acct_pop.cgi',
462     },
463     { 'url'      => 'edit/process/svc_acct_pop.cgi',
464       'params'   => {
465                       'popnum' => '',
466                       'city' => 'Oakland',
467                       'state' => 'CA',
468                       'ac' => '510',
469                       'exch' => '208',
470                     },
471       'location' => 'browse/svc_acct_pop.cgi',
472     },
473
474     { 'url'      => 'edit/process/cust_main.cgi',
475       'params'   => {
476                       'custnum' => '',
477                       'agentnum' => '1',
478                       'refnum' => '1',
479                       'last' => 'Hogan',
480                       'first' => 'Shawn D.',
481                       'ss' => '',
482                       'company' => 'Digital Point Solutions',
483                       'address1' => '3570 Tony Drive',
484                       'address2' => '',
485                       'city' => 'San Diego',
486                       'state' => 'CA / US',
487                       'zip' => '92122-2307',
488                       'daytime' => '',
489                       'night' => '',
490                       'fax' => '',
491                       'tax' => '',
492                       'invoicing_list_POST' => '',
493                       'invoicing_list' => '',
494                       'payby' => 'BILL',
495                       'CARD_payinfo' => '',
496                       'CARD_month' => '1',
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' => '',
504                       'COMP_month' => '1',
505                       'COMP_year' => '1999',
506                       'pkgpart_svcpart' => '1_2',
507                       'username' => 'cyborg',
508                       '_password' => '',
509                       'popnum' => '1',
510                       'otaker' => 'example',
511                     },
512       'location' => 'view/cust_main.cgi?1',
513     },
514     { 'url'      => 'edit/process/cust_main.cgi',
515       'params'   => {
516                       'custnum' => '',
517                       'agentnum' => '1',
518                       'refnum' => '2',
519                       'last' => 'Ford',
520                       'first' => 'Bill',
521                       'ss' => '',
522                       'company' => 'Boardtown Corporation',
523                       'address1' => '116 East Main Street',
524                       'address2' => '',
525                       'city' => 'Starkville',
526                       'state' => 'MS / US',
527                       'zip' => '39759',
528                       'daytime' => '',
529                       'night' => '',
530                       'fax' => '',
531                       'tax' => '',
532                       'invoicing_list_POST' => '',
533                       'invoicing_list' => '',
534                       'payby' => 'BILL',
535                       'CARD_payinfo' => '',
536                       'CARD_month' => '1',
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' => '',
544                       'COMP_month' => '1',
545                       'COMP_year' => '1999',
546                       'pkgpart_svcpart' => '3_3',
547                       'username' => 'billf',
548                       '_password' => '',
549                       'popnum' => '',
550                       'otaker' => 'example',
551                     },
552       'location' => 'view/cust_main.cgi?2',
553     },
554
555            
556   );
557 }
558