File Coverage

blib/lib/Test/SSH/Backend/Remote.pm
Criterion Covered Total %
statement 14 24 58.3
branch 1 6 16.6
condition n/a
subroutine 3 3 100.0
pod 0 1 0.0
total 18 34 52.9


line stmt bran cond sub pod time code
1             package Test::SSH::Backend::Remote;
2              
3 1     1   4 use strict;
  1         1  
  1         22  
4 1     1   3 use warnings;
  1         1  
  1         173  
5              
6             require Test::SSH::Backend::Base;
7             our @ISA = qw(Test::SSH::Backend::Base);
8              
9             sub new {
10 2     2 0 10 my ($class, %opts) = @_;
11 2         13 my $sshd = $class->SUPER::new(%opts);
12              
13 2 50       10 if (defined $sshd->{password}) {
14 0         0 $sshd->_log("trying to authenticate using given password");
15 0         0 $sshd->{auth_method} = 'password';
16 0 0       0 if ($sshd->_test_server) {
17 0         0 $sshd->_log("the given password can be used to connect to host");
18 0         0 return $sshd;
19             }
20             }
21              
22 2         6 $sshd->_log("trying to authenticate using keys");
23 2         258 $sshd->{auth_method} = 'publickey';
24 2         4 for my $key (@{$sshd->{user_keys}}) {
  2         7  
25 0         0 $sshd->_log("trying user key '$key'");
26 0         0 $sshd->{key_path} = $key;
27 0 0       0 if ($sshd->_test_server) {
28 0         0 $sshd->_log("key '$key' can be used to connect to host");
29 0         0 return $sshd;
30             }
31             }
32             ()
33 2         12 }
34              
35             1;