File: author-22_local_privileged_pass.t

package info (click to toggle)
libnet-appliance-session-perl 4.300005-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 188 kB
  • sloc: perl: 1,048; makefile: 11
file content (54 lines) | stat: -rw-r--r-- 1,358 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/perl

BEGIN {
  unless ($ENV{AUTHOR_TESTING}) {
    require Test::More;
    Test::More::plan(skip_all => 'these tests are for testing by the author');
  }
}


BEGIN {
  if ($ENV{NOT_AT_HOME}) {
    require Test::More;
    Test::More::plan(skip_all => 'these tests can only be run by the author when at home');
  }
}

use strict; use warnings FATAL => 'all';
use Test::More 0.88;

BEGIN { use_ok( 'Net::Appliance::Session') }

my $s = new_ok( 'Net::Appliance::Session' => [{
    transport => "Telnet",
    ($^O eq 'MSWin32' ?
        (app => "$ENV{HOMEPATH}\\Desktop\\plink.exe") : () ),
    host => '172.16.20.55',
    personality => "ios",
}]);

my @out = ();

ok( $s->connect({
    username => 'Cisco',
    password => ($ENV{IOS_PASS} || 'letmein'),
    privileged_password => ($ENV{IOS_PASS} || 'letmein') . 'x',
}), 'connect with bad privileged_password' );

# should fail
eval { $s->begin_privileged };
like( $@, qr/read timed-out|timeout on timer/, 'begin priv, bad pass' );
ok( eval{$s->close;1}, 'disconnected' );

# should be OK
ok( $s->connect({
    username => 'Cisco',
    password => ($ENV{IOS_PASS} || 'letmein'),
    privileged_password => ($ENV{IOS_PASS} || 'letmein') . '',
}), 'connected ok' );

ok( $s->begin_privileged, 'begin priv, no pass' );
ok( eval{$s->close;1}, 'disconnected, backed out of privileged' );

done_testing;