t/Asnmtap/Plugins/WebTransact.t

filter: Statementstmt 68.1% 79 / 116 Branchbran 30.0% 6 / 20 Conditioncond 13.3% 4 / 30 MC/DCmcdc 0.0% 0 / 16 Subroutinesub 86.6% 13 / 15 Podpod n/a totaltotal 51.7% 102 / 197 CC 6 SCAR 25.9
CC
6
Cov
54%
customWebTransact
42.0
BEGIN
1.1
__ANON__
1.1
CRAP 13.3
« blib/lib/ASNMTAP/Asnmtap/Plugins/XML.pm ↑ Summary plugins/templates/check_template-WebTransact.pl »
1 1 ▶use Test::More tests => 18;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 1 ▶BEGIN { require_ok ( 'ASNMTAP::Asnmtap::Plugins::WebTransact' ) };
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶BEGIN { use_ok ( 'ASNMTAP::Asnmtap::Plugins::WebTransact' ) };
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use ASNMTAP::Asnmtap::Plugins v3.002.003;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use ASNMTAP::Asnmtap::Plugins qw(:PLUGINS);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 my $objectPlugins = ASNMTAP::Asnmtap::Plugins->new (
11 _programName => 'WebTransact.t',
12 _programDescription => 'Testing ASNMTAP::Asnmtap::Plugins::WebTransact',
13 _programVersion => '3.002.003',
14 _programGetOptions => ['environment|e:s', 'proxy:s', 'timeout|t:i', 'trendline|T:i'],
15 _timeout => 30,
16 _debug => 0);
17  
18 1 isa_ok( $objectPlugins, 'ASNMTAP::Asnmtap::Plugins' );
19 1 can_ok( $objectPlugins, qw(programName programDescription programVersion getOptionsArgv getOptionsValue debug dumpData printRevision printRevision printUsage printHelp) );
20 1 can_ok( $objectPlugins, qw(appendPerformanceData browseragent SSLversion clientCertificate pluginValue pluginValues proxy timeout setEndTime_and_getResponsTime write_debugfile call_system exit) );
21
22 1 ▶use ASNMTAP::Asnmtap::Plugins::WebTransact;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 1 my @URLS = ();
25 1 my $objectWebTransact = ASNMTAP::Asnmtap::Plugins::WebTransact->new ( \$objectPlugins, \@URLS );
26  
27 1 isa_ok( $objectWebTransact, 'ASNMTAP::Asnmtap::Plugins::WebTransact' );
28 1 can_ok( $objectWebTransact, qw(matches get_matches set_matches returns get_returns set_returns urls get_urls set_urls) );
29  
30  
31 1 $objectWebTransact->set_returns( { ape => 'lucky' } );
32 1 %returns = %{ $objectWebTransact->returns() };
33 1 ▶$returnCode = ( exists $returns{ape} and $returns{ape} eq 'lucky' ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
exists $returns{'ape'} && $returns{'ape'} eq 'lucky' ? : 1 0 1
Condition33%1/3
exists $returns{"ape"} and $returns{"ape"} eq "lucky"
!ll&&!rl&&r
001
MC/DC0%0/2
exists $returns{"ape"} and $returns{"ape"} eq "lucky"
exists $returns{"ape"} $returns{"ape"} eq "lucky"
Truth table33%1/3
A and B
A= exists $returns{"ape"}B= $returns{"ape"} eq "lucky"
ABresult
0X0
100
111
34 1 ok ($returnCode, 'ASNMTAP::Asnmtap::Plugins::WebTransact::set_returns():');
35  
36 1 %returns = %{ $objectWebTransact->get_returns() };
37 1 ▶$returnCode = ( exists $returns{ape} and $returns{ape} eq 'lucky' ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
exists $returns{'ape'} && $returns{'ape'} eq 'lucky' ? : 1 0 1
Condition33%1/3
exists $returns{"ape"} and $returns{"ape"} eq "lucky"
!ll&&!rl&&r
001
MC/DC0%0/2
exists $returns{"ape"} and $returns{"ape"} eq "lucky"
exists $returns{"ape"} $returns{"ape"} eq "lucky"
Truth table33%1/3
A and B
A= exists $returns{"ape"}B= $returns{"ape"} eq "lucky"
ABresult
0X0
100
111
38 1 ok ($returnCode, 'ASNMTAP::Asnmtap::Plugins::WebTransact::get_returns():');
39  
40  
41 1 $objectWebTransact->set_matches( ['AZERTY', 'QWERTY'] );
42 1 my $matches = $objectWebTransact->matches();
43 1 ▶my $returnCode = ( @$matches[0] eq 'AZERTY' and @$matches[1] eq 'QWERTY' ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
@$matches[0] eq 'AZERTY' && @$matches[1] eq 'QWERTY' ? : 1 0 1
Condition33%1/3
@$matches[0] eq "AZERTY" and @$matches[1] eq "QWERTY"
!ll&&!rl&&r
001
MC/DC0%0/2
@$matches[0] eq "AZERTY" and @$matches[1] eq "QWERTY"
@$matches[0] eq "AZERTY" @$matches[1] eq "QWERTY"
Truth table33%1/3
A and B
A= @$matches[0] eq "AZERTY"B= @$matches[1] eq "QWERTY"
ABresult
0X0
100
111
44 1 ok ($returnCode, 'ASNMTAP::Asnmtap::Plugins::WebTransact::set_matches():');
45
46 1 $returnCode = 0;
47 1 foreach my $match ( @{ $objectWebTransact->matches() } ) { $returnCode = 1; last; }
48 1 ok ($returnCode, 'ASNMTAP::Asnmtap::Plugins::WebTransact::get_matches():');
49  
50  
51 1 @URLS = (
52 { Method => 'GET', Url => 'http://www.citap.be/', Qs_var => [], Qs_fixed => [], Exp => "Consulting Internet Technology Alex Peeters", Exp_Fault => ">>>NIHIL<<<", Msg => "Consulting Internet Technology Alex Peeters", Msg_Fault => "Consulting Internet Technology Alex Peeters", Perfdata_Label => 'Label 1' },
53 );
54  
55 1 $objectWebTransact->set_urls( \@URLS );
56 1 $returnCode = $objectWebTransact->check ( { } );
57 1 ok ($returnCode != 4, 'ASNMTAP::Asnmtap::Plugins::WebTransact::set_urls():');
58  
59 1 $returnCode = 0;
60 1 foreach ( @{ $objectWebTransact->get_urls() } ) { $returnCode = 1; last; };
61 1 ok ($returnCode, 'ASNMTAP::Asnmtap::Plugins::WebTransact::urls():');
62  
63  
64 SKIP: {
65 1 ▶ my $ASNMTAP_PROXY = ( exists $ENV{ASNMTAP_PROXY} ) ? $ENV{ASNMTAP_PROXY} : undef;
Branch: 1 branch
BranchTrueFalseTotal
exists $ENV{'ASNMTAP_PROXY'} ? : 0 1 1
66 1 ▶ skip 'Missing ASNMTAP_PROXY', 5 if ( defined $ASNMTAP_PROXY and ( $ASNMTAP_PROXY eq '0.0.0.0' or $ASNMTAP_PROXY eq '' ) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $ASNMTAP_PROXY and $ASNMTAP_PROXY eq "0.0.0.0" || $ASNMTAP_PROXY eq "" 0 1 1
Condition16%1/6
defined $ASNMTAP_PROXY and $ASNMTAP_PROXY eq "0.0.0.0" || $ASNMTAP_PROXY eq ""
!ll&&!rl&&r
100
$ASNMTAP_PROXY eq "0.0.0.0" or $ASNMTAP_PROXY eq ""
l!l&&r!l&&!r
000
MC/DC0%0/3
defined $ASNMTAP_PROXY and $ASNMTAP_PROXY eq "0.0.0.0" || $ASNMTAP_PROXY eq ""
defined $ASNMTAP_PROXY $ASNMTAP_PROXY eq "0.0.0.0" $ASNMTAP_PROXY eq ""
Truth table25%1/4
A and B or C
A= defined $ASNMTAP_PROXYB= $ASNMTAP_PROXY eq "0.0.0.0"C= $ASNMTAP_PROXY eq ""
ABCresult
0XX0
1000
11X1
1011
67  
68 1 $returnCode = $objectWebTransact->check ( { } );
69 1 ok ($returnCode == 0, 'ASNMTAP::Asnmtap::Plugins::WebTransact::check():');
70  
71  
72 1 ▶ skip 'reason: ASNMTAP::Asnmtap::Plugins::WebTransact::check() failed', 4 if ( $returnCode );
Branch: 1 branch
BranchTrueFalseTotal
if $returnCode 1 0 1
73  
74 1 ▶ use constant EXP_TITLE_1 => "\Q<TITLE>\E(Consulting Internet Technology Alex Peeters)\Q</TITLE>\E";
Subroutine BEGIN: called CC=1 SCAR=0.0
75 1 ▶ use constant EXP_TITLE_2 => "\Q<TITLE>\E(Consulting) (Internet) (Technology) (Alex Peeters)\Q</TITLE>\E";
Subroutine BEGIN: called CC=1 SCAR=0.0
76  
77 1 ▶ use constant EXP_SUBMAIN => "\Q<FRAME NAME=\"NO_INFO\" SRC=\"\E(submain.htm)\Q\" SCROLLING=\"No\" FRAMEBORDER=\"0\" NORESIZE>\E";
Subroutine BEGIN: called CC=1 SCAR=0.0
78 0 ▶ use constant VAL_SUBMAIN => [0, sub { my %pages = ( 'index.htm' => 'InDeX', 'submain.htm' => 'subMAIN' ); $pages { $_[0] }; } ];
Subroutine BEGIN: called CC=1 SCAR=0.6
Subroutine __ANON__: not called CC=1 SCAR=0.6
79  
80 0 @URLS = (
81 { Method => 'GET', Url => 'http://www.citap.com/', Qs_var => [], Qs_fixed => [], Exp => [EXP_SUBMAIN, 'Consulting Internet Technology Alex Peeters'], Exp_Fault => ">>>NIHIL<<<", Msg => "Consulting Internet Technology Alex Peeters", Msg_Fault => "Consulting Internet Technology Alex Peeters", Perfdata_Label => 'Label 2' },
82 { Method => 'GET', Url => 'http://www.citap.com/', Qs_var => [parameter => 0], Qs_fixed => [], Exp => [EXP_SUBMAIN, 'Consulting Internet Technology Alex Peeters'], Exp_Fault => ">>>NIHIL<<<", Exp_Return => { title1 => EXP_TITLE_1 }, Msg => "Consulting Internet Technology Alex Peeters", Msg_Fault => "Consulting Internet Technology Alex Peeters", Perfdata_Label => 'Label 2' },
83 { Method => 'GET', Url => 'http://www.citap.com/', Qs_var => [parameter => VAL_SUBMAIN], Qs_fixed => [], Exp => 'Consulting Internet Technology Alex Peeters', Exp_Fault => ">>>NIHIL<<<", Exp_Return => { title2 => EXP_TITLE_2, submain => EXP_SUBMAIN }, Msg => "Consulting Internet Technology Alex Peeters", Msg_Fault => "Consulting Internet Technology Alex Peeters", Perfdata_Label => 'Label 3' },
84 );
85  
86 0 $returnCode = $objectWebTransact->check ( { }, custom => \&customWebTransact );
87 0 ok ($returnCode == 0, 'ASNMTAP::Asnmtap::Plugins::WebTransact::check():');
88  
89  
90 0 $returnCode = 0;
91 0 my @matches = @{ $objectWebTransact->matches() };
92 0 foreach my $match ( @{ $objectWebTransact->matches() } ) { $returnCode = 1; last; }
93 0 ok ($returnCode, 'ASNMTAP::Asnmtap::Plugins::WebTransact::matches():');
94  
95  
96 0 my %returns = %{ $objectWebTransact->returns() };
97 0 ▶ $returnCode = ( exists $returns {title1} ) and ( exists $returns {submain} ) and ( exists $returns {title2}[0] ) and ( exists $returns {title2}[1] ) and ( exists $returns {title2}[2] ) and ( exists $returns {title2}[3] );
Branch: 1 branch
BranchTrueFalseTotal
$returnCode = exists $returns{"title1"} and exists $returns{"submain"} and exists $returns{"title2"}[0] and exists $returns{"title2"}[1] and exists $returns{"title2"}[2] and exists $returns{"title2"}[3] 0 0 0
Condition0%0/12
$returnCode = exists $returns{"title1"} and exists $returns{"submain"} and exists $returns{"title2"}[0] and exists $returns{"title2"}[1] and exists $returns{"title2"}[2]
!ll&&!rl&&r
000
$returnCode = exists $returns{"title1"} and exists $returns{"submain"} and exists $returns{"title2"}[0] and exists $returns{"title2"}[1]
!ll&&!rl&&r
000
$returnCode = exists $returns{"title1"} and exists $returns{"submain"} and exists $returns{"title2"}[0]
!ll&&!rl&&r
000
$returnCode = exists $returns{"title1"} and exists $returns{"submain"}
!ll&&!rl&&r
000
MC/DC0%0/5
$returnCode = exists $returns{"title1"} and exists $returns{"submain"} and exists $returns{"title2"}[0] and exists $returns{"title2"}[1] and exists $returns{"title2"}[2]
$returnCode = exists $returns{"title1"} exists $returns{"submain"} exists $returns{"title2"}[0] exists $returns{"title2"}[1] exists $returns{"title2"}[2]
Truth table0%0/6
A and B and C and D and E
A= $returnCode = exists $returns{"title1"}B= exists $returns{"submain"}C= exists $returns{"title2"}[0]D= exists $returns{"title2"}[1]E= exists $returns{"title2"}[2]
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
98 0 ok ($returnCode, 'ASNMTAP::Asnmtap::Plugins::WebTransact::returns():');
99  
100  
101 0 $returnCode = 0;
102 0 foreach ( @{ $objectWebTransact->get_urls() } ) { $returnCode = 1; last; };
103 0 ok ($returnCode, 'ASNMTAP::Asnmtap::Plugins::WebTransact::get_urls():');
104  
105  
106 1 ▶ no warnings 'deprecated';
Subroutine BEGIN: called CC=1 SCAR=0.0
107 0 $objectPlugins->{_pluginValues}->{stateValue} = $ERRORS{OK};
108 0 $objectPlugins->{_pluginValues}->{stateError} = $STATE{$ERRORS{OK}};
109 0 $objectPlugins->exit (0);
110  
111  
112 0 ▶ sub customWebTransact {
Subroutine customWebTransact: not called CC=6 SCAR=37.4
113 0 for ( $_[0] ) {
114 /Failure of server APACHE bridge/ &&
115 0 ▶ do { return ( $ERRORS{CRITICAL}, 1, 'Failure of server APACHE bridge' ); last; };
Branch: 1 branch
BranchTrueFalseTotal
/Failure of server APACHE bridge/ and do { return $ERRORS{"CRITICAL"}, 1, "Failure of server APACHE bridge"; last } 0 0 0
116 /Message from the NSAPI plugin:/ && /No backend server available for connection:/ &&
117 0 ▶ do { return ( $ERRORS{CRITICAL}, 1, "'KBOWI - Message from the NSAPI plugin - No backend server available for connection'" ); last; };
Branch: 1 branch
BranchTrueFalseTotal
/Message from the NSAPI plugin:/ and /No backend server available for connection:/ and do { return $ERRORS{"CRITICAL"}, 1, "'KBOWI - Message from the NSAPI plugin - No backend server available for connection'"; last } 0 0 0
Condition0%0/3
/Message from the NSAPI plugin:/ and /No backend server available for connection:/
!ll&&!rl&&r
000
MC/DC0%0/2
/Message from the NSAPI plugin:/ and /No backend server available for connection:/
/Message from the NSAPI plugin:/ /No backend server available for connection:/
Truth table0%0/3
A and B
A= /Message from the NSAPI plugin:/B= /No backend server available for connection:/
ABresult
0X0
100
111
118 /\Q<FRAME NAME="NO_INFO" SRC="submain.html" SCROLLING="No" FRAMEBORDER="0" NORESIZE>\E/ &&
119 0 ▶ do { return ( $ERRORS{CRITICAL}, 0, '+submain+' ); last; };
Branch: 1 branch
BranchTrueFalseTotal
/\<FRAME\ NAME\=\"NO_INFO\"\ SRC\=\"submain\.html\"\ SCROLLING\=\"No\"\ FRAMEBORDER\=\"0\"\ NORESIZE\>/ and do { return $ERRORS{"CRITICAL"}, 0, "+submain+"; last } 0 0 0
120 0 return ( $ERRORS{OK}, 0, undef );
121 }
122 }
123 }
124 1  
« blib/lib/ASNMTAP/Asnmtap/Plugins/XML.pm ↑ Summary plugins/templates/check_template-WebTransact.pl »