BCSSH/Client.pm

filter: Statementstmt 36.1% 13 / 36 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 14 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 33.3% 3 / 9 Podpod 0.0% 0 / 3 totaltotal 20.0% 16 / 80 CC 11 SCAR 37.9
CC
11
Cov
22%
command
90.0
BUILD
6.0
handler
6.0
CRAP 44.3
« BCSSH/Proxy.pm ↑ Summary BCSSH/Handler/scp.pm »
1 package App::BCSSH::Client;
2 1 ▶use App::BCSSH::Message qw(send_message BCSSH_SUCCESS BCSSH_FAILURE BCSSH_COMMAND);
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use JSON qw(encode_json decode_json);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 0 ▶has 'agent' => ( is => 'ro', default => sub { $ENV{SSH_AUTH_SOCK} } );
Subroutine __ANON__: not called CC=1 SCAR=1.2
7 0 ▶has 'auth_key' => ( is => 'ro', default => sub { $ENV{LC_BCSSH_KEY} } );
Subroutine __ANON__: not called CC=1 SCAR=1.2
8 1 has 'agent_socket' => ( is => 'lazy' );
9  
10 0 ▶sub BUILD {
Subroutine BUILD: not called CC=2 SCAR=17.9
Pod undocumented
11 0 ▶ if (! $ENV{SSH_CONNECTION}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $ENV{"SSH_CONNECTION"}) 0 0 0
12 0 die "No SSH connection!\n";
13 }
14 }
15  
16 0 ▶sub _build_agent_socket {
Subroutine _build_agent_socket: not called CC=1 SCAR=6.9
17 0 my $self = shift;
18 0 require IO::Socket::UNIX;
19 0 IO::Socket::UNIX->new(
20 Peer => $self->agent,
21 );
22 };
23  
24 0 ▶sub handler {
Subroutine handler: not called CC=2 SCAR=17.9
Pod undocumented
25 0 my $self = shift;
26 0 ▶ my $class = ref $self || $self;
Condition0%0/3
ref $self || $self
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table0%0/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
27 0 $class =~ s/.*:://;
28 0 return $class;
29 }
30  
31 0 ▶sub command {
Subroutine command: not called CC=9 SCAR=45.0
Pod undocumented
32 0 my ($self, @args) = @_;
33 0 ▶ my $key = $self->auth_key || '';
Condition0%0/2
$self->auth_key || ''
l!l
00
MC/DC0%0/1
$self->auth_key || ''
$self->auth_key
Truth table0%0/2
A
A= $self->auth_key
Aresult
11
00
34 0 my $message = join '|', $self->handler, $key, encode_json(\@args);
35 0 my ($rtype, $rmessage) = send_message($self->agent_socket, BCSSH_COMMAND, $message);
36 0 ▶ if (defined $rtype && $rtype == BCSSH_FAILURE && $rmessage) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $rtype and $rtype == -42 and $rmessage) 0 0 0
Condition0%0/6
defined $rtype and $rtype == -42 and $rmessage
!ll&&!rl&&r
000
defined $rtype and $rtype == -42
!ll&&!rl&&r
000
MC/DC0%0/3
defined $rtype and $rtype == -42 and $rmessage
defined $rtype $rtype == -42 $rmessage
Truth table0%0/4
A and B and C
A= defined $rtypeB= $rtype == -42C= $rmessage
ABCresult
0XX0
10X0
1100
1111
37 0 die $rmessage;
38 }
39 0 ▶ if ($rtype != BCSSH_SUCCESS) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rtype != -41) 0 0 0
40 0 die "Error!";
41 }
42 0 ▶ unless (defined $rmessage && length $rmessage) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $rmessage and length $rmessage) 0 0 0
Condition0%0/3
defined $rmessage and length $rmessage
!ll&&!rl&&r
000
MC/DC0%0/2
defined $rmessage and length $rmessage
defined $rmessage length $rmessage
Truth table0%0/3
A and B
A= defined $rmessageB= length $rmessage
ABresult
0X0
100
111
43 0 return;
44 }
45 0 my $response = decode_json($rmessage);
46 0 ▶ return wantarray ? @$response : 1;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
47 }
48  
49 1 1;
50 __END__
« BCSSH/Proxy.pm ↑ Summary BCSSH/Handler/scp.pm »