| 1 | package Net::SSH::Any::Test::Backend::Remote; | ||||||||||||||||
| 2 | |||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||
| 5 | |||||||||||||||||
| 6 | 1 | ▶ | use Net::SSH::Any; | ||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||
| 7 | 1 | ▶ | use Net::SSH::Any::Constants qw(SSHA_BACKEND_ERROR); | ||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||
| 8 | |||||||||||||||||
| 9 | 1 | ▶ | use parent 'Net::SSH::Any::Test::Backend::_Base'; | ||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||
| 10 | |||||||||||||||||
| 11 | 1 | ▶ | sub _start_and_check { | ||||||||||||||
|
Subroutine
_start_and_check: called CC=7 SCAR=34.4
| |||||||||||||||||
| 12 | 1 | my $tssh = shift; | |||||||||||||||
| 13 | |||||||||||||||||
| 14 | 1 | for my $uri (@{$tssh->{uris}}) { | |||||||||||||||
| 15 | 0 | ▶ | $tssh->_check_and_set_uri($uri) and return 1; | ||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||
| 16 | 0 | for my $key_path (@{$tssh->{key_paths}}) { | |||||||||||||||
| 17 | 0 | my $uri2 = Net::SSH::Any::URI->new($uri->uri); | |||||||||||||||
| 18 | 0 | $uri2->set(password => ()); | |||||||||||||||
| 19 | 0 | $uri2->set(key_path => $key_path); | |||||||||||||||
| 20 | 0 | ▶ | $tssh->_check_and_set_uri($uri2) and return 1; | ||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||
| 21 | } | ||||||||||||||||
| 22 | 0 | for my $password (@{$tssh->{passwords}}) { | |||||||||||||||
| 23 | 0 | my $uri2 = Net::SSH::Any::URI->new($uri->uri); | |||||||||||||||
| 24 | 0 | $uri2->set(password => $password); | |||||||||||||||
| 25 | 0 | $uri2->set(key_path => ()); | |||||||||||||||
| 26 | 0 | ▶ | $tssh->_check_and_set_uri($uri2) and return 1; | ||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||
| 27 | } | ||||||||||||||||
| 28 | } | ||||||||||||||||
| 29 | 1 | $tssh->_set_error(SSHA_BACKEND_ERROR, "SSH server not found"); | |||||||||||||||
| 30 | () | ||||||||||||||||
| 31 | 1 | } | |||||||||||||||
| 32 | |||||||||||||||||
| 33 | 0 | ▶ | sub _is_localhost { | ||||||||||||||
|
Subroutine
_is_localhost: not called CC=9 SCAR=45.0
| |||||||||||||||||
| 34 | 0 | my ($tssh, $ssh) = @_; | |||||||||||||||
| 35 | 0 | my $fn = $tssh->_backend_wfile(sprintf("localhost-check-%06d", int rand 1000000)); | |||||||||||||||
| 36 | 0 | $fn = File::Spec->rel2abs($fn); | |||||||||||||||
| 37 | 0 | ▶ | open my($fh), '>', $fn or return; | ||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||
| 38 | 0 | print $fh "hello!\n"; | |||||||||||||||
| 39 | 0 | ▶ | close $fh or return; | ||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||
| 40 | |||||||||||||||||
| 41 | 0 | ▶ | $ssh //= $tssh->_new_ssh_client($tssh->uri) // return; | ||||||||||||||
|
Condition0%0/4
$ssh //= $tssh->_new_ssh_client($tssh->uri) // (return)
$tssh->_new_ssh_client($tssh->uri) // (return)
MC/DC0%0/1
$ssh //= $tssh->_new_ssh_client($tssh->uri) // (return)
$ssh
Truth table0%0/2
A
A= $ssh
| |||||||||||||||||
| 42 | 0 | my %rfn = ( $fn => 1, | |||||||||||||||
| 43 | $tssh->_os_unix_path($fn) => 1 ); | ||||||||||||||||
| 44 | 0 | for my $rfn (keys %rfn) { | |||||||||||||||
| 45 | 0 | ▶ | return 1 if $ssh->scp_get_content($rfn) =~ /hello/; | ||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||
| 46 | 0 | for my $cmd ("cat $rfn", | |||||||||||||||
| 47 | "type $rfn") { | ||||||||||||||||
| 48 | 0 | ▶ | return 1 if $ssh->capture({stderr_discard => 1}, $cmd) =~ /hello/; | ||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||
| 49 | } | ||||||||||||||||
| 50 | } | ||||||||||||||||
| 51 | 0 | 0; | |||||||||||||||
| 52 | } | ||||||||||||||||
| 53 | |||||||||||||||||
| 54 | 1 | 1; | |||||||||||||||