aaa3715b16777b63c78804b61c9e07f7d263f04d
[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 tunnel, and an account on the APP server.
37
38 END
39
40 my $hostname = input "Enter the local (cleartext) APP proxy hostname or IP: ";
41 my $port = input "Enter the local (cleartext) APP proxy port number: ";
42 my $user = input "Enter your APP username: ";
43 my $domain = input "Enter your APP domain: ";
44
45 system("stty -echo");
46 my $password = input "Enter your APP password: "; 
47 print "\n\n"; system("stty echo");
48
49 test 2, my $app = new Net::APP ( "$hostname:$port",
50                                   Debug => 1,
51                                 );
52 test 3, $app->login( User => $user,
53                      Domain => $domain,
54                      Password => $password,
55                    );
56 test 4, $app->code == 0;
57 test 5, $app->quit;
58 test 6, $app->code == 0;
59 $app->close();
60 undef $app;
61 test 6, $app = new Net::APP ( "$hostname:$port",
62                               Debug => 1,
63                               User => $user,
64                               Domain => $domain,
65                               Password => $password,
66                             );
67 test 7, $app->code == 0;
68 test 8, $app->quit;
69 test 9, $app->code == 0;
70 $app->close();
71 undef $app;
72
73