File: author-42_ssh_fail_close.t

package info (click to toggle)
libnet-appliance-session-perl 4.142720-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 224 kB
  • ctags: 29
  • sloc: perl: 1,034; makefile: 8
file content (30 lines) | stat: -rw-r--r-- 688 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
#!/usr/bin/perl

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


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 => "SSH",
    ($^O eq 'MSWin32' ?
        (app => "$ENV{HOMEPATH}\\Desktop\\plink.exe") : () ),
    host => "bogus.example.com",
    personality => "cisco",
}]);

# should fail
eval { $s->connect };
like( $@, qr/Could not resolve hostname/, 'Unknown Host' );

ok( eval{$s->close;1}, 'disconnected without pathological behaviour' );

done_testing;