Annotation of trango/Net-Telnet-Trango/t/52-network-ap.t, Revision 1.1
1.1 ! andrew 1: #!perl -T
! 2: # $RedRiver: 50-network.t,v 1.5 2007/02/06 00:42:09 andrew Exp $
! 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: $t->input_log('input.log'); # XXX Debugging
! 49:
! 50: ok($t->open($host), "Opening connection to $host");
! 51:
! 52: ok($t->is_connected, "connected");
! 53:
! 54: ok($t->login($pass), "Logging in");
! 55:
! 56: ok($t->logged_in, "logged in");
! 57:
! 58: my $sudb = [];
! 59: if ((!ok($sudb = $t->sudb_view, "Getting sudb"))
! 60: && $t->last_error ) {
! 61: diag('ERR: ' . $t->last_error);
! 62: }
! 63:
! 64: my $opmode;
! 65: ok($opmode = $t->opmode, "getting current opmode");
! 66:
! 67: SKIP: {
! 68: skip("no SUDB", 1) unless @{ $sudb };
! 69: skip("already opmode ap", 1) if $opmode->{Opmode} eq 'ap';
! 70:
! 71: if ((! ok($result = $t->opmode('ap y'), "Setting opmode ap y"))
! 72: && $t->last_error ) {
! 73: diag('ERR: ' . $t->last_error);
! 74: }
! 75: }
! 76:
! 77: my $opmode_should_be = 'ap';
! 78: if (! @{ $sudb }) {
! 79: $opmode_should_be = 'off';
! 80: }
! 81:
! 82: $opmode = {};
! 83: if ((! ok($opmode = $t->opmode, "getting current opmode"))
! 84: && $t->last_error) {
! 85: diag('ERR: ' . $t->last_error);
! 86: }
! 87:
! 88: is($opmode->{Opmode}, $opmode_should_be,
! 89: "current Opmode $opmode_should_be");
! 90:
! 91: if (! ok($result = $t->save_ss, "Saving systemsetting")
! 92: && $t->last_error ) {
! 93: diag('ERR: ' . $t->last_error);
! 94: }
! 95:
! 96: ok($t->bye, "Goodbye");
! 97: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>