lib/Rex/Interface/Connection/Base.pm

filter: Statementstmt 36.3% 24 / 66 Branchbran 12.5% 1 / 8 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 30.7% 8 / 26 Podpod 0.0% 0 / 22 totaltotal 26.7% 34 / 127 CC 6 SCAR 9.5
CC
6
Cov
34%
get_auth_user
6.0
get_auth
6.0
push_sudo_options
6.0
CRAP 2.6
« lib/Rex/Hook.pm ↑ Summary lib/Rex/Test/Base/has_file_content.pm »
1 #
2 # (c) Jan Gehring <jan.gehring@gmail.com>
3 #
4  
5 package Rex::Interface::Connection::Base;
6  
7 69 ▶use v5.14.4;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 69 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 69 our $VERSION = '1.16.1'; # VERSION
11  
12 69 ▶use Rex::Interface::Fs;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 69 ▶use Rex::Interface::Exec;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 108 ▶sub new {
Subroutine new: called CC=2 SCAR=7.1
Pod undocumented
16 108 my $that = shift;
17 108 ▶ my $proto = ref($that) || $that;
Condition33%1/3
ref $that || $that
l!l&&r!l&&!r
01080
MC/DC0%0/2
ref $that || $that
ref $that $that
Truth table33%1/3
A || B
A= ref $thatB= $that
ABresult
1X1
011
000
18 108 my $self = {@_};
19  
20 108 bless( $self, $proto );
21  
22 108 $self->{__sudo_options__} = [];
23  
24 108 return $self;
25 }
26  
27 0 ▶sub error { die("Must be implemented by Interface Class"); }
Subroutine error: not called CC=1 SCAR=6.9
Pod undocumented
28 0 ▶sub connect { die("Must be implemented by Interface Class"); }
Subroutine connect: not called CC=1 SCAR=6.9
Pod undocumented
29 0 ▶sub disconnect { die("Must be implemented by Interface Class"); }
Subroutine disconnect: not called CC=1 SCAR=6.9
Pod undocumented
30 0 ▶sub get_connection_object { die("Must be implemented by Interface Class"); }
Subroutine get_connection_object: not called CC=1 SCAR=6.9
Pod undocumented
31 0 ▶sub is_connected { die("Must be implemented by Interface Class"); }
Subroutine is_connected: not called CC=1 SCAR=6.9
Pod undocumented
32 0 ▶sub is_authenticated { die("Must be implemented by Interface Class"); }
Subroutine is_authenticated: not called CC=1 SCAR=6.9
Pod undocumented
33 0 ▶sub get_connection_type { die("Must be implemented by Interface Class") }
Subroutine get_connection_type: not called CC=1 SCAR=6.9
Pod undocumented
34 2 ▶sub reconnect { }
Subroutine reconnect: called CC=1 SCAR=0.0
Pod undocumented
35  
36 0 ▶sub get_fs_connection_object {
Subroutine get_fs_connection_object: not called CC=1 SCAR=6.9
Pod undocumented
37 0 my ($self) = @_;
38 0 return $self;
39 }
40  
41 0 ▶sub get_fs {
Subroutine get_fs: not called CC=1 SCAR=6.9
Pod undocumented
42 0 my $fs = Rex::Interface::Fs->create;
43 0 return $fs;
44 }
45  
46 0 ▶sub get_exec {
Subroutine get_exec: not called CC=1 SCAR=6.9
Pod undocumented
47 0 my $exec = Rex::Interface::Exec->create;
48 0 return $exec;
49 }
50  
51 414 ▶sub server {
Subroutine server: called CC=1 SCAR=0.0
Pod undocumented
52 414 my ($self) = @_;
53 414 return $self->{server};
54 }
55  
56 0 ▶sub get_auth_user {
Subroutine get_auth_user: not called CC=2 SCAR=17.9
Pod undocumented
57 0 my ($self) = @_;
58  
59 0 ▶ if ( exists $self->{__auth_info__} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"__auth_info__"}) 0 0 0
60 0 return $self->{__auth_info__}->{user};
61 }
62  
63 0 return "";
64 }
65  
66 0 ▶sub get_auth {
Subroutine get_auth: not called CC=2 SCAR=17.9
Pod undocumented
67 0 my ($self) = @_;
68  
69 0 ▶ if ( exists $self->{__auth_info__} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"__auth_info__"}) 0 0 0
70 0 return $self->{__auth_info__};
71 }
72 }
73  
74 0 ▶sub push_sudo_options {
Subroutine push_sudo_options: not called CC=2 SCAR=17.9
Pod undocumented
75 0 my ( $self, @option ) = @_;
76 0 ▶ if ( ref $option[0] eq "HASH" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $option[0] eq 'HASH') { } 0 0 0
77 0 push @{ $self->{__sudo_options__} }, $option[0];
78 }
79 else {
80 0 push @{ $self->{__sudo_options__} }, {@option};
81 }
82 }
83  
84 0 ▶sub get_current_sudo_options {
Subroutine get_current_sudo_options: not called CC=1 SCAR=6.9
Pod undocumented
85 0 my ($self) = @_;
86 0 return $self->{__sudo_options__}->[-1];
87 }
88  
89 0 ▶sub push_use_sudo {
Subroutine push_use_sudo: not called CC=1 SCAR=6.9
Pod undocumented
90 0 my ( $self, $use ) = @_;
91 0 push @{ $self->{__use_sudo__} }, $use;
92 }
93  
94 3797 ▶sub get_current_use_sudo {
Subroutine get_current_use_sudo: called CC=2 SCAR=7.6
Pod undocumented
95 3797 my ($self) = @_;
96  
97 3797 ▶ if ( $self->{is_sudo} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"is_sudo"}) 0 3797 3797
98 0 return 1;
99 }
100 3797 return $self->{__use_sudo__}->[-1];
101 }
102  
103 0 ▶sub pop_sudo_options {
Subroutine pop_sudo_options: not called CC=1 SCAR=6.9
Pod undocumented
104 0 my ($self) = @_;
105 0 pop @{ $self->{__sudo_options__} };
106 }
107  
108 0 ▶sub pop_use_sudo {
Subroutine pop_use_sudo: not called CC=1 SCAR=6.9
Pod undocumented
109 0 my ($self) = @_;
110 0 pop @{ $self->{__use_sudo__} };
111 }
112  
113 0 ▶sub run_sudo_unmodified {
Subroutine run_sudo_unmodified: not called CC=1 SCAR=6.9
Pod undocumented
114 0 my ( $self, $code ) = @_;
115 0 $self->push_sudo_options( {} );
116 0 $code->();
117 0 $self->pop_sudo_options();
118 }
119  
120 69 1;
« lib/Rex/Hook.pm ↑ Summary lib/Rex/Test/Base/has_file_content.pm »