[BACK]Return to 51-network-add_su-ap.t CVS log [TXT][DIR] Up to [local] / trango / Net-Telnet-Trango / t

Annotation of trango/Net-Telnet-Trango/t/51-network-add_su-ap.t, Revision 1.1

1.1     ! andrew      1: #!perl -T
        !             2: # $RedRiver: 50-network.t,v 1.4 2007/02/05 23:11:21 andrew Exp $
        !             3:
        !             4: use Test::More tests => 7;
        !             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("  Generic tests");
        !            13:
        !            14: my $cfg_file = File::Spec->catfile('t', 'tests.cfg');
        !            15: my ($cir, $mir) = (128, 256);
        !            16:
        !            17: SKIP: {
        !            18:     my $skipped = 6;
        !            19:     my %cfg;
        !            20:     if (-e $cfg_file) {
        !            21:         if (open my $fh, $cfg_file) {
        !            22:             while (<$fh>) {
        !            23:                 chomp;
        !            24:                 my ($key, $value) = split /\t/, $_, 2;
        !            25:                 $cfg{$key} = $value;
        !            26:             }
        !            27:             close $fh;
        !            28:         }
        !            29:     }
        !            30:
        !            31:     my $type = 'AP';
        !            32:     my ($host, $pass, $su_id, $su_mac);
        !            33:
        !            34:     if ($cfg{$type} && $cfg{$type} =~ /^(\d+\.\d+\.\d+.\d+)$/) {
        !            35:         $host = $1;
        !            36:     }
        !            37:
        !            38:     skip 'No valid ' . $type . ' in config file',        $skipped unless $host;
        !            39:
        !            40:     if ($cfg{$type . '_PASSWD'} && $cfg{$type . '_PASSWD'} =~ /^(.*)$/) {
        !            41:         $pass = $1;
        !            42:     }
        !            43:
        !            44:     skip 'No valid ' . $type . '_PASSWD in config file', $skipped unless $pass;
        !            45:
        !            46:     if ($cfg{SU_ID} && $cfg{SU_ID} =~ /^(\d+)$/) {
        !            47:         $su_id= $1;
        !            48:     }
        !            49:
        !            50:     skip 'No valid SU_ID in config file', $skipped unless $su_id;
        !            51:
        !            52:     if ($cfg{SU_MAC} && length $cfg{SU_MAC} >= 12 && $cfg{SU_MAC} =~ /^(.*)$/) {
        !            53:         $su_mac = $1;
        !            54:     }
        !            55:
        !            56:     skip 'No valid SU_MAC in config file', $skipped unless $su_mac;
        !            57:
        !            58:     my $t;
        !            59:     ok($t = Net::Telnet::Trango->new(), "Instantiating object");
        !            60:
        !            61:     $t->input_log('input.log'); # XXX Debugging
        !            62:
        !            63:     ok($t->open($host), "Opening connection to $host");
        !            64:
        !            65:     ok($t->is_connected, "connected");
        !            66:
        !            67:     ok($t->login($pass), "Logging in");
        !            68:
        !            69:     ok($t->logged_in, "logged in");
        !            70:
        !            71:
        !            72:     my $sudb;
        !            73:     ok($sudb = $t->sudb_view, "Getting sudb");
        !            74:
        !            75:     use YAML;
        !            76:     print Dump $sudb;
        !            77:
        !            78:     my $result;
        !            79:     ok($result = $t->sudb_add($su_id, 'reg', $cir, $mir, $su_mac), "Adding su");
        !            80:
        !            81:     if ( (! $result ) && $t->last_error ) {
        !            82:         diag('ERR: ' . $t->last_error);
        !            83:     }
        !            84:
        !            85:     ok($result = $t->save_sudb, "Saving sudb");
        !            86:
        !            87:     if ( (! $result ) && $t->last_error ) {
        !            88:         diag('ERR: ' . $t->last_error);
        !            89:     }
        !            90:
        !            91:     $result = $t->opmode('ap y');
        !            92:     if ( (! $result ) && $t->last_error ) {
        !            93:         diag('ERR: ' . $t->last_error);
        !            94:     }
        !            95:
        !            96:     my $opmode;
        !            97:     ok($opmode = $t->opmode, "getting current opmode");
        !            98:
        !            99:     if (ref $opmode eq 'HASH' && $opmode->{ERR}) {
        !           100:         diag("Error: $opmode->{ERR}");
        !           101:     }
        !           102:
        !           103:     is($opmode->{Opmode}, 'ap', "Checking opmode is ap");
        !           104:
        !           105:     ok($t->bye, "Goodbye");
        !           106: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>