stunnel example usage update
[Net-APP.git] / test.pl
1 # Before `make install' is performed this script should be runnable with
2 # `make test'. After `make install' it should work as `perl test.pl'
3
4 ######################### We start with some black magic to print on failure.
5
6 # Change 1..1 below to 1..last_test_to_print .
7 # (It may become useful if the test is moved to ./t subdirectory.)
8
9 BEGIN { $| = 1; print "1..9\n"; }
10 END {print "not ok 1\n" unless $loaded;}
11 use Net::APP;
12 $loaded = 1;
13 print "ok 1\n";
14
15 ######################### End of black magic.
16
17 # Insert your test code below (better if it prints "ok 13"
18 # (correspondingly "not ok 13") depending on the success of chunk 13
19 # of the test code):
20
21 sub test {
22     local($^W) = 0;
23     my($num, $true,$msg) = @_;
24     print($true ? "ok $num\n" : "not ok $num: $msg $@\n");
25 }
26
27 sub input {
28   my $prompt = shift;
29   print $prompt;
30   chomp ( my $input = scalar(<STDIN>) );
31   $input;
32 }
33
34 print <<END;
35 In order to test Net::APP, you need a cleartext APP server available, i.e. a
36 Safe Passage or tunnel or Stunnel <http://www.stunnel.org>, and an account on
37 the APP server.
38
39 (i.e. stunnel -P none -c -d 8888 -r appsandbox.criticalpath.net:8889)
40
41 END
42
43 my $hostname = input "Enter the local (cleartext) APP proxy hostname or IP: ";
44 my $port = input "Enter the local (cleartext) APP proxy port number: ";
45 my $user = input "Enter your APP username: ";
46 my $domain = input "Enter your APP domain: ";
47
48 system("stty -echo");
49 my $password = input "Enter your APP password: "; 
50 print "\n\n"; system("stty echo");
51
52 test 2, my $app = new Net::APP ( "$hostname:$port",
53                                   Debug => 0,
54                                 );
55 test 3, $app->login( User => $user,
56                      Domain => $domain,
57                      Password => $password,
58                    );
59 test 4, $app->code == 0;
60 test 5, $app->quit;
61 test 6, $app->code == 0;
62 $app->close();
63 undef $app;
64 test 6, $app = new Net::APP ( "$hostname:$port",
65                               Debug => 0,
66                               User => $user,
67                               Domain => $domain,
68                               Password => $password,
69                             );
70 test 7, $app->code == 0;
71 test 8, $app->quit;
72 test 9, $app->code == 0;
73 $app->close();
74 undef $app;
75
76