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