Annotation of trango/Net-Telnet-Trango/t/52-network-ap.t, Revision 1.2
1.1 andrew 1: #!perl -T
1.2 ! andrew 2: # $RedRiver: 52-network-ap.t,v 1.1 2007/02/06 16:52:42 andrew Exp $
1.1 andrew 3:
4: use Test::More tests => 13;
5: use File::Spec;
6:
7: BEGIN {
8: use_ok( 'Net::Telnet::Trango' );
9: }
10:
11: diag("Testing Net::Telnet::Trango $Net::Telnet::Trango::VERSION, Perl $], $^X");
12: diag(" AP tests");
13:
14: my $cfg_file = File::Spec->catfile('t', 'tests.cfg');
15:
16: SKIP: {
17: my $skipped = 12;
18: my %cfg;
19: if (-e $cfg_file) {
20: if (open my $fh, $cfg_file) {
21: while (<$fh>) {
22: chomp;
23: my ($key, $value) = split /\t/, $_, 2;
24: $cfg{$key} = $value;
25: }
26: close $fh;
27: }
28: }
29:
30: my $type = 'AP';
31: my ($host, $pass);
32:
33: if ($cfg{$type} && $cfg{$type} =~ /^(\d+\.\d+\.\d+.\d+)$/) {
34: $host = $1;
35: }
36:
37: skip 'No valid ' . $type . ' in config file', $skipped unless $host;
38:
39: if ($cfg{$type . '_PASSWD'} && $cfg{$type . '_PASSWD'} =~ /^(.*)$/) {
40: $pass = $1;
41: }
42:
43: skip 'No valid ' . $type . '_PASSWD in config file', $skipped unless $pass;
44:
45: my $t;
46: ok($t = Net::Telnet::Trango->new(), "Instantiating object");
47:
48: ok($t->open($host), "Opening connection to $host");
49:
50: ok($t->is_connected, "connected");
51:
52: ok($t->login($pass), "Logging in");
53:
54: ok($t->logged_in, "logged in");
55:
56: my $sudb = [];
57: if ((!ok($sudb = $t->sudb_view, "Getting sudb"))
58: && $t->last_error ) {
59: diag('ERR: ' . $t->last_error);
60: }
61:
62: my $opmode;
63: ok($opmode = $t->opmode, "getting current opmode");
64:
65: SKIP: {
66: skip("no SUDB", 1) unless @{ $sudb };
67: skip("already opmode ap", 1) if $opmode->{Opmode} eq 'ap';
68:
69: if ((! ok($result = $t->opmode('ap y'), "Setting opmode ap y"))
70: && $t->last_error ) {
71: diag('ERR: ' . $t->last_error);
72: }
73: }
74:
75: my $opmode_should_be = 'ap';
76: if (! @{ $sudb }) {
77: $opmode_should_be = 'off';
78: }
79:
80: $opmode = {};
81: if ((! ok($opmode = $t->opmode, "getting current opmode"))
82: && $t->last_error) {
83: diag('ERR: ' . $t->last_error);
84: }
85:
86: is($opmode->{Opmode}, $opmode_should_be,
87: "current Opmode $opmode_should_be");
88:
89: if (! ok($result = $t->save_ss, "Saving systemsetting")
90: && $t->last_error ) {
91: diag('ERR: ' . $t->last_error);
92: }
93:
94: ok($t->bye, "Goodbye");
95: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>