blib/lib/Lemonldap/NG/Manager/Conf/Parser.pm

filter: Statementstmt 67.3% 481 / 714 Branchbran 56.5% 199 / 352 Conditioncond 62.8% 103 / 164 MC/DCmcdc 44.6% 42 / 94 Subroutinesub 92.8% 26 / 28 Podpod 0.0% 0 / 6 totaltotal 62.6% 851 / 1358 CC 269 SCAR 76.7
CC
269
Cov
64%
_scanNodes
3486.0
_unitTest
33.8
scanTree
24.6
CRAP 2150.2
↑ Summary blib/lib/Lemonldap/NG/Manager/Sessions.pm »
1 package Lemonldap::NG::Manager::Conf::Parser;
2  
3 # This module is called either to parse a new configuration in JSON format (as
4 # posted by the web interface) and test a new configuration object.
5 #
6 # The new object must be built with the following properties:
7 # - refConf: the actual configuration
8 # - req : the Lemonldap::NG::Common::PSGI::Request
9 # - tree : the new configuration in JSON format
10 # or
11 # - newConf: the configuration to test
12 #
13 # The main method is check() which calls:
14 # - scanTree() if configuration is not parsed (JSON string)
15 # - testNewConf()
16 #
17 # It returns a boolean. Errors, warnings and changes are stored as array
18 # containing `{ message => 'Explanation' }. A main message is stored in
19 # `message` property.
20  
21 28 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 28 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 28 ▶use Crypt::URandom;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 28 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 28 ▶use JSON 'to_json';
Subroutine BEGIN: called CC=1 SCAR=0.0
26 28 ▶use Lemonldap::NG::Common::Conf::ReConstants;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 28 ▶use Lemonldap::NG::Manager::Attributes;
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 28 our $VERSION = '2.23.0';
30  
31 28 extends 'Lemonldap::NG::Common::Conf::Compact';
32  
33 # High debugging for developers, set this to 1
34 28 ▶use constant HIGHDEBUG => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
35  
36 # Messages storage
37 has errors => (
38 is => 'rw',
39 isa => 'ArrayRef',
40 50 ▶ default => sub { return [] }
Subroutine __ANON__: called CC=1 SCAR=0.0
41 28 );
42 has warnings => (
43 is => 'rw',
44 isa => 'ArrayRef',
45 50 ▶ default => sub { return [] },
Subroutine __ANON__: called CC=1 SCAR=0.0
46 trigger => sub {
47 0 ▶ hdebug( 'warnings contains', $_[0]->{warnings} );
Subroutine __ANON__: not called CC=1 SCAR=6.9
48 }
49 28 );
50 50 ▶has changes => ( is => 'rw', isa => 'ArrayRef', default => sub { return [] } );
Subroutine __ANON__: called CC=1 SCAR=0.0
51 has message => (
52 is => 'rw',
53 isa => 'Str',
54 lazy => 1,
55 default => sub {
56 0 ▶ return join( ', ', map { $_->{message} } @{ $_[0]->errors } );
Subroutine __ANON__: not called CC=1 SCAR=6.9
57 },
58 trigger => sub {
59 3 ▶ hdebug( "Message becomes " . $_[0]->{message} );
Subroutine __ANON__: called CC=1 SCAR=0.0
60 }
61 28 );
62 has needConfirmation =>
63 50 ▶ ( is => 'rw', isa => 'ArrayRef', default => sub { return [] } );
Subroutine __ANON__: called CC=1 SCAR=0.0
64  
65 # Booleans
66 has confChanged => (
67 is => 'rw',
68 isa => 'Bool',
69 default => 0,
70 trigger => sub {
71 116 ▶ hdebug( "condChanged: " . $_[0]->{confChanged} );
Subroutine __ANON__: called CC=1 SCAR=0.0
72 }
73 28 );
74  
75 # Properties required during build
76 28 has refConf => ( is => 'ro', isa => 'HashRef', required => 1 );
77 28 has req => ( is => 'ro', required => 1 );
78 28 has newConf => ( is => 'rw', isa => 'HashRef' );
79 28 has tree => ( is => 'rw', isa => 'ArrayRef' );
80  
81 # High debug method
82 sub hdebug {
83 35318 ▶ if (HIGHDEBUG) {
Subroutine hdebug: called CC=1 SCAR=0.0
Pod undocumented
84 foreach my $d (@_) {
85 if ( ref $d ) {
86 require Data::Dumper;
87 $Data::Dumper::Useperl = 1;
88 print STDERR Data::Dumper::Dumper($d);
89 }
90 else { print STDERR "$d\n" }
91 }
92 }
93 35318 undef;
94 }
95  
96 ##@method boolean check()
97 # Main method
98 #@return result
99 sub check {
100 17 ▶ my ( $self, $localConf ) = @_;
Subroutine check: called CC=9 SCAR=22.0
Pod undocumented
101  
102 17 hdebug("# check()");
103 17 ▶ unless ( $self->newConf ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->newConf) 16 1 17
104 16 ▶ return 0 unless ( $self->scanTree );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->scanTree 0 16 16
105 }
106 17 ▶ unless ( $self->testNewConf($localConf) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->testNewConf($localConf)) 1 16 17
107 1 hdebug(" testNewConf() failed");
108 1 return 0;
109 }
110 16 ▶ my $separator = $self->newConf->{multiValuesSeparator} || '; ';
Condition100%2/2
$self->newConf->{'multiValuesSeparator'} || '; '
l!l
313
MC/DC100%1/1
$self->newConf->{'multiValuesSeparator'} || '; '
$self->newConf->{'multiValuesSeparator'}
Truth table100%2/2
A
A= $self->newConf->{'multiValuesSeparator'}
Aresult
11
00
111 16 hdebug(" tests succeed");
112 16 my %conf = %{ $self->newConf };
113 16 my %compactedConf = %{ $self->compactConf( $self->newConf ) };
114 16 my @removedKeys = ();
115 16 ▶ unless ( $self->confChanged ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->confChanged) 3 13 16
116 3 hdebug(" no change detected");
117 3 $self->message('__confNotChanged__');
118 3 return 0;
119 }
120  
121 # Return removed keys if conf compacted
122 921 ▶ @removedKeys = map { exists $compactedConf{$_} ? () : $_ } sort keys %conf
Branch: 1 branch
BranchTrueFalseTotal
exists $compactedConf{$_} ? : 722 199 921
123 13 ▶ if ( $self->newConf->{compactConf} );
Branch: 1 branch
BranchTrueFalseTotal
if $self->newConf->{"compactConf"} 6 7 13
124 13 ▶ push @{ $self->changes },
Branch: 1 branch
BranchTrueFalseTotal
$self->{'newConf'}{'compactConf'} ? : 6 7 13
125 (
126 $self->{newConf}->{compactConf}
127 ? {
128 13 confCompacted => '1',
129 removedKeys => join( $separator, @removedKeys )
130 }
131 : { confCompacted => '0' }
132 );
133  
134 13 return 1;
135 }
136  
137 ##@method boolean scanTree()
138 # Methods to build new conf from JSON string
139 #@result true if succeed
140 sub scanTree {
141 16 ▶ my $self = shift;
Subroutine scanTree: called CC=13 SCAR=32.0
Pod undocumented
142 16 hdebug("# scanTree()");
143 16 $self->newConf( {} );
144 16 ▶ $self->_scanNodes( $self->tree ) or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->_scanNodes($self->tree) or return 0 0 16 16
145  
146 # Set cfgNum to ref cfgNum (will be changed when saving), set other
147 # metadata and set a value to the key if empty
148 16 $self->newConf->{cfgNum} = $self->req->params('cfgNum');
149 16 my $envUser;
150 16 foreach (qw(REMOTE_USER SUDO_USER USER)) {
151 48 ▶ ( $envUser = $self->req->env->{$_} || $ENV{$_} ) and last;
Branch: 1 branch
BranchTrueFalseTotal
$envUser = $self->req->env->{$_} || $ENV{$_} and last 0 48 48
Condition33%1/3
$self->req->env->{$_} || $ENV{$_}
l!l&&r!l&&!r
0048
MC/DC0%0/2
$self->req->env->{$_} || $ENV{$_}
$self->req->env->{$_} $ENV{$_}
Truth table33%1/3
A || B
A= $self->req->env->{$_}B= $ENV{$_}
ABresult
1X1
011
000
152 }
153 16 ▶ $envUser = '' unless $envUser =~ /\w/;
Branch: 1 branch
BranchTrueFalseTotal
unless $envUser =~ /\w/ 16 0 16
154 $self->newConf->{cfgAuthor} =
155 $self->req->userData->{ Lemonldap::NG::Handler::Main->tsv->{whatToTrace}
156 16 ▶ || '_whatToTrace' }
Condition42%3/7
$self->req->userData->{'Lemonldap::NG::Handler::Main'->tsv->{'whatToTrace'} or '_whatToTrace'} || $envUser || 'anonymous'
l!l
016
$self->req->userData->{"Lemonldap::NG::Handler::Main"->tsv->{"whatToTrace"} or "_whatToTrace"} or $envUser
l!l&&r!l&&!r
0016
'Lemonldap::NG::Handler::Main'->tsv->{'whatToTrace'} || '_whatToTrace'
l!l
160
MC/DC0%0/2
$self->req->userData->{'Lemonldap::NG::Handler::Main'->tsv->{'whatToTrace'} or '_whatToTrace'} || $envUser || 'anonymous'
$self->req->userData->{"Lemonldap::NG::Handler::Main"->tsv->{"whatToTrace"} or "_whatToTrace"} $envUser
MC/DC0%0/1
'Lemonldap::NG::Handler::Main'->tsv->{'whatToTrace'} || '_whatToTrace'
'Lemonldap::NG::Handler::Main'->tsv->{'whatToTrace'}
Truth table33%1/3
A or B
A= $self->req->userData->{"Lemonldap::NG::Handler::Main"->tsv->{"whatToTrace"} or "_whatToTrace"}B= $envUser
ABresult
1X1
011
000
Truth table50%1/2
A
A= 'Lemonldap::NG::Handler::Main'->tsv->{'whatToTrace'}
Aresult
11
00
157 || $envUser
158 || "anonymous";
159 16 $self->newConf->{cfgAuthorIP} = $self->req->address;
160 $self->newConf->{cfgAuthorIP} .=
161 ' (maybe '
162 . ( $self->req->env->{'X-Real-IP'}
163 || $self->req->env->{HTTP_X_FORWARDED_FOR} )
164 . ')'
165 if $self->req->env->{'X-Real-IP'}
166 16 ▶ or $self->req->env->{HTTP_X_FORWARDED_FOR};
Branch: 1 branch
BranchTrueFalseTotal
if $self->req->env->{"X-Real-IP"} or $self->req->env->{"HTTP_X_FORWARDED_FOR"} 0 16 16
Condition16%1/6
$self->req->env->{"X-Real-IP"} or $self->req->env->{"HTTP_X_FORWARDED_FOR"}
l!l&&r!l&&!r
0016
$self->req->env->{'X-Real-IP'} || $self->req->env->{'HTTP_X_FORWARDED_FOR'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->req->env->{"X-Real-IP"} or $self->req->env->{"HTTP_X_FORWARDED_FOR"}
$self->req->env->{"X-Real-IP"} $self->req->env->{"HTTP_X_FORWARDED_FOR"}
MC/DC0%0/2
$self->req->env->{'X-Real-IP'} || $self->req->env->{'HTTP_X_FORWARDED_FOR'}
$self->req->env->{'X-Real-IP'} $self->req->env->{'HTTP_X_FORWARDED_FOR'}
Truth table33%1/3
A or B
A= $self->req->env->{"X-Real-IP"}B= $self->req->env->{"HTTP_X_FORWARDED_FOR"}
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $self->req->env->{'X-Real-IP'}B= $self->req->env->{'HTTP_X_FORWARDED_FOR'}
ABresult
1X1
011
000
167 16 $self->newConf->{cfgDate} = time;
168 16 $self->newConf->{cfgVersion} = $Lemonldap::NG::Manager::VERSION;
169 $self->newConf->{key} ||= join( '',
170 16 ▶ map { chr( int( ord( Crypt::URandom::urandom(1) ) * 94 / 256 ) + 33 ) }
Condition33%1/3
$self->newConf->{"key"} ||= join("", map({chr int(ord(Crypt::URandom::urandom(1)) * 94 / 256) + 33;} 1..16))
l!l&&r!l&&!r
1600
MC/DC0%0/2
$self->newConf->{"key"} ||= join("", map({chr int(ord(Crypt::URandom::urandom(1)) * 94 / 256) + 33;} 1..16))
$self->newConf->{"key"} join("", map({chr int(ord(Crypt::URandom::urandom(1)) * 94 / 256) + 33;} 1..16))
Truth table33%1/3
A ||= B
A= $self->newConf->{"key"}B= join("", map({chr int(ord(Crypt::URandom::urandom(1)) * 94 / 256) + 33;} 1..16))
ABresult
1X1
011
000
171 ( 1 .. 16 ) );
172  
173 16 return 1;
174 }
175  
176 28 ▶use feature 'state';
Subroutine BEGIN: called CC=1 SCAR=0.0
177  
178 ##@method private boolean _scanNodes()
179 # Recursive JSON parser
180 #@result true if succeed
181 sub _scanNodes {
182 1541 ▶ my ( $self, $tree, ) = @_;
Subroutine _scanNodes: called CC=182 SCAR=81.6
183 1541 hdebug("# _scanNodes()");
184 1541 state ( $knownCat, %newNames );
185 1541 ▶ unless ( ref($tree) eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $tree eq "ARRAY") 0 1541 1541
186 0 print STDERR 'Fatal: node is not an array';
187 0 push @{ $self->errors }, { message => 'Fatal: node is not an array' };
188 0 return 0;
189 }
190 1541 ▶ unless (@$tree) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@$tree) 37 1504 1541
191 37 hdebug(' empty tree !?');
192 }
193 1541 foreach my $leaf (@$tree) {
194 6000 my $name = $leaf->{title};
195 6000 hdebug("Looking to $name");
196  
197 # subnode
198 6000 ▶ my $subNodes = $leaf->{nodes} // $leaf->{_nodes};
Condition100%3/3
$leaf->{"nodes"} // $leaf->{"_nodes"}
l!l&&r!l&&!r
56910204411
MC/DC100%2/2
$leaf->{"nodes"} // $leaf->{"_nodes"}
$leaf->{"nodes"} $leaf->{"_nodes"}
Truth table100%3/3
A // B
A= $leaf->{"nodes"}B= $leaf->{"_nodes"}
ABresult
1X1
011
000
199 6000 ▶ my $subNodesCond = $leaf->{nodes_cond} // $leaf->{_nodes_cond};
Condition100%3/3
$leaf->{"nodes_cond"} // $leaf->{"_nodes_cond"}
l!l&&r!l&&!r
885984
MC/DC100%2/2
$leaf->{"nodes_cond"} // $leaf->{"_nodes_cond"}
$leaf->{"nodes_cond"} $leaf->{"_nodes_cond"}
Truth table100%3/3
A // B
A= $leaf->{"nodes_cond"}B= $leaf->{"_nodes_cond"}
ABresult
1X1
011
000
200  
201 ##################################
202 # VirtualHosts and SAML partners #
203 ##################################
204  
205 # Root nodes
206 6000 ▶ if ( $leaf->{id} =~ /^($specialNodeKeys)$/i ) {
Branch: 9 branches
BranchTrueFalseTotal
if ($leaf->{'id'} =~ /^($Lemonldap::NG::Manager::Conf::Parser::specialNodeKeys)$/i) { } 59 5941 6000
elsif ($leaf->{'id'} =~ m[^($Lemonldap::NG::Manager::Conf::Parser::specialNodeKeys)/([^/]+)$]i) { } 26 5915 5941
elsif ($leaf->{'id'} =~ m[^($Lemonldap::NG::Manager::Conf::Parser::specialNodeKeys)/([^/]+)/([^/]+)(?:/(.*))?$]i) { } 209 5706 5915
elsif ($leaf->{'title'} eq 'applicationList') { } 16 5690 5706
elsif ($leaf->{'id'} =~ m[^applicationList/(.+)$]) { } 60 5630 5690
elsif ($leaf->{'id'} eq 'grantSessionRules') { } 16 5614 5630
elsif ($name eq 'openIdIDPList') { } 16 5598 5614
elsif ($leaf->{'title'} =~ /^$Lemonldap::NG::Manager::Conf::Parser::simpleHashKeys$/ and not $leaf->{'title'} eq 'applicationList') { } 366 5232 5598
elsif ($leaf->{'title'} =~ /^$Lemonldap::NG::Manager::Conf::Parser::doubleHashKeys$/) { } 2 5230 5232
207 59 hdebug("Root special node detected $leaf->{id}");
208  
209 # If node has not been opened
210 59 ▶ if ( $leaf->{cnodes} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($leaf->{"cnodes"}) 36 23 59
211 36 hdebug(" not opened");
212 36 foreach my $k ( @{ $specialNodeHash->{ $leaf->{id} } } ) {
213 133 hdebug(" copying $k");
214 133 $self->newConf->{$k} = $self->refConf->{$k};
215 }
216 36 next;
217 }
218 23 $self->_scanNodes($subNodes);
219  
220 # Check deleted keys
221 23 my $field = $specialNodeHash->{ $leaf->{id} }->[0];
222 23 my @old = keys %{ $self->refConf->{$field} };
223 23 foreach my $k ( keys %{ $self->newConf->{$field} } ) {
224 20 @old = grep { $_ ne $k } @old;
225 }
226 23 ▶ if (@old) {
Branch: 1 branch
BranchTrueFalseTotal
if (@old) 5 18 23
227 5 hdebug( "Keys detected as removed:", \@old );
228 5 $self->confChanged(1);
229 5 foreach my $deletedHost (@old) {
230 5 push @{ $self->changes },
231 5 { key => $leaf->{id}, old => $deletedHost };
232 }
233 }
234 23 next;
235 }
236  
237 # 1st sublevel
238 elsif ( $leaf->{id} =~ /^($specialNodeKeys)\/([^\/]+)$/i ) {
239 26 hdebug("Special node chield detected $leaf->{id}");
240 26 my ( $base, $host ) = ( $1, $2 );
241  
242 # Check hostname/partner name changes (id points to the old name)
243 26 $newNames{$host} = $leaf->{title};
244 26 ▶ if ( $newNames{$host} ne $host and $host !~ /^new__/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($newNames{$host} ne $host and not $host =~ /^new__/) 3 23 26
Condition100%3/3
$newNames{$host} ne $host and not $host =~ /^new__/
!ll&&!rl&&r
1943
MC/DC100%2/2
$newNames{$host} ne $host and not $host =~ /^new__/
$newNames{$host} ne $host not $host =~ /^new__/
Truth table100%3/3
A and not(B)
A= $newNames{$host} ne $hostB= not $host =~ /^new__/
ABresult
0X0
100
111
245 3 hdebug(" $host becomes $newNames{$host}");
246 3 $self->confChanged(1);
247 3 push @{ $self->changes },
248 3 { key => $base, old => $host, new => $newNames{$host} };
249 }
250  
251 26 $self->_scanNodes($subNodes);
252 26 next;
253 }
254  
255 # Other sub levels
256 elsif ( $leaf->{id} =~
257 /^($specialNodeKeys)\/([^\/]+)\/([^\/]+)(?:\/(.*))?$/i )
258 {
259 my ( $base, $key, $oldName, $target, $h ) =
260 209 ( $1, $newNames{$2}, $2, $3, $4 );
261 209 ▶ hdebug(
Branch: 1 branch
BranchTrueFalseTotal
$h ? : 47 162 209
262 "Special node chield subnode detected $leaf->{id}",
263 " base $base, key $key, target $target, h "
264 . ( $h ? $h : 'undef' )
265 );
266  
267 # VirtualHosts
268 209 ▶ if ( $base eq 'virtualHosts' ) {
Branch: 5 branches
BranchTrueFalseTotal
if ($base eq 'virtualHosts') { } 194 15 209
elsif ($base =~ /^saml(?:S|ID)PMetaDataNodes$/) { } 0 15 15
elsif ($base =~ /^oidc(?:O|R)PMetaDataNodes$/) { } 0 15 15
elsif ($base =~ /^cas(?:App|Srv)MetaDataNodes$/) { } 0 15 15
elsif ($base eq 'keyNodes') { } 15 0 15
269 194 hdebug(" virtualhost");
270 194 ▶ if ( $target =~ /^(?:locationRules|exportedHeaders|post)$/ ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($target =~ /^(?:locationRules|exportedHeaders|post)$/) { } 110 84 194
elsif ($target =~ /^$Lemonldap::NG::Manager::Conf::Parser::virtualHostKeys$/) { } 84 0 84
271 110 ▶ if ( $leaf->{cnodes} ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($leaf->{'cnodes'}) { } 6 104 110
elsif ($h) { } 47 57 104
272 6 hdebug(' unopened subnode');
273 $self->newConf->{$target}->{$key} =
274 6 ▶ $self->refConf->{$target}->{$oldName} // {};
Condition50%1/2
$self->refConf->{$target}{$oldName} // {}
l!l
06
MC/DC0%0/1
$self->refConf->{$target}{$oldName} // {}
$self->refConf->{$target}{$oldName}
Truth table50%1/2
A
A= $self->refConf->{$target}{$oldName}
Aresult
11
00
275 }
276  
277 elsif ($h) {
278 47 hdebug(' 4 levels');
279 47 ▶ if ( $target eq 'locationRules' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target eq 'locationRules') { } 33 14 47
280 33 hdebug(' locationRules');
281 my $k =
282 $leaf->{comment}
283 ? "(?#$leaf->{comment})$leaf->{re}"
284 33 ▶ : $leaf->{re};
Branch: 1 branch
BranchTrueFalseTotal
$leaf->{'comment'} ? : 3 30 33
285 $k .= "(?#AuthnLevel=$leaf->{level})"
286 33 ▶ if $leaf->{level};
Branch: 1 branch
BranchTrueFalseTotal
if $leaf->{"level"} 0 33 33
287 33 $self->set( $target, $key, $k, $leaf->{data} );
288 }
289 else {
290 14 hdebug(' other than locationrules');
291 $self->set( $target, $key, $leaf->{title},
292 14 $leaf->{data} );
293 }
294 }
295  
296 # Unless $h is set, scan subnodes and check changes
297 else {
298 57 hdebug(' 3 levels only (missing $h)');
299 57 ▶ if ( ref $subNodes ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $subNodes) 57 0 57
300 57 hdebug(' has subnodes');
301 57 ▶ $self->_scanNodes($subNodes)
Branch: 1 branch
BranchTrueFalseTotal
$self->_scanNodes($subNodes) or return 0 0 57 57
302 or return 0;
303 }
304 57 ▶ if ( exists $self->refConf->{$target}->{$key}
Branch: 2 branches
BranchTrueFalseTotal
if (exists $self->refConf->{$target}{$key} and %{$self->refConf->{$target}{$key};}) { } 24 33 57
elsif (exists $self->newConf->{$target}{$key} and %{$self->newConf->{$target}{$key};}) { } 9 48 57
Condition100%3/3
exists $self->refConf->{$target}{$key} and %{$self->refConf->{$target}{$key};}
!ll&&!rl&&r
24924
MC/DC100%2/2
exists $self->refConf->{$target}{$key} and %{$self->refConf->{$target}{$key};}
exists $self->refConf->{$target}{$key} %{$self->refConf->{$target}{$key};}
Truth table100%3/3
A and B
A= exists $self->refConf->{$target}{$key}B= %{$self->refConf->{$target}{$key};}
ABresult
0X0
100
111
305 33 and %{ $self->refConf->{$target}->{$key} } )
306 {
307 24 hdebug(' old conf subnode has values');
308 24 my $c = $self->newConf->{$target};
309 24 foreach my $k (
310 24 keys %{ $self->refConf->{$target}->{$key} } )
311 {
312 33 ▶ unless ( defined $c->{$key}->{$k} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $c->{$key}{$k}) 3 30 33
313 3 hdebug(' missing value in old conf');
314 3 $self->confChanged(1);
315 3 push @{ $self->changes },
316 {
317 key => "$target, $key",
318 old => $k,
319 };
320 }
321 }
322 }
323 ▶ elsif ( exists $self->newConf->{$target}->{$key}
Condition66%2/3
exists $self->newConf->{$target}{$key} and %{$self->newConf->{$target}{$key};}
!ll&&!rl&&r
2409
MC/DC50%1/2
exists $self->newConf->{$target}{$key} and %{$self->newConf->{$target}{$key};}
exists $self->newConf->{$target}{$key} %{$self->newConf->{$target}{$key};}
Truth table66%2/3
A and B
A= exists $self->newConf->{$target}{$key}B= %{$self->newConf->{$target}{$key};}
ABresult
0X0
100
111
324 9 and %{ $self->newConf->{$target}->{$key} } )
325 {
326 9 hdebug(" '$key' has values");
327 9 $self->confChanged(1);
328 9 push @{ $self->changes },
329 { key => "$target", new => $key };
330 }
331 }
332 }
333 elsif ( $target =~ /^$virtualHostKeys$/ ) {
334 $self->set( 'vhostOptions', [ $oldName, $key ],
335 84 $target, $leaf->{data} );
336 }
337 else {
338 0 push @{ $self->errors },
339 { message => "Unknown vhost key $target" };
340 0 return 0;
341 }
342 194 next;
343 }
344  
345 # SAML
346 elsif ( $base =~ /^saml(?:S|ID)PMetaDataNodes$/ ) {
347 0 hdebug('SAML');
348 0 ▶ if ( defined $leaf->{data}
Branch: 1 branch
BranchTrueFalseTotal
if (defined $leaf->{"data"} and ref $leaf->{"data"} eq "ARRAY") 0 0 0
Condition0%0/3
defined $leaf->{"data"} and ref $leaf->{"data"} eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $leaf->{"data"} and ref $leaf->{"data"} eq "ARRAY"
defined $leaf->{"data"} ref $leaf->{"data"} eq "ARRAY"
Truth table0%0/3
A and B
A= defined $leaf->{"data"}B= ref $leaf->{"data"} eq "ARRAY"
ABresult
0X0
100
111
349 and ref( $leaf->{data} ) eq 'ARRAY' )
350 {
351 0 hdebug(" SAML data is an array, serializing");
352 0 $leaf->{data} = join ';', @{ $leaf->{data} };
353 }
354 0 ▶ if ( $target =~
Branch: 4 branches
BranchTrueFalseTotal
if ($target =~ /^saml(?:S|ID)PMetaData(?:ExportedAttributes|Macros)$/) { } 0 0 0
elsif ($target =~ /^saml(?:S|ID)PMetaDataXML$/) { } 0 0 0
elsif ($target =~ /^saml(?:S|ID)PMetaDataURL$/) { } 0 0 0
elsif ($target =~ /^saml(?:ID|S)PMetaDataOptions/) { } 0 0 0
355 /^saml(?:S|ID)PMetaData(?:ExportedAttributes|Macros)$/ )
356 {
357 0 ▶ if ( $leaf->{cnodes} ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($leaf->{'cnodes'}) { } 0 0 0
elsif ($h) { } 0 0 0
elsif (not @$subNodes) { } 0 0 0
358 0 hdebug(" $target: unopened node");
359 $self->newConf->{$target}->{$key} =
360 0 ▶ $self->refConf->{$target}->{$oldName} // {};
Condition0%0/2
$self->refConf->{$target}{$oldName} // {}
l!l
00
MC/DC0%0/1
$self->refConf->{$target}{$oldName} // {}
$self->refConf->{$target}{$oldName}
Truth table0%0/2
A
A= $self->refConf->{$target}{$oldName}
Aresult
11
00
361 }
362 elsif ($h) {
363 0 hdebug(" $target: opened node");
364 0 $self->confChanged(1);
365 $self->set( $target, $key, $leaf->{title},
366 0 $leaf->{data} );
367 }
368 elsif ( !@$subNodes ) {
369 0 hdebug(" $target: no subnodes");
370 0 $self->confChanged(1);
371 }
372 else {
373 0 hdebug(" $target: scanning subnodes");
374 0 $self->_scanNodes($subNodes);
375 }
376 }
377 elsif ( $target =~ /^saml(?:S|ID)PMetaDataXML$/ ) {
378 0 hdebug(" $target");
379 $self->set( $target, [ $oldName, $key ],
380 0 $target, $leaf->{data} );
381 }
382 elsif ( $target =~ /^saml(?:S|ID)PMetaDataURL$/ ) {
383 0 hdebug(" $target");
384 $self->set( $target, [ $oldName, $key ],
385 0 $target, $leaf->{data} );
386 }
387 elsif ( $target =~ /^saml(?:ID|S)PMetaDataOptions/ ) {
388 0 my $optKey = $&;
389 0 hdebug(" $base sub key: $target");
390 0 ▶ if ( $target =~
Branch: 1 branch
BranchTrueFalseTotal
if ($target =~ /^(?:$Lemonldap::NG::Manager::Conf::Parser::samlIDPMetaDataNodeKeys|$Lemonldap::NG::Manager::Conf::Parser::samlSPMetaDataNodeKeys)/) { } 0 0 0
391 /^(?:$samlIDPMetaDataNodeKeys|$samlSPMetaDataNodeKeys)/
392 )
393 {
394 $self->set(
395 $optKey, [ $oldName, $key ],
396 $target, $leaf->{data}
397 0 );
398 }
399 else {
400 0 push @{ $self->errors },
401 { message => "Unknown SAML metadata option $target" };
402 0 return 0;
403 }
404 }
405 else {
406 0 push @{ $self->errors },
407 { message => "Unknown SAML key $target" };
408 0 return 0;
409 }
410 0 next;
411 }
412  
413 # OIDC
414 elsif ( $base =~ /^oidc(?:O|R)PMetaDataNodes$/ ) {
415 0 hdebug('OIDC');
416 0 ▶ if ( $target =~ /^oidc(?:O|R)PMetaDataOptions$/ ) {
Branch: 5 branches
BranchTrueFalseTotal
if ($target =~ /^oidc(?:O|R)PMetaDataOptions$/) { } 0 0 0
elsif ($target =~ /^oidcOPMetaData(?:JSON|JWKS)$/) { } 0 0 0
elsif ($target =~ /^oidcRPMetaDataExportedVars$/) { } 0 0 0
elsif ($target =~ /^oidc(?:O|R)PMetaData(?:ExportedVars|Macros|ScopeRules)$/) { } 0 0 0
elsif ($target =~ /^oidc(?:O|R)PMetaDataOptions/) { } 0 0 0
417 0 hdebug(" $target: looking for subnodes");
418 0 $self->_scanNodes($subNodes);
419 0 $self->set( $target, $key, $leaf->{title}, $leaf->{data} );
420 }
421 elsif ( $target =~ /^oidcOPMetaData(?:JSON|JWKS)$/ ) {
422 0 hdebug(" $target");
423 0 $self->set( $target, $key, $leaf->{data} );
424 }
425 elsif ( $target =~ /^oidcRPMetaDataExportedVars$/ ) {
426 0 hdebug(" $target");
427 0 ▶ if ( $leaf->{cnodes} ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($leaf->{'cnodes'}) { } 0 0 0
elsif ($h) { } 0 0 0
elsif (not @$subNodes) { } 0 0 0
428 0 hdebug(' unopened');
429 $self->newConf->{$target}->{$key} =
430 0 ▶ $self->refConf->{$target}->{$oldName} // {};
Condition0%0/2
$self->refConf->{$target}{$oldName} // {}
l!l
00
MC/DC0%0/1
$self->refConf->{$target}{$oldName} // {}
$self->refConf->{$target}{$oldName}
Truth table0%0/2
A
A= $self->refConf->{$target}{$oldName}
Aresult
11
00
431 }
432 elsif ($h) {
433 0 hdebug(' opened');
434 0 $self->confChanged(1);
435 0 my $tmp = $leaf->{data};
436 0 ▶ if ( ref( $leaf->{data} ) eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $leaf->{"data"} eq "ARRAY") 0 0 0
437  
438 # Forward compatibility. If Type and Array have
439 # default values, store in old format
440 0 ▶ if ( $leaf->{data}->[1] eq "string"
Branch: 1 branch
BranchTrueFalseTotal
if ($leaf->{'data'}[1] eq 'string' and $leaf->{'data'}[2] eq 'auto') { } 0 0 0
Condition0%0/3
$leaf->{"data"}[1] eq "string" and $leaf->{"data"}[2] eq "auto"
!ll&&!rl&&r
000
MC/DC0%0/2
$leaf->{"data"}[1] eq "string" and $leaf->{"data"}[2] eq "auto"
$leaf->{"data"}[1] eq "string" $leaf->{"data"}[2] eq "auto"
Truth table0%0/3
A and B
A= $leaf->{"data"}[1] eq "string"B= $leaf->{"data"}[2] eq "auto"
ABresult
0X0
100
111
441 and $leaf->{data}->[2] eq "auto" )
442 {
443 0 $tmp = $leaf->{data}->[0];
444 }
445 else {
446 0 $tmp = join ';', @{ $leaf->{data} };
447 }
448 }
449 0 $self->set( $target, $key, $leaf->{title}, $tmp );
450 }
451 elsif ( !@$subNodes ) {
452 0 hdebug(" $target: no subnodes");
453 0 $self->confChanged(1);
454 }
455 else {
456 0 hdebug(" $target: scanning subnodes");
457 0 $self->_scanNodes($subNodes);
458 }
459 }
460 elsif ( $target =~
461 /^oidc(?:O|R)PMetaData(?:ExportedVars|Macros|ScopeRules)$/ )
462 {
463 0 hdebug(" $target");
464 0 ▶ if ( $leaf->{cnodes} ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($leaf->{'cnodes'}) { } 0 0 0
elsif ($h) { } 0 0 0
elsif (not @$subNodes) { } 0 0 0
465 0 hdebug(' unopened');
466 $self->newConf->{$target}->{$key} =
467 0 ▶ $self->refConf->{$target}->{$oldName} // {};
Condition0%0/2
$self->refConf->{$target}{$oldName} // {}
l!l
00
MC/DC0%0/1
$self->refConf->{$target}{$oldName} // {}
$self->refConf->{$target}{$oldName}
Truth table0%0/2
A
A= $self->refConf->{$target}{$oldName}
Aresult
11
00
468 }
469 elsif ($h) {
470 0 hdebug(' opened');
471 0 $self->confChanged(1);
472 $self->set( $target, $key, $leaf->{title},
473 0 $leaf->{data} );
474 }
475 elsif ( !@$subNodes ) {
476 0 hdebug(" $target: no subnodes");
477 0 $self->confChanged(1);
478 }
479 else {
480 0 hdebug(" $target: scanning subnodes");
481 0 $self->_scanNodes($subNodes);
482 }
483 }
484 elsif ( $target =~ /^oidc(?:O|R)PMetaDataOptions/ ) {
485 0 my $optKey = $&;
486 0 hdebug " $base sub key: $target";
487 0 ▶ if ( $target eq 'oidcRPMetaDataOptionsExtraClaims' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($target eq 'oidcRPMetaDataOptionsExtraClaims') { } 0 0 0
elsif ($target =~ /^(?:$Lemonldap::NG::Manager::Conf::Parser::oidcOPMetaDataNodeKeys|$Lemonldap::NG::Manager::Conf::Parser::oidcRPMetaDataNodeKeys)/) { } 0 0 0
488 0 ▶ if ( $leaf->{cnodes} ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($leaf->{'cnodes'}) { } 0 0 0
elsif ($h) { } 0 0 0
elsif (not @$subNodes) { } 0 0 0
489 0 hdebug(' unopened');
490 $self->newConf->{$target}->{$key} =
491 0 ▶ $self->refConf->{$target}->{$oldName} // {};
Condition0%0/2
$self->refConf->{$target}{$oldName} // {}
l!l
00
MC/DC0%0/1
$self->refConf->{$target}{$oldName} // {}
$self->refConf->{$target}{$oldName}
Truth table0%0/2
A
A= $self->refConf->{$target}{$oldName}
Aresult
11
00
492 }
493 elsif ($h) {
494 0 hdebug(' opened');
495 $self->set( $target, $key, $leaf->{title},
496 0 $leaf->{data} );
497 }
498 elsif ( !@$subNodes ) {
499 0 hdebug(" $target: no subnodes");
500 0 $self->confChanged(1);
501 }
502 else {
503 0 hdebug(" $target: scanning subnodes");
504 0 $self->_scanNodes($subNodes);
505 }
506 }
507 elsif ( $target =~
508 /^(?:$oidcOPMetaDataNodeKeys|$oidcRPMetaDataNodeKeys)/ )
509 {
510 $self->set(
511 $optKey, [ $oldName, $key ],
512 $target, $leaf->{data}
513 0 );
514 }
515 else {
516 0 push @{ $self->errors },
517 { message => "Unknown OIDC metadata option $target" };
518 0 return 0;
519 }
520 }
521 else {
522 0 push @{ $self->errors },
523 { message => "Unknown OIDC key $target" };
524 0 return 0;
525 }
526 0 next;
527 }
528  
529 # CAS
530 elsif ( $base =~ /^cas(?:App|Srv)MetaDataNodes$/ ) {
531 0 my $optKey = $&;
532 0 hdebug('CAS');
533 0 ▶ if ( $target =~ /^cas(?:App|Srv)MetaDataOptions$/ ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($target =~ /^cas(?:App|Srv)MetaDataOptions$/) { } 0 0 0
elsif ($target =~ /^cas(?:App|Srv)MetaData(?:ExportedVars|Macros)$/) { } 0 0 0
elsif ($target =~ /^cas(?:Srv|App)MetaDataOptions/) { } 0 0 0
534 0 hdebug(" $target: looking for subnodes");
535 0 $self->_scanNodes($subNodes);
536 0 $self->set( $target, $key, $leaf->{title}, $leaf->{data} );
537 }
538 elsif ( $target =~
539 /^cas(?:App|Srv)MetaData(?:ExportedVars|Macros)$/ )
540 {
541 0 hdebug(" $target");
542 0 ▶ if ( $leaf->{cnodes} ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($leaf->{'cnodes'}) { } 0 0 0
elsif ($h) { } 0 0 0
elsif (not @$subNodes) { } 0 0 0
543 0 hdebug(' unopened');
544 $self->newConf->{$target}->{$key} =
545 0 ▶ $self->refConf->{$target}->{$oldName} // {};
Condition0%0/2
$self->refConf->{$target}{$oldName} // {}
l!l
00
MC/DC0%0/1
$self->refConf->{$target}{$oldName} // {}
$self->refConf->{$target}{$oldName}
Truth table0%0/2
A
A= $self->refConf->{$target}{$oldName}
Aresult
11
00
546 }
547 elsif ($h) {
548 0 hdebug(' opened');
549 0 $self->confChanged(1);
550 $self->set( $target, $key, $leaf->{title},
551 0 $leaf->{data} );
552 }
553 elsif ( !@$subNodes ) {
554 0 hdebug(" $target: no subnodes");
555 0 $self->confChanged(1);
556 }
557 else {
558 0 hdebug(" $target: scanning subnodes");
559 0 $self->_scanNodes($subNodes);
560 }
561 }
562 elsif ( $target =~ /^cas(?:Srv|App)MetaDataOptions/ ) {
563 0 my $optKey = $&;
564 0 hdebug " $base sub key: $target";
565 0 ▶ if ( $target eq 'casSrvMetaDataOptionsProxiedServices' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($target eq 'casSrvMetaDataOptionsProxiedServices') { } 0 0 0
elsif ($target =~ /^(?:$Lemonldap::NG::Manager::Conf::Parser::casSrvMetaDataNodeKeys|$Lemonldap::NG::Manager::Conf::Parser::casAppMetaDataNodeKeys)/) { } 0 0 0
566 0 ▶ if ( $leaf->{cnodes} ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($leaf->{'cnodes'}) { } 0 0 0
elsif ($h) { } 0 0 0
elsif (not @$subNodes) { } 0 0 0
567 0 hdebug(' unopened');
568 $self->newConf->{$target}->{$key} =
569 0 ▶ $self->refConf->{$target}->{$oldName} // {};
Condition0%0/2
$self->refConf->{$target}{$oldName} // {}
l!l
00
MC/DC0%0/1
$self->refConf->{$target}{$oldName} // {}
$self->refConf->{$target}{$oldName}
Truth table0%0/2
A
A= $self->refConf->{$target}{$oldName}
Aresult
11
00
570 }
571 elsif ($h) {
572 0 hdebug(' opened');
573 $self->set( $target, $key, $leaf->{title},
574 0 $leaf->{data} );
575 }
576 elsif ( !@$subNodes ) {
577 0 hdebug(" $target: no subnodes");
578 0 $self->confChanged(1);
579 }
580 else {
581 0 hdebug(" $target: scanning subnodes");
582 0 $self->_scanNodes($subNodes);
583 }
584 }
585 elsif ( $target =~
586 /^(?:$casSrvMetaDataNodeKeys|$casAppMetaDataNodeKeys)/ )
587 {
588 $self->set(
589 $optKey, [ $oldName, $key ],
590 $target, $leaf->{data}
591 0 );
592 }
593 else {
594 0 push @{ $self->errors },
595 { message => "Unknown CAS metadata option $target" };
596 0 return 0;
597 }
598 }
599 else {
600 0 push @{ $self->errors },
601 { message => "Unknown CAS option $target" };
602 0 return 0;
603 }
604 0 next;
605 }
606 elsif ( $base eq 'keyNodes' ) {
607 15 hdebug('Keys');
608 15 hdebug("target $target");
609 15 hdebug("key $key");
610 15 ▶ if ( $target eq "KeyMaterial" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target eq 'KeyMaterial') { } 5 10 15
611 5 ▶ if ( $leaf->{data} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($leaf->{'data'}) { } 3 2 5
612 3 hdebug(' opened');
613 3 for my $data ( @{ $leaf->{data} } ) {
614 $self->set( "keys", $key, $data->{title},
615 9 $data->{data} );
616 }
617 }
618 else {
619 2 hdebug(' unopened');
620 2 for my $opt (qw/keyPrivate keyPrivatePwd keyPublic/) {
621 6 $self->set( "keys", $key, $opt, undef );
622 }
623 }
624 }
625 else {
626 10 $self->set( "keys", $key, $leaf->{title}, $leaf->{data} );
627 }
628 15 next;
629 }
630 else {
631 0 push @{ $self->errors },
632 { message => "Fatal: unknown special sub node $base" };
633 0 return 0;
634 }
635 }
636  
637 ####################
638 # Application list #
639 ####################
640  
641 # Application list root node
642 elsif ( $leaf->{title} eq 'applicationList' ) {
643 16 hdebug( $leaf->{title} );
644 16 ▶ if ( $leaf->{cnodes} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($leaf->{'cnodes'}) { } 10 6 16
645 10 hdebug(' unopened');
646 $self->newConf->{applicationList} =
647 10 ▶ $self->refConf->{applicationList} // {};
Condition50%1/2
$self->refConf->{"applicationList"} // {}
l!l
100
MC/DC0%0/1
$self->refConf->{"applicationList"} // {}
$self->refConf->{"applicationList"}
Truth table50%1/2
A
A= $self->refConf->{"applicationList"}
Aresult
11
00
648 }
649 else {
650 6 ▶ $self->_scanNodes($subNodes) or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->_scanNodes($subNodes) or return 0 0 6 6
651  
652 # Check for deleted
653 my @listCatRef =
654 18 map { $self->refConf->{applicationList}->{$_}->{catname} }
655 6 keys %{ $self->refConf->{applicationList} };
656 my @listCatNew =
657 17 map { $self->newConf->{applicationList}->{$_}->{catname} }
658 keys(
659 %{
660 6 ref $self->newConf->{applicationList}
661 ? $self->newConf->{applicationList}
662 : {}
663 6 ▶ }
Branch: 1 branch
BranchTrueFalseTotal
ref $self->newConf->{'applicationList'} ? : 6 0 6
664 );
665  
666 6 ▶ @listCatRef = map { $_ ? $_ : () } @listCatRef;
Branch: 1 branch
BranchTrueFalseTotal
$_ ? : 18 0 18
667 6 ▶ @listCatNew = map { $_ ? $_ : () } @listCatNew;
Branch: 1 branch
BranchTrueFalseTotal
$_ ? : 17 0 17
668 6 @listCatRef = sort @listCatRef;
669 6 @listCatNew = sort @listCatNew;
670 6 hdebug( '# @listCatRef : ', \@listCatRef );
671 6 hdebug( '# @listCatNew : ', \@listCatNew );
672  
673 # Check for deleted
674 my @diff =
675 6 grep !${ { map { $_, 1 } @listCatNew } }{$_}, @listCatRef;
676 6 ▶ if ( scalar @diff ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @diff) 1 5 6
677 1 $self->confChanged(1);
678 1 push @{ $self->changes },
679 {
680 new => join( ', ', 'categoryList', @listCatNew ),
681 key => join( ', ', 'Deletes in cat(s)', @diff ),
682 old => join( ', ', 'categoryList', @listCatRef ),
683 };
684 }
685 }
686 16 next;
687 }
688  
689 # Application list sub nodes
690 elsif ( $leaf->{id} =~ /^applicationList\/(.+)$/ ) {
691 60 hdebug('Application list subnode');
692 28 ▶ use feature 'state';
Subroutine BEGIN: called CC=1 SCAR=0.0
693 60 my @cats = split /\//, $1;
694 60 my $app = pop @cats;
695 60 ▶ $self->newConf->{applicationList} //= {};
Condition100%2/2
$self->newConf->{"applicationList"} //= {}
l!l
546
MC/DC100%1/1
$self->newConf->{"applicationList"} //= {}
$self->newConf->{"applicationList"}
Truth table100%2/2
A
A= $self->newConf->{"applicationList"}
Aresult
11
00
696  
697 # $cn is a pointer to the parent
698 60 my $cn = $self->newConf->{applicationList};
699 60 my $cmp = $self->refConf->{applicationList};
700 60 my @path;
701  
702 # Makes $cn point to the parent
703 60 foreach my $cat (@cats) {
704 43 hdebug(" looking to cat $cat");
705 43 ▶ unless ( defined $knownCat->{$cat} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $knownCat->{$cat}) 0 43 43
706 0 push @{ $self->{errors} },
707 { message =>
708 "Fatal: sub cat/app before parent ($leaf->{id})" };
709 0 return 0;
710 }
711 43 $cn = $cn->{ $knownCat->{$cat} };
712 43 push @path, $cn->{catname};
713 43 ▶ $cmp->{$cat} //= {};
Condition50%1/2
$cmp->{$cat} //= {}
l!l
430
MC/DC0%0/1
$cmp->{$cat} //= {}
$cmp->{$cat}
Truth table50%1/2
A
A= $cmp->{$cat}
Aresult
11
00
714 43 $cmp = $cmp->{$cat};
715 }
716  
717 60 my $newapp = $app;
718  
719 # Compute a nice name for new nodes, taking care of potential conflicts
720 # For some reason, the manager sends /nNaN sometimes
721 60 ▶ if ( $newapp =~ /^n(\d+|NaN)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($newapp =~ /^n(\d+|NaN)$/) 3 57 60
722  
723 # Remove all special characters
724 3 my $baseName = $leaf->{title} =~ s/\W//gr;
725 3 $baseName = lc $baseName;
726 3 $newapp = $baseName;
727 3 my $cnt = 1;
728 3 ▶ while ( exists $cn->{$newapp} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $cn->{$newapp}) 0 3 3
729 0 $newapp = "${baseName}_" . $cnt++;
730 }
731 }
732  
733 # Create new category
734 #
735 # Note that this works because nodes are ordered so "cat/cat2/app"
736 # is looked after "cat" and "cat/cat2"
737 60 ▶ if ( $leaf->{type} eq 'menuCat' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($leaf->{"type"} eq "menuCat") 17 43 60
738 17 hdebug(' menu cat');
739 17 $knownCat->{__id}++;
740 17 $knownCat->{$app} = $newapp;
741 $cn->{$newapp} = {
742 catname => $leaf->{title},
743 type => 'category',
744 order => $knownCat->{__id}
745 17 };
746 17 ▶ unless ($cmp->{$app}
Branch: 1 branch
BranchTrueFalseTotal
unless ($cmp->{$app} and $cmp->{$app}{"catname"} eq $cn->{$newapp}{"catname"}) 0 17 17
Condition33%1/3
$cmp->{$app} and $cmp->{$app}{"catname"} eq $cn->{$newapp}{"catname"}
!ll&&!rl&&r
0017
MC/DC0%0/2
$cmp->{$app} and $cmp->{$app}{"catname"} eq $cn->{$newapp}{"catname"}
$cmp->{$app} $cmp->{$app}{"catname"} eq $cn->{$newapp}{"catname"}
Truth table33%1/3
A and B
A= $cmp->{$app}B= $cmp->{$app}{"catname"} eq $cn->{$newapp}{"catname"}
ABresult
0X0
100
111
747 and $cmp->{$app}->{catname} eq $cn->{$newapp}->{catname} )
748 {
749 0 $self->confChanged(1);
750 0 ▶ push @{ $self->changes },
Branch: 1 branch
BranchTrueFalseTotal
$cn->{$newapp} ? : 0 0 0
751 {
752 key => join(
753 ', ', 'applicationList', @path, $leaf->{title}
754 ),
755 new => $cn->{$newapp}->{catname},
756 old => (
757 $cn->{$newapp} ? $cn->{$newapp}->{catname} : undef
758 )
759 0 };
760 }
761 17 ▶ if ( ref $subNodes ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $subNodes) 17 0 17
762 17 ▶ $self->_scanNodes($subNodes) or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->_scanNodes($subNodes) or return 0 0 17 17
763 }
764 17 my @listCatRef = keys %{ $cmp->{$app} };
765 17 my @listCatNew = keys %{ $cn->{$newapp} };
766  
767 # Check for deleted
768 17 ▶ unless ( @listCatRef == @listCatNew ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@listCatRef == @listCatNew) 3 14 17
769 3 $self->confChanged(1);
770 3 push @{ $self->changes },
771 {
772 key => join( ', ', 'applicationList', @path ),
773 new => 'Changes in cat(s)/app(s)',
774 };
775 }
776 }
777  
778 # Create new apps
779 60 ▶ if ( $leaf->{type} eq 'menuApp' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($leaf->{"type"} eq "menuApp") 43 17 60
780 43 hdebug(' new app');
781 43 $knownCat->{__id}++;
782 $cn->{$newapp} = {
783 type => 'application',
784 options => $leaf->{data},
785 order => $knownCat->{__id}
786 43 };
787 43 $cn->{$newapp}->{options}->{name} = $leaf->{title};
788 43 ▶ unless ( $cmp->{$app} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmp->{$app}) { } 40 3 43
789 3 $self->confChanged(1);
790 3 push @{ $self->changes },
791 {
792 key => join( ', ', 'applicationList', @path ),
793 new => $leaf->{title},
794 3 };
795 }
796 else {
797 # Check for change in ordering
798 40 ▶ if ( ( $cn->{$newapp}->{order} || 0 ) !=
Branch: 1 branch
BranchTrueFalseTotal
if (($cn->{$newapp}{"order"} || 0) != ($cmp->{$newapp}{"order"} || 0)) 22 18 40
Condition50%2/4
$cn->{$newapp}{'order'} || 0
l!l
400
$cmp->{$newapp}{'order'} || 0
l!l
400
MC/DC0%0/1
$cn->{$newapp}{'order'} || 0
$cn->{$newapp}{'order'}
MC/DC0%0/1
$cmp->{$newapp}{'order'} || 0
$cmp->{$newapp}{'order'}
Truth table50%1/2
A
A= $cn->{$newapp}{'order'}
Aresult
11
00
Truth table50%1/2
A
A= $cmp->{$newapp}{'order'}
Aresult
11
00
799 ( $cmp->{$newapp}->{order} || 0 ) )
800 {
801 22 $self->confChanged(1);
802 }
803  
804 # Check for change in options
805 40 foreach my $k ( keys %{ $cn->{$newapp}->{options} } ) {
806 200 ▶ unless ( $cmp->{$app}->{options}->{$k} eq
Branch: 1 branch
BranchTrueFalseTotal
unless ($cmp->{$app}{"options"}{$k} eq $cn->{$newapp}{"options"}{$k}) 3 197 200
807 $cn->{$newapp}->{options}->{$k} )
808 {
809 3 $self->confChanged(1);
810 3 push @{ $self->changes },
811 {
812 key => join( ', ',
813 'applicationList', @path,
814 $leaf->{title}, $k ),
815 new => $cn->{$newapp}->{options}->{$k},
816 3 old => $cmp->{$app}->{options}->{$k}
817 };
818 }
819 }
820 }
821 }
822 60 next;
823 }
824 elsif ( $leaf->{id} eq 'grantSessionRules' ) {
825 16 hdebug('grantSessionRules');
826 16 ▶ if ( $leaf->{cnodes} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($leaf->{'cnodes'}) { } 10 6 16
827 10 hdebug(' unopened');
828 10 ▶ $self->newConf->{$name} = $self->refConf->{$name} // {};
Condition50%1/2
$self->refConf->{$name} // {}
l!l
100
MC/DC0%0/1
$self->refConf->{$name} // {}
$self->refConf->{$name}
Truth table50%1/2
A
A= $self->refConf->{$name}
Aresult
11
00
829 }
830 else {
831 6 hdebug(' opened');
832 6 ▶ $subNodes //= [];
Condition50%1/2
$subNodes //= []
l!l
60
MC/DC0%0/1
$subNodes //= []
$subNodes
Truth table50%1/2
A
A= $subNodes
Aresult
11
00
833 6 my $count = 0;
834 6 my $ref = $self->refConf->{grantSessionRules};
835 6 my $new = $self->newConf->{grantSessionRules};
836 6 ▶ my @old = ref $ref ? keys %$ref : ();
Branch: 1 branch
BranchTrueFalseTotal
ref $ref ? : 6 0 6
837 6 $self->newConf->{grantSessionRules} = {};
838 6 foreach my $n (@$subNodes) {
839 0 hdebug(" looking at $n subnode");
840 my $k =
841 0 ▶ $n->{re} . ( $n->{comment} ? "##$n->{comment}" : '' );
Branch: 1 branch
BranchTrueFalseTotal
$n->{'comment'} ? : 0 0 0
842 0 $self->newConf->{grantSessionRules}->{$k} = $n->{data};
843 0 $count++;
844 0 ▶ unless ( defined $ref->{$k} ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $ref->{$k}) { } 0 0 0
(do { $ref->{$k} ne $n->{"data"} }) 0 0 0
845 0 $self->confChanged(1);
846 0 push @{ $self->changes },
847 { keys => 'grantSessionRules', new => $k };
848 }
849 0 elsif ( $ref->{$k} ne $n->{data} ) {
850 0 $self->confChanged(1);
851 0 push @{ $self->changes },
852 {
853 key => "grantSessionRules, $k",
854 old => $self->refConf->{grantSessionRules}->{$k},
855 new => $n->{data}
856 0 };
857 }
858 0 @old = grep { $_ ne $k } @old;
859 }
860 6 ▶ if (@old) {
Branch: 1 branch
BranchTrueFalseTotal
if (@old) 0 6 6
861 0 $self->confChanged(1);
862 0 push @{ $self->changes },
863 { key => 'grantSessionRules', old => $_, }
864 0 foreach (@old);
865 }
866 }
867 16 next;
868 }
869  
870 # openIdIDPList: data is splitted by Conf.pm into a boolean and a
871 # string
872 elsif ( $name eq 'openIdIDPList' ) {
873 16 hdebug('openIdIDPList');
874 16 ▶ if ( $leaf->{data} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($leaf->{'data'}) { } 0 16 16
875 0 ▶ unless ( ref $leaf->{data} eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $leaf->{"data"} eq "ARRAY") 0 0 0
876 0 push @{ $self->{errors} },
877 0 { message => 'Malformed openIdIDPList ' . $leaf->{data} };
878 0 return 0;
879 }
880 0 $self->set( $name, join( ';', @{ $leaf->{data} } ) );
881 }
882 else {
883 16 $self->set( $name, undef );
884 }
885 16 next;
886 }
887  
888 ####################
889 # Other hash nodes #
890 ####################
891 ▶ elsif ( $leaf->{title} =~ /^$simpleHashKeys$/
Condition66%2/3
$leaf->{"title"} =~ /^$Lemonldap::NG::Manager::Conf::Parser::simpleHashKeys$/ and not $leaf->{"title"} eq "applicationList"
!ll&&!rl&&r
52320366
MC/DC50%1/2
$leaf->{"title"} =~ /^$Lemonldap::NG::Manager::Conf::Parser::simpleHashKeys$/ and not $leaf->{"title"} eq "applicationList"
$leaf->{"title"} =~ /^$Lemonldap::NG::Manager::Conf::Parser::simpleHashKeys$/ not $leaf->{"title"} eq "applicationList"
Truth table66%2/3
A and not(B)
A= $leaf->{"title"} =~ /^$Lemonldap::NG::Manager::Conf::Parser::simpleHashKeys$/B= not $leaf->{"title"} eq "applicationList"
ABresult
0X0
100
111
892 and not $leaf->{title} eq 'applicationList' )
893 {
894 366 hdebug( $leaf->{title} );
895  
896 # If a `cnodes` key is found, keep old key unchanges
897 366 ▶ if ( $leaf->{cnodes} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($leaf->{'cnodes'}) { } 286 80 366
898 286 hdebug(' unopened');
899 286 ▶ $self->newConf->{$name} = $self->refConf->{$name} // {};
Condition100%2/2
$self->refConf->{$name} // {}
l!l
155131
MC/DC100%1/1
$self->refConf->{$name} // {}
$self->refConf->{$name}
Truth table100%2/2
A
A= $self->refConf->{$name}
Aresult
11
00
900 }
901 else {
902 80 hdebug(' opened');
903  
904 # combModules: just to replace "over" key
905 80 ▶ if ( $name eq 'combModules' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "combModules") 1 79 80
906 1 hdebug(' combModules');
907 1 $self->newConf->{$name} = {};
908 1 foreach my $node ( @{ $leaf->{nodes} } ) {
909 2 my $tmp;
910 2 $tmp->{$_} = $node->{data}->{$_} foreach (qw(type for));
911 2 $tmp->{over} = {};
912 2 foreach ( @{ $node->{data}->{over} } ) {
913 0 $tmp->{over}->{ $_->[0] } = $_->[1];
914 }
915 2 $self->newConf->{$name}->{ $node->{title} } = $tmp;
916 }
917  
918 # TODO: check changes
919 1 $self->confChanged(1);
920 1 next;
921 }
922  
923 # sfExtra: just to replace "over" key
924 79 ▶ if ( $name eq 'sfExtra' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "sfExtra") 1 78 79
925 1 hdebug(' sfExtra');
926 1 $self->newConf->{$name} = {};
927 1 foreach my $node ( @{ $leaf->{nodes} } ) {
928 2 my $tmp;
929 $tmp->{$_} = $node->{data}->{$_}
930 2 foreach (qw(type rule logo level label regrule));
931 2 ▶ $tmp->{register} = $node->{data}->{register} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$node->{'data'}{'register'} ? : 0 2 2
932 2 $tmp->{over} = {};
933 2 foreach ( @{ $node->{data}->{over} } ) {
934 3 $tmp->{over}->{ $_->[0] } = $_->[1];
935 }
936 2 $self->newConf->{$name}->{ $node->{title} } = $tmp;
937 }
938  
939 # TODO: check changes
940 1 $self->confChanged(1);
941 1 next;
942 }
943  
944 78 ▶ $subNodes //= [];
Condition100%2/2
$subNodes //= []
l!l
726
MC/DC100%1/1
$subNodes //= []
$subNodes
Truth table100%2/2
A
A= $subNodes
Aresult
11
00
945 78 my $count = 0;
946 my @old = (
947 ref( $self->refConf->{$name} )
948 78 ▶ ? ( keys %{ $self->refConf->{$name} } )
Branch: 1 branch
BranchTrueFalseTotal
ref $self->refConf->{$name} ? : 60 18 78
949 : ()
950 );
951 78 $self->newConf->{$name} = {};
952 78 foreach my $n (@$subNodes) {
953 61 hdebug(" looking at $n subnode");
954 61 ▶ if ( ref $n->{data} and ref $n->{data} eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $n->{"data"} and ref $n->{"data"} eq "ARRAY") 0 61 61
Condition33%1/3
ref $n->{"data"} and ref $n->{"data"} eq "ARRAY"
!ll&&!rl&&r
6100
MC/DC0%0/2
ref $n->{"data"} and ref $n->{"data"} eq "ARRAY"
ref $n->{"data"} ref $n->{"data"} eq "ARRAY"
Truth table33%1/3
A and B
A= ref $n->{"data"}B= ref $n->{"data"} eq "ARRAY"
ABresult
0X0
100
111
955  
956 # authChoiceModules
957 0 ▶ if ( $name eq 'authChoiceModules' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "authChoiceModules") 0 0 0
958 0 hdebug(' authChoiceModules');
959 0 ▶ if ( ref( $n->{data}->[5] ) eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $n->{'data'}[5] eq 'ARRAY') { } 0 0 0
960 $n->{data}->[5] =
961 0 to_json( { map { @$_ } @{ $n->{data}->[5] } },
962 { canonical => 1 } );
963 }
964 else {
965 0 $n->{data}->[5] = '{}';
966 }
967 }
968  
969 0 $n->{data} = join ';', @{ $n->{data} };
970 }
971 61 $self->newConf->{$name}->{ $n->{title} } = $n->{data};
972 61 $count++;
973 61 ▶ unless ( defined $self->refConf->{$name}->{ $n->{title} } )
Branch: 2 branches
BranchTrueFalseTotal
if (defined $self->refConf->{$name}{$n->{'title'}}) { } 58 3 61
(do { $self->refConf->{$name}{$n->{"title"}} ne $n->{"data"} }) 1 57 58
974 {
975 3 $self->confChanged(1);
976 3 push @{ $self->changes },
977 3 { key => $name, new => $n->{title}, };
978 }
979 0 elsif (
980 $self->refConf->{$name}->{ $n->{title} } ne $n->{data} )
981 {
982 1 $self->confChanged(1);
983 1 push @{ $self->changes },
984 {
985 key => "$name, $n->{title}",
986 old => $self->refConf->{$name}->{ $n->{title} },
987 new => $n->{data}
988 1 };
989 }
990 61 @old = grep { $_ ne $n->{title} } @old;
991 }
992 78 ▶ if (@old) {
Branch: 1 branch
BranchTrueFalseTotal
if (@old) 2 76 78
993 2 $self->confChanged(1);
994 2 push @{ $self->changes }, { key => $name, old => $_, }
995 2 foreach (@old);
996 }
997 }
998 364 next;
999 }
1000  
1001 # Double hash nodes
1002 elsif ( $leaf->{title} =~ /^$doubleHashKeys$/ ) {
1003 2 hdebug( $leaf->{title} );
1004 my @oldHosts = (
1005 ref( $self->refConf->{$name} )
1006 2 ▶ ? ( keys %{ $self->refConf->{$name} } )
Branch: 1 branch
BranchTrueFalseTotal
ref $self->refConf->{$name} ? : 0 2 2
1007 : ()
1008 );
1009 2 $self->newConf->{$name} = {};
1010 2 ▶ unless ( defined $leaf->{data} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $leaf->{"data"}) 2 0 2
1011 2 hdebug(' unopened');
1012 2 ▶ $self->newConf->{$name} = $self->refConf->{$name} || {};
Condition50%1/2
$self->refConf->{$name} || {}
l!l
02
MC/DC0%0/1
$self->refConf->{$name} || {}
$self->refConf->{$name}
Truth table50%1/2
A
A= $self->refConf->{$name}
Aresult
11
00
1013 2 next;
1014 }
1015 0 foreach my $getHost ( @{ $leaf->{data} } ) {
1016 0 my $change = 0;
1017 0 my @oldKeys;
1018 0 my $host = $getHost->{k};
1019 0 hdebug(" looking at host: $host");
1020 0 $self->newConf->{$name}->{$host} = {};
1021 0 ▶ unless ( defined $self->refConf->{$name}->{$host} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->refConf->{$name}{$host}) { } 0 0 0
1022 0 $self->confChanged(1);
1023 0 $change++;
1024 0 push @{ $self->changes }, { key => $name, new => $host };
1025 0 hdebug(" $host is new");
1026 }
1027 else {
1028 0 @oldHosts = grep { $_ ne $host } @oldHosts;
1029 0 @oldKeys = keys %{ $self->refConf->{$name}->{$host} };
1030 }
1031 0 foreach my $prm ( @{ $getHost->{h} } ) {
1032 $self->newConf->{$name}->{$host}->{ $prm->{k} } =
1033 0 $prm->{v};
1034 0 ▶ if (
Branch: 2 branches
BranchTrueFalseTotal
if (not $change and !defined($self->refConf->{$name}{$host}{$prm->{'k'}}) || $self->newConf->{$name}{$host}{$prm->{'k'}} ne $self->refConf->{$name}{$host}{$prm->{'k'}}) { } 0 0 0
elsif (not $change) { } 0 0 0
Condition0%0/6
not $change and !defined($self->refConf->{$name}{$host}{$prm->{"k"}}) || $self->newConf->{$name}{$host}{$prm->{"k"}} ne $self->refConf->{$name}{$host}{$prm->{"k"}}
!ll&&!rl&&r
000
not defined $self->refConf->{$name}{$host}{$prm->{"k"}} or $self->newConf->{$name}{$host}{$prm->{"k"}} ne $self->refConf->{$name}{$host}{$prm->{"k"}}
l!l&&r!l&&!r
000
MC/DC0%0/3
not $change and !defined($self->refConf->{$name}{$host}{$prm->{"k"}}) || $self->newConf->{$name}{$host}{$prm->{"k"}} ne $self->refConf->{$name}{$host}{$prm->{"k"}}
not $change not defined $self->refConf->{$name}{$host}{$prm->{"k"}} $self->newConf->{$name}{$host}{$prm->{"k"}} ne $self->refConf->{$name}{$host}{$prm->{"k"}}
Truth table0%0/4
not(A) and not(B) or C
A= not $changeB= not defined $self->refConf->{$name}{$host}{$prm->{"k"}}C= $self->newConf->{$name}{$host}{$prm->{"k"}} ne $self->refConf->{$name}{$host}{$prm->{"k"}}
ABCresult
0XX0
1000
11X1
1011
1035 !$change
1036 and (
1037 not defined(
1038 $self->refConf->{$name}->{$host}->{ $prm->{k} }
1039 )
1040 or $self->newConf->{$name}->{$host}->{ $prm->{k} }
1041 ne $self->refConf->{$name}->{$host}->{ $prm->{k} }
1042 )
1043 )
1044 {
1045 0 $self->confChanged(1);
1046 0 hdebug(" key $prm->{k} has been changed");
1047 0 push @{ $self->changes },
1048 0 { key => "$name/$host", new => $prm->{k} };
1049 }
1050 elsif ( !$change ) {
1051 0 @oldKeys = grep { $_ ne $prm->{k} } @oldKeys;
1052 }
1053 }
1054 0 ▶ if (@oldKeys) {
Branch: 1 branch
BranchTrueFalseTotal
if (@oldKeys) 0 0 0
1055 0 $self->confChanged(1);
1056 0 hdebug( " old keys: " . join( ' ', @oldKeys ) );
1057 0 push @{ $self->changes },
1058 { key => "$name/$host", old => $_ }
1059 0 foreach (@oldKeys);
1060 }
1061 }
1062 0 ▶ if (@oldHosts) {
Branch: 1 branch
BranchTrueFalseTotal
if (@oldHosts) 0 0 0
1063 0 $self->confChanged(1);
1064 0 hdebug( " old hosts " . join( ' ', @oldHosts ) );
1065 0 push @{ $self->changes }, { key => "$name", old => $_ }
1066 0 foreach (@oldHosts);
1067 }
1068 0 next;
1069 }
1070  
1071 ###############
1072 # Other nodes #
1073 ###############
1074  
1075 # Check if subnodes
1076 5230 my $n = 0;
1077 5230 ▶ if ( ref $subNodesCond ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $subNodesCond) 16 5214 5230
1078 16 hdebug(' conditional subnodes detected');
1079  
1080 # Bad idea,subnode unopened are not read
1081 #$subNodesCond = [ grep { $_->{show} } @$subNodesCond ];
1082 16 ▶ $self->_scanNodes($subNodesCond) or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->_scanNodes($subNodesCond) or return 0 0 16 16
1083 16 $n++;
1084 }
1085 5230 ▶ if ( ref $subNodes ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $subNodes) 1380 3850 5230
1086 1380 hdebug(' subnodes detected');
1087 1380 ▶ $self->_scanNodes($subNodes) or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->_scanNodes($subNodes) or return 0 0 1380 1380
1088 1380 $n++;
1089 }
1090 5230 ▶ if ($n) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n) 1380 3850 5230
1091 1380 next;
1092 }
1093 3850 ▶ if ( defined $leaf->{data} and ref( $leaf->{data} ) eq 'ARRAY' ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $leaf->{'data'} and ref $leaf->{'data'} eq 'ARRAY') { } 87 3763 3850
elsif ($leaf->{'get'} and ref $leaf->{'get'} eq 'ARRAY') { } 6 3757 3763
Condition100%3/3
defined $leaf->{"data"} and ref $leaf->{"data"} eq "ARRAY"
!ll&&!rl&&r
310665787
MC/DC100%2/2
defined $leaf->{"data"} and ref $leaf->{"data"} eq "ARRAY"
defined $leaf->{"data"} ref $leaf->{"data"} eq "ARRAY"
Truth table100%3/3
A and B
A= defined $leaf->{"data"}B= ref $leaf->{"data"} eq "ARRAY"
ABresult
0X0
100
111
1094 87 ▶ if ( ref( $leaf->{data}->[0] ) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $leaf->{'data'}[0] eq 'HASH') { } 0 87 87
1095 0 hdebug(" array found");
1096 0 ▶ $self->_scanNodes( $leaf->{data} ) or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->_scanNodes($leaf->{"data"}) or return 0 0 0 0
1097 }
1098 else {
1099 87 $self->set( $name, join( ';', @{ $leaf->{data} } ) );
1100 }
1101 }
1102  
1103 # Grouped nodes not opened
1104 ▶ elsif ( $leaf->{get} and ref $leaf->{get} eq 'ARRAY' ) {
Condition66%2/3
$leaf->{"get"} and ref $leaf->{"get"} eq "ARRAY"
!ll&&!rl&&r
375706
MC/DC50%1/2
$leaf->{"get"} and ref $leaf->{"get"} eq "ARRAY"
$leaf->{"get"} ref $leaf->{"get"} eq "ARRAY"
Truth table66%2/3
A and B
A= $leaf->{"get"}B= ref $leaf->{"get"} eq "ARRAY"
ABresult
0X0
100
111
1105 6 hdebug(" unopened grouped node");
1106 6 foreach my $subkey ( @{ $leaf->{get} } ) {
1107 16 $self->set( $subkey, undef );
1108 }
1109 }
1110  
1111 # Normal leaf
1112 else {
1113 3757 $self->set( $name, $leaf->{data} );
1114 }
1115 }
1116 1541 return 1;
1117 }
1118  
1119 ##@method private void set($target, @path, $data)
1120 # Store a value in the $target key (following subkeys if @path is set)
1121 sub set {
1122 4032 ▶ my $self = shift;
Subroutine set: called CC=15 SCAR=27.1
Pod undocumented
1123 4032 my $data = pop;
1124 4032 my @confs = ( $self->refConf, $self->newConf );
1125 4032 my @path;
1126 4032 ▶ while ( @_ > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 1) 312 4032 4344
1127 312 my $tmp = shift;
1128 312 push @path, $tmp;
1129 312 foreach my $i ( 0, 1 ) {
1130 624 ▶ my $v = ref($tmp) ? $tmp->[$i] : $tmp;
Branch: 1 branch
BranchTrueFalseTotal
ref $tmp ? : 168 456 624
1131 624 ▶ $confs[$i]->{$v} //= {};
Condition100%2/2
$confs[$i]{$v} //= {}
l!l
518106
MC/DC100%1/1
$confs[$i]{$v} //= {}
$confs[$i]{$v}
Truth table100%2/2
A
A= $confs[$i]{$v}
Aresult
11
00
1132 624 $confs[$i] = $confs[$i]->{$v};
1133 }
1134 }
1135 4032 my $target = shift;
1136 4032 hdebug( "# set() called:",
1137 { data => $data, path => \@path, target => $target } );
1138 4032 ▶ die @path unless ($target);
Branch: 1 branch
BranchTrueFalseTotal
unless $target 0 4032 4032
1139  
1140 # Check new value
1141 4032 ▶ if ( defined $data ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $data) { } 858 3174 4032
1142 858 hdebug(" data defined");
1143  
1144 # TODO: remove if $data == default value
1145 858 $confs[1]->{$target} = $data;
1146 858 eval {
1147 858 ▶ unless (
Branch: 1 branch
BranchTrueFalseTotal
unless ($target eq "cfgLog" or defined $confs[0]{$target} and $confs[0]{$target} eq $data or not defined $confs[0]{$target} and defined $self->defaultValue($target) and $data eq $self->defaultValue($target)) 55 803 858
Condition100%15/15
$target eq "cfgLog" or defined $confs[0]{$target} and $confs[0]{$target} eq $data or not defined $confs[0]{$target} and defined $self->defaultValue($target) and $data eq $self->defaultValue($target)
l!l&&r!l&&!r
39440955
$target eq "cfgLog" or defined $confs[0]{$target} and $confs[0]{$target} eq $data
l!l&&r!l&&!r
16378464
defined $confs[0]{$target} and $confs[0]{$target} eq $data
!ll&&!rl&&r
44420378
not defined $confs[0]{$target} and defined $self->defaultValue($target) and $data eq $self->defaultValue($target)
!ll&&!rl&&r
3916409
not defined $confs[0]{$target} and defined $self->defaultValue($target)
!ll&&!rl&&r
2019425
MC/DC83%5/6
$target eq "cfgLog" or defined $confs[0]{$target} and $confs[0]{$target} eq $data or not defined $confs[0]{$target} and defined $self->defaultValue($target) and $data eq $self->defaultValue($target)
$target eq "cfgLog" defined $confs[0]{$target} $confs[0]{$target} eq $data not defined $confs[0]{$target} defined $self->defaultValue($target) $data eq $self->defaultValue($target)
Truth table60%6/10
A or B and C or not(D) and E and F
A= $target eq "cfgLog"B= defined $confs[0]{$target}C= $confs[0]{$target} eq $dataD= not defined $confs[0]{$target}E= defined $self->defaultValue($target)F= $data eq $self->defaultValue($target)
ABCDEFresult
1XXXXX1
011XXX1
00X1111
0101111
00X0XX0
00X10X0
00X1100
0100XX0
01010X0
0101100
1148 $target eq 'cfgLog'
1149 or ( defined $confs[0]->{$target}
1150 and $confs[0]->{$target} eq $data )
1151 or ( !defined $confs[0]->{$target}
1152 and defined $self->defaultValue($target)
1153 and $data eq $self->defaultValue($target) )
1154 )
1155 {
1156 55 $self->confChanged(1);
1157 55 ▶ push @{ $self->changes },
Condition100%3/3
$confs[0]{$target} // $self->defaultValue($target)
l!l&&r!l&&!r
20431
MC/DC100%2/2
$confs[0]{$target} // $self->defaultValue($target)
$confs[0]{$target} $self->defaultValue($target)
Truth table100%3/3
A // B
A= $confs[0]{$target}B= $self->defaultValue($target)
ABresult
1X1
011
000
1158 {
1159 key => join( ', ', @path, $target ),
1160 old => $confs[0]->{$target} // $self->defaultValue($target),
1161 55 new => $confs[1]->{$target}
1162 };
1163 }
1164 };
1165 }
1166  
1167 # Set old value if exists
1168 else {
1169 3174 hdebug(" data undefined");
1170 3174 ▶ if ( exists $confs[0]->{$target} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $confs[0]{$target}) { } 950 2224 3174
1171 950 hdebug(" old value exists");
1172 950 $confs[1]->{$target} = $confs[0]->{$target};
1173 }
1174 else {
1175 2224 hdebug(" no old value, skipping");
1176 }
1177 }
1178 }
1179  
1180 sub defaultValue {
1181 1062 ▶ my ( $self, $target ) = @_;
Subroutine defaultValue: called CC=2 SCAR=7.0
Pod undocumented
1182 1062 hdebug("# defaultValue($target)");
1183 1062 ▶ die unless ($target);
Branch: 1 branch
BranchTrueFalseTotal
unless $target 0 1062 1062
1184 1062 my $res = eval {
1185 &Lemonldap::NG::Manager::Attributes::attributes()->{$target}
1186 1062 ->{'default'};
1187 };
1188 1062 return $res;
1189 }
1190  
1191 ##@method boolean testNewConf()
1192 # Launch _unitTest() and _globaTest()
1193 #
1194 #@return true if tests succeed
1195 sub testNewConf {
1196 50 ▶ my ( $self, $localConf ) = @_;
Subroutine testNewConf: called CC=2 SCAR=6.9
Pod undocumented
1197  
1198 50 hdebug('# testNewConf()');
1199 50 ▶ return $self->_unitTest( $self->newConf(), $localConf )
Condition100%3/3
$self->_unitTest($self->newConf, $localConf) && $self->_globalTest($localConf)
!ll&&!rl&&r
3146
MC/DC100%2/2
$self->_unitTest($self->newConf, $localConf) && $self->_globalTest($localConf)
$self->_unitTest($self->newConf, $localConf) $self->_globalTest($localConf)
Truth table100%3/3
A && B
A= $self->_unitTest($self->newConf, $localConf)B= $self->_globalTest($localConf)
ABresult
0X0
100
111
1200 && $self->_globalTest($localConf);
1201 }
1202  
1203 ##@method private boolean _unitTest()
1204 # Launch unit tests declared in Lemonldap::NG::Manager::Build::Attributes file
1205 #
1206 #@return true if tests succeed
1207 sub _unitTest {
1208 107 ▶ my ( $self, $conf, $localConf ) = @_;
Subroutine _unitTest: called CC=29 SCAR=35.2
1209 107 hdebug('# _unitTest()');
1210 107 my $types = &Lemonldap::NG::Manager::Attributes::types();
1211 107 my $attrs = &Lemonldap::NG::Manager::Attributes::attributes();
1212 107 my $res = 1;
1213  
1214 107 foreach my $key ( keys %$conf ) {
1215 11650 ▶ if ( $localConf
Branch: 1 branch
BranchTrueFalseTotal
if ($localConf and $localConf->{"skippedUnitTests"} and $localConf->{"skippedUnitTests"} =~ /\b$key\b/) 1 11649 11650
Condition83%5/6
$localConf and $localConf->{"skippedUnitTests"} and $localConf->{"skippedUnitTests"} =~ /\b$key\b/
!ll&&!rl&&r
249114001
$localConf and $localConf->{"skippedUnitTests"}
!ll&&!rl&&r
024911401
MC/DC66%2/3
$localConf and $localConf->{"skippedUnitTests"} and $localConf->{"skippedUnitTests"} =~ /\b$key\b/
$localConf $localConf->{"skippedUnitTests"} $localConf->{"skippedUnitTests"} =~ /\b$key\b/
Truth table75%3/4
A and B and C
A= $localConfB= $localConf->{"skippedUnitTests"}C= $localConf->{"skippedUnitTests"} =~ /\b$key\b/
ABCresult
0XX0
10X0
1100
1111
1216 and $localConf->{skippedUnitTests}
1217 and $localConf->{skippedUnitTests} =~ /\b$key\b/ )
1218 {
1219 1 $localConf->logger->debug("-> Ignore test for $key\n");
1220 1 next;
1221 }
1222 11649 hdebug("Testing $key");
1223 11649 my $attr = $attrs->{$key};
1224 11649 ▶ my $type = $types->{ $attr->{type} } if $attr;
Branch: 1 branch
BranchTrueFalseTotal
if $attr 11590 59 11649
1225 11649 ▶ unless ( $type or $attr->{test} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($type or $attr->{"test"}) 59 11590 11649
Condition100%3/3
$type or $attr->{"test"}
l!l&&r!l&&!r
1140418659
MC/DC100%2/2
$type or $attr->{"test"}
$type $attr->{"test"}
Truth table100%3/3
A or B
A= $typeB= $attr->{"test"}
ABresult
1X1
011
000
1226 59 ▶ $localConf->logger->debug("Unknown attribute $key, deleting it\n")
Branch: 1 branch
BranchTrueFalseTotal
if $localConf 59 0 59
1227 if $localConf;
1228 59 delete $conf->{$key};
1229 59 next;
1230 }
1231  
1232 # Vhost, CAS, SAML, OIDC options
1233 11590 ▶ if ( $key =~
Branch: 1 branch
BranchTrueFalseTotal
if ($key =~ /^(?^:(?:(?:(?:saml(?:ID|S)|oidc[OR])P|cas(?:App|Srv))MetaData|vhost)Options)$/) { } 103 11487 11590
1234 /^(?^:(?:(?:(?:saml(?:ID|S)|oidc[OR])P|cas(?:App|Srv))MetaData|vhost)Options)$/
1235 )
1236 {
1237  
1238 # Iterate on vhost names, or saml/cas/oidc configuration keys
1239 103 for my $vhost ( keys %{ $conf->{$key} } ) {
1240 57 my $options = $conf->{$key}->{$vhost};
1241 57 ▶ if ( ref($options) eq "HASH" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $options eq "HASH") 57 0 57
1242  
1243 # Recurse on option list,
1244 # FIXME this does check for oidcRPMetaDataOptionsXXX
1245 # appearing under samlSPMetadataOptions
1246 57 ▶ $res = 0
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_unitTest($options, $localConf, "$key/$vhost/") 2 55 57
1247 unless $self->_unitTest( $options, $localConf,
1248 "$key/$vhost/" );
1249 }
1250 }
1251 }
1252  
1253 else {
1254  
1255 # Check if key exists
1256 11487 ▶ unless ($attr) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($attr) 0 11487 11487
1257 0 push @{ $self->errors }, { message => "__unknownKey__: $key" };
1258 0 $res = 0;
1259 0 next;
1260 }
1261  
1262 # Hash parameters
1263 11487 ▶ if ( $key =~ /^$simpleHashKeys$/ ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($key =~ /^$Lemonldap::NG::Manager::Conf::Parser::simpleHashKeys$/) { } 946 10541 11487
elsif ($attr->{'type'} =~ /Container$/) { } 276 10265 10541
1264 946 ▶ $conf->{$key} //= {};
Condition100%2/2
$conf->{$key} //= {}
l!l
9424
MC/DC100%1/1
$conf->{$key} //= {}
$conf->{$key}
Truth table100%2/2
A
A= $conf->{$key}
Aresult
11
00
1265 946 ▶ unless ( ref $conf->{$key} eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $conf->{$key} eq "HASH") 0 946 946
1266 0 push @{ $self->errors },
1267 { message => "$key is not a hash ref" };
1268 0 $res = 0;
1269 0 next;
1270 }
1271 }
1272 elsif ( $attr->{type} =~ /Container$/ ) {
1273  
1274 #TODO
1275 }
1276 11487 ▶ if ( $key =~ /^(?:$simpleHashKeys|$doubleHashKeys)$/
Branch: 2 branches
BranchTrueFalseTotal
if ($key =~ /^(?:$Lemonldap::NG::Manager::Conf::Parser::simpleHashKeys|$Lemonldap::NG::Manager::Conf::Parser::doubleHashKeys)$/ or $attr->{'type'} =~ /Container$/) { } 1224 10263 11487
elsif (defined $attr->{'keyTest'}) { } 0 10263 10263
Condition100%3/3
$key =~ /^(?:$Lemonldap::NG::Manager::Conf::Parser::simpleHashKeys|$Lemonldap::NG::Manager::Conf::Parser::doubleHashKeys)$/ or $attr->{"type"} =~ /Container$/
l!l&&r!l&&!r
94827610263
MC/DC100%2/2
$key =~ /^(?:$Lemonldap::NG::Manager::Conf::Parser::simpleHashKeys|$Lemonldap::NG::Manager::Conf::Parser::doubleHashKeys)$/ or $attr->{"type"} =~ /Container$/
$key =~ /^(?:$Lemonldap::NG::Manager::Conf::Parser::simpleHashKeys|$Lemonldap::NG::Manager::Conf::Parser::doubleHashKeys)$/ $attr->{"type"} =~ /Container$/
Truth table100%3/3
A or B
A= $key =~ /^(?:$Lemonldap::NG::Manager::Conf::Parser::simpleHashKeys|$Lemonldap::NG::Manager::Conf::Parser::doubleHashKeys)$/B= $attr->{"type"} =~ /Container$/
ABresult
1X1
011
000
1277 or $attr->{type} =~ /Container$/ )
1278 {
1279 $res = 0
1280 unless (
1281 $self->_execTest( {
1282 keyTest => $attr->{keyTest} // $type->{keyTest},
1283 keyMsgFail => $attr->{keyMsgFail}
1284 // $type->{keyMsgFail},
1285 test => $attr->{test} // $type->{test},
1286 msgFail => $attr->{msgFail} // $type->{msgFail},
1287 },
1288 1224 ▶ $conf->{$key},
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_execTest({"keyTest", $attr->{"keyTest"} // $type->{"keyTest"}, "keyMsgFail", $attr->{"keyMsgFail"} // $type->{"keyMsgFail"}, "test", $attr->{"test"} // $type->{"test"}, "msgFail", $attr->{"msgFail"} // $type->{"msgFail"}}, $conf->{$key}, $key, $attr, undef, $conf) 0 1224 1224
Condition83%10/12
$attr->{"keyTest"} // $type->{"keyTest"}
l!l&&r!l&&!r
7195050
$attr->{"keyMsgFail"} // $type->{"keyMsgFail"}
l!l&&r!l&&!r
512582130
$attr->{"test"} // $type->{"test"}
l!l&&r!l&&!r
6745500
$attr->{"msgFail"} // $type->{"msgFail"}
l!l&&r!l&&!r
297713214
MC/DC0%0/2
$attr->{"keyTest"} // $type->{"keyTest"}
$attr->{"keyTest"} $type->{"keyTest"}
MC/DC100%2/2
$attr->{"keyMsgFail"} // $type->{"keyMsgFail"}
$attr->{"keyMsgFail"} $type->{"keyMsgFail"}
MC/DC0%0/2
$attr->{"test"} // $type->{"test"}
$attr->{"test"} $type->{"test"}
MC/DC100%2/2
$attr->{"msgFail"} // $type->{"msgFail"}
$attr->{"msgFail"} $type->{"msgFail"}
Truth table66%2/3
A // B
A= $attr->{"keyTest"}B= $type->{"keyTest"}
ABresult
1X1
011
000
Truth table100%3/3
A // B
A= $attr->{"keyMsgFail"}B= $type->{"keyMsgFail"}
ABresult
1X1
011
000
Truth table66%2/3
A // B
A= $attr->{"test"}B= $type->{"test"}
ABresult
1X1
011
000
Truth table100%3/3
A // B
A= $attr->{"msgFail"}B= $type->{"msgFail"}
ABresult
1X1
011
000
1289 $key, $attr, undef, $conf
1290 )
1291 );
1292 }
1293 elsif ( defined $attr->{keyTest} ) {
1294  
1295 #TODO
1296 }
1297 else {
1298 10263 ▶ my $msg = $attr->{msgFail} // $type->{msgFail};
Condition100%3/3
$attr->{"msgFail"} // $type->{"msgFail"}
l!l&&r!l&&!r
23485071522
MC/DC100%2/2
$attr->{"msgFail"} // $type->{"msgFail"}
$attr->{"msgFail"} $type->{"msgFail"}
Truth table100%3/3
A // B
A= $attr->{"msgFail"}B= $type->{"msgFail"}
ABresult
1X1
011
000
1299 $res = 0
1300 unless (
1301 $self->_execTest(
1302 $attr->{test} // $type->{test},
1303 10263 ▶ $conf->{$key}, $key, $attr, $msg, $conf
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_execTest($attr->{"test"} // $type->{"test"}, $conf->{$key}, $key, $attr, $msg, $conf) 3 10260 10263
Condition66%2/3
$attr->{"test"} // $type->{"test"}
l!l&&r!l&&!r
57796860
MC/DC0%0/2
$attr->{"test"} // $type->{"test"}
$attr->{"test"} $type->{"test"}
Truth table66%2/3
A // B
A= $attr->{"test"}B= $type->{"test"}
ABresult
1X1
011
000
1304 )
1305 );
1306 }
1307 }
1308 }
1309 107 return $res;
1310 }
1311  
1312 ##@method private boolean _execTest($test, $value)
1313 # Execute the given test with value
1314 #@param test that can be a code-ref, or a regexp
1315 #@return result of test
1316 sub _execTest {
1317 14837 ▶ my ( $self, $test, $value, $key, $attr, $msg, $conf ) = @_;
Subroutine _execTest: called CC=14 SCAR=28.6
1318 14837 my $ref;
1319 14837 ▶ die
Branch: 1 branch
BranchTrueFalseTotal
unless $ref = ref $test and $ref =~ /^(CODE|Regexp|HASH)$/ 0 14837 14837
Condition33%1/3
$ref = ref $test and $ref =~ /^(CODE|Regexp|HASH)$/
!ll&&!rl&&r
0014837
MC/DC0%0/2
$ref = ref $test and $ref =~ /^(CODE|Regexp|HASH)$/
$ref = ref $test $ref =~ /^(CODE|Regexp|HASH)$/
Truth table33%1/3
A and B
A= $ref = ref $testB= $ref =~ /^(CODE|Regexp|HASH)$/
ABresult
0X0
100
111
1320 "Malformed test for $key: only regexp ref or sub are accepted (type \"$ref\")"
1321 unless ( $ref = ref($test) and $ref =~ /^(CODE|Regexp|HASH)$/ );
1322 14837 ▶ if ( $ref eq 'CODE' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ref eq 'CODE') { } 6726 8111 14837
elsif ($ref eq 'Regexp') { } 6591 1520 8111
1323 6726 my ( $r, $m ) = ( $test->( $value, $conf, $attr ) );
1324 6726 ▶ if ($m) {
Branch: 2 branches
BranchTrueFalseTotal
if ($m) { } 2 6724 6726
elsif (not $r) { } 0 6724 6724
1325 push @{
1326 2 $self->{ (
1327 2 ▶ $r > 0
Branch: 2 branches
BranchTrueFalseTotal
$r > 0 ? : 2 0 2
$r < 0 ? : 0 0 0
1328 ? 'warnings'
1329 : ( $r < 0 ? 'needConfirmation' : 'errors' )
1330 )
1331 }
1332 },
1333 { message => "$key: $m" };
1334 }
1335 elsif ( !$r ) {
1336 0 push @{ $self->{errors} }, { message => "$key: $msg" };
1337 }
1338 6726 return $r;
1339 }
1340 elsif ( $ref eq 'Regexp' ) {
1341 6591 my $r = $value =~ $test;
1342 6591 ▶ push @{ $self->errors }, { message => "$key: $msg" } unless ($r);
Branch: 1 branch
BranchTrueFalseTotal
unless $r 3 6588 6591
1343 6591 return $r;
1344 }
1345  
1346 # Recursive test (for locationRules,...)
1347 else {
1348 1520 my $res = 1;
1349 1520 ▶ return $res unless ( ref($value) eq 'HASH' );
Branch: 1 branch
BranchTrueFalseTotal
unless ref $value eq "HASH" 53 1467 1520
1350 1467 foreach my $k ( keys %$value ) {
1351 $res = 0
1352 unless (
1353 $self->_execTest(
1354 $test->{keyTest}, $k, "$key/$k",
1355 $attr, $test->{keyMsgFail}, $conf
1356 )
1357 and $self->_execTest(
1358 $test->{test}, $value->{$k}, "$key/$k",
1359 1675 ▶ $attr, $test->{msgFail}, $conf
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_execTest($test->{"keyTest"}, $k, "$key/$k", $attr, $test->{"keyMsgFail"}, $conf) and $self->_execTest($test->{"test"}, $value->{$k}, "$key/$k", $attr, $test->{"msgFail"}, $conf) 0 1675 1675
Condition33%1/3
$self->_execTest($test->{"keyTest"}, $k, "$key/$k", $attr, $test->{"keyMsgFail"}, $conf) and $self->_execTest($test->{"test"}, $value->{$k}, "$key/$k", $attr, $test->{"msgFail"}, $conf)
!ll&&!rl&&r
001675
MC/DC0%0/2
$self->_execTest($test->{"keyTest"}, $k, "$key/$k", $attr, $test->{"keyMsgFail"}, $conf) and $self->_execTest($test->{"test"}, $value->{$k}, "$key/$k", $attr, $test->{"msgFail"}, $conf)
$self->_execTest($test->{"keyTest"}, $k, "$key/$k", $attr, $test->{"keyMsgFail"}, $conf) $self->_execTest($test->{"test"}, $value->{$k}, "$key/$k", $attr, $test->{"msgFail"}, $conf)
Truth table33%1/3
A and B
A= $self->_execTest($test->{"keyTest"}, $k, "$key/$k", $attr, $test->{"keyMsgFail"}, $conf)B= $self->_execTest($test->{"test"}, $value->{$k}, "$key/$k", $attr, $test->{"msgFail"}, $conf)
ABresult
0X0
100
111
1360 )
1361 );
1362 }
1363 1467 return $res;
1364 }
1365 }
1366  
1367 ##@method private boolean _globalTest()
1368 # Launch all tests declared in Lemonldap::NG::Manager::Conf::Tests::tests()
1369 #
1370 #@return true if tests succeed
1371 sub _globalTest {
1372 47 ▶ my ( $self, $localConf ) = @_;
Subroutine _globalTest: called CC=11 SCAR=24.5
1373  
1374 47 require Lemonldap::NG::Manager::Conf::Tests;
1375 47 hdebug('# _globalTest()');
1376 47 my $result = 1;
1377 47 my $tests = &Lemonldap::NG::Manager::Conf::Tests::tests( $self->newConf );
1378  
1379 47 foreach my $name ( keys %$tests ) {
1380 3807 ▶ if ( $localConf
Branch: 1 branch
BranchTrueFalseTotal
if ($localConf and $localConf->{"skippedGlobalTests"} and $localConf->{"skippedGlobalTests"} =~ /\b$name\b/) 138 3669 3807
Condition83%5/6
$localConf and $localConf->{"skippedGlobalTests"} and $localConf->{"skippedGlobalTests"} =~ /\b$name\b/
!ll&&!rl&&r
813588138
$localConf and $localConf->{"skippedGlobalTests"}
!ll&&!rl&&r
0813726
MC/DC66%2/3
$localConf and $localConf->{"skippedGlobalTests"} and $localConf->{"skippedGlobalTests"} =~ /\b$name\b/
$localConf $localConf->{"skippedGlobalTests"} $localConf->{"skippedGlobalTests"} =~ /\b$name\b/
Truth table75%3/4
A and B and C
A= $localConfB= $localConf->{"skippedGlobalTests"}C= $localConf->{"skippedGlobalTests"} =~ /\b$name\b/
ABCresult
0XX0
10X0
1100
1111
1381 and $localConf->{skippedGlobalTests}
1382 and $localConf->{skippedGlobalTests} =~ /\b$name\b/ )
1383 {
1384 138 ▶ $localConf->logger->debug("-> Ignore test for $name\n")
Branch: 1 branch
BranchTrueFalseTotal
if $localConf 138 0 138
1385 if $localConf;
1386 138 next;
1387 }
1388 3669 my $sub = $tests->{$name};
1389 3669 my ( $res, $msg );
1390 3669 eval {
1391 3669 ( $res, $msg ) = $sub->();
1392 3669 ▶ if ( $res == -1 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($res == -1) { } 2 3667 3669
elsif ($res) { } 3666 1 3667
1393 2 push @{ $self->needConfirmation }, { message => $msg };
1394 }
1395 elsif ($res) {
1396 3666 ▶ if ($msg) {
Branch: 1 branch
BranchTrueFalseTotal
if ($msg) 47 3619 3666
1397 47 push @{ $self->warnings }, { message => $msg };
1398 }
1399 }
1400 else {
1401 1 $result = 0;
1402 1 push @{ $self->errors }, { message => $msg };
1403 }
1404 };
1405 3669 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 3669 3669
1406 0 push @{ $self->warnings }, "Test $name failed: $@";
1407 0 ▶ $localConf->logger->debug("Test $name failed: $@\n") if $localConf;
Branch: 1 branch
BranchTrueFalseTotal
if $localConf 0 0 0
1408 }
1409 }
1410 47 return $result;
1411 }
1412  
1413 28 1;
1414 __END__
↑ Summary blib/lib/Lemonldap/NG/Manager/Sessions.pm »