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

filter: Statementstmt 65.7% 481 / 732 Branchbran 54.9% 199 / 362 Conditioncond 62.0% 103 / 166 MC/DCmcdc 44.2% 42 / 95 Subroutinesub 92.8% 26 / 28 Podpod 0.0% 0 / 6 totaltotal 61.2% 851 / 1389 CC 275 SCAR 78.6
CC
275
Cov
62%
_scanNodes
4158.6
_unitTest
33.8
scanTree
24.6
CRAP 2595.4
↑ 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.1';
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 0 ▶ trigger => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
47 0 hdebug( 'warnings contains', $_[0]->{warnings} );
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 0 ▶ default => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
56 0 return join( ', ', map { $_->{message} } @{ $_[0]->errors } );
57 },
58 3 ▶ trigger => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
59 3 hdebug( "Message becomes " . $_[0]->{message} );
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 116 ▶ trigger => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
71 116 hdebug( "condChanged: " . $_[0]->{confChanged} );
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 35318 ▶sub hdebug {
Subroutine hdebug: called CC=1 SCAR=0.0
Pod undocumented
83 35318 if (HIGHDEBUG) {
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 17 ▶sub check {
Subroutine check: called CC=9 SCAR=22.0
Pod undocumented
100 17 my ( $self, $localConf ) = @_;
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 922 ▶ @removedKeys = map { exists $compactedConf{$_} ? () : $_ } sort keys %conf
Branch: 1 branch
BranchTrueFalseTotal
exists $compactedConf{$_} ? : 723 199 922
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 16 ▶sub scanTree {
Subroutine scanTree: called CC=13 SCAR=32.0
Pod undocumented
141 16 my $self = shift;
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 16 0 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 0 ▶ 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 1541 ▶sub _scanNodes {
Subroutine _scanNodes: called CC=188 SCAR=83.3
182 1541 my ( $self, $tree, ) = @_;
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 57 0 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: 3 branches
BranchTrueFalseTotal
if ($target eq 'oidcRPMetaDataOptionsExtraClaims') { } 0 0 0
elsif ($target eq 'oidcOPMetaDataOptionsAuthEndpointExtraParams') { } 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 eq
508 'oidcOPMetaDataOptionsAuthEndpointExtraParams' )
509 {
510 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
511 0 hdebug(' unopened');
512 $self->newConf->{$optKey}->{$key}->{$target} =
513 0 ▶ $self->refConf->{$optKey}->{$oldName}->{$target}
Condition0%0/2
$self->refConf->{$optKey}{$oldName}{$target} // {}
l!l
00
MC/DC0%0/1
$self->refConf->{$optKey}{$oldName}{$target} // {}
$self->refConf->{$optKey}{$oldName}{$target}
Truth table0%0/2
A
A= $self->refConf->{$optKey}{$oldName}{$target}
Aresult
11
00
514 // {};
515 }
516 elsif ($h) {
517 0 hdebug(' opened');
518 $self->set( $optKey, [ $oldName, $key ],
519 0 $target, $leaf->{title}, $leaf->{data} );
520 }
521 elsif ( !@$subNodes ) {
522 0 hdebug(" $target: no subnodes");
523 0 $self->confChanged(1);
524 }
525 else {
526 0 hdebug(" $target: scanning subnodes");
527 my @oldKeys =
528 0 keys %{ $self->refConf->{$optKey}->{$oldName}
529 0 ->{$target} };
530 0 $self->_scanNodes($subNodes);
531 my @newKeys = keys
532 0 %{ $self->newConf->{$optKey}->{$key}->{$target} };
533  
534 # Detect deleted nodes
535 0 my %seen = map { $_ => 1 } @newKeys;
536 0 my @deleted = grep { !$seen{$_} } @oldKeys;
537 0 ▶ $self->confChanged(1) if @deleted;
Branch: 1 branch
BranchTrueFalseTotal
if @deleted 0 0 0
538 }
539 }
540 elsif ( $target =~
541 /^(?:$oidcOPMetaDataNodeKeys|$oidcRPMetaDataNodeKeys)/ )
542 {
543 $self->set(
544 $optKey, [ $oldName, $key ],
545 $target, $leaf->{data}
546 0 );
547 }
548 else {
549 0 push @{ $self->errors },
550 { message => "Unknown OIDC metadata option $target" };
551 0 return 0;
552 }
553 }
554 else {
555 0 push @{ $self->errors },
556 { message => "Unknown OIDC key $target" };
557 0 return 0;
558 }
559 0 next;
560 }
561  
562 # CAS
563 elsif ( $base =~ /^cas(?:App|Srv)MetaDataNodes$/ ) {
564 0 my $optKey = $&;
565 0 hdebug('CAS');
566 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
567 0 hdebug(" $target: looking for subnodes");
568 0 $self->_scanNodes($subNodes);
569 0 $self->set( $target, $key, $leaf->{title}, $leaf->{data} );
570 }
571 elsif ( $target =~
572 /^cas(?:App|Srv)MetaData(?:ExportedVars|Macros)$/ )
573 {
574 0 hdebug(" $target");
575 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
576 0 hdebug(' unopened');
577 $self->newConf->{$target}->{$key} =
578 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
579 }
580 elsif ($h) {
581 0 hdebug(' opened');
582 0 $self->confChanged(1);
583 $self->set( $target, $key, $leaf->{title},
584 0 $leaf->{data} );
585 }
586 elsif ( !@$subNodes ) {
587 0 hdebug(" $target: no subnodes");
588 0 $self->confChanged(1);
589 }
590 else {
591 0 hdebug(" $target: scanning subnodes");
592 0 $self->_scanNodes($subNodes);
593 }
594 }
595 elsif ( $target =~ /^cas(?:Srv|App)MetaDataOptions/ ) {
596 0 my $optKey = $&;
597 0 hdebug " $base sub key: $target";
598 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
599 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
600 0 hdebug(' unopened');
601 $self->newConf->{$target}->{$key} =
602 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
603 }
604 elsif ($h) {
605 0 hdebug(' opened');
606 $self->set( $target, $key, $leaf->{title},
607 0 $leaf->{data} );
608 }
609 elsif ( !@$subNodes ) {
610 0 hdebug(" $target: no subnodes");
611 0 $self->confChanged(1);
612 }
613 else {
614 0 hdebug(" $target: scanning subnodes");
615 0 $self->_scanNodes($subNodes);
616 }
617 }
618 elsif ( $target =~
619 /^(?:$casSrvMetaDataNodeKeys|$casAppMetaDataNodeKeys)/ )
620 {
621 $self->set(
622 $optKey, [ $oldName, $key ],
623 $target, $leaf->{data}
624 0 );
625 }
626 else {
627 0 push @{ $self->errors },
628 { message => "Unknown CAS metadata option $target" };
629 0 return 0;
630 }
631 }
632 else {
633 0 push @{ $self->errors },
634 { message => "Unknown CAS option $target" };
635 0 return 0;
636 }
637 0 next;
638 }
639 elsif ( $base eq 'keyNodes' ) {
640 15 hdebug('Keys');
641 15 hdebug("target $target");
642 15 hdebug("key $key");
643 15 ▶ if ( $target eq "KeyMaterial" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target eq 'KeyMaterial') { } 5 10 15
644 5 ▶ if ( $leaf->{data} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($leaf->{'data'}) { } 3 2 5
645 3 hdebug(' opened');
646 3 for my $data ( @{ $leaf->{data} } ) {
647 $self->set( "keys", $key, $data->{title},
648 9 $data->{data} );
649 }
650 }
651 else {
652 2 hdebug(' unopened');
653 2 for my $opt (qw/keyPrivate keyPrivatePwd keyPublic/) {
654 6 $self->set( "keys", $key, $opt, undef );
655 }
656 }
657 }
658 else {
659 10 $self->set( "keys", $key, $leaf->{title}, $leaf->{data} );
660 }
661 15 next;
662 }
663 else {
664 0 push @{ $self->errors },
665 { message => "Fatal: unknown special sub node $base" };
666 0 return 0;
667 }
668 }
669  
670 ####################
671 # Application list #
672 ####################
673  
674 # Application list root node
675 elsif ( $leaf->{title} eq 'applicationList' ) {
676 16 hdebug( $leaf->{title} );
677 16 ▶ if ( $leaf->{cnodes} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($leaf->{'cnodes'}) { } 10 6 16
678 10 hdebug(' unopened');
679 $self->newConf->{applicationList} =
680 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
681 }
682 else {
683 6 ▶ $self->_scanNodes($subNodes) or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->_scanNodes($subNodes) or return 0 6 0 6
684  
685 # Check for deleted
686 my @listCatRef =
687 18 map { $self->refConf->{applicationList}->{$_}->{catname} }
688 6 keys %{ $self->refConf->{applicationList} };
689 my @listCatNew =
690 17 map { $self->newConf->{applicationList}->{$_}->{catname} }
691 keys(
692 %{
693 6 ref $self->newConf->{applicationList}
694 ? $self->newConf->{applicationList}
695 : {}
696 6 ▶ }
Branch: 1 branch
BranchTrueFalseTotal
ref $self->newConf->{'applicationList'} ? : 6 0 6
697 );
698  
699 6 ▶ @listCatRef = map { $_ ? $_ : () } @listCatRef;
Branch: 1 branch
BranchTrueFalseTotal
$_ ? : 18 0 18
700 6 ▶ @listCatNew = map { $_ ? $_ : () } @listCatNew;
Branch: 1 branch
BranchTrueFalseTotal
$_ ? : 17 0 17
701 6 @listCatRef = sort @listCatRef;
702 6 @listCatNew = sort @listCatNew;
703 6 hdebug( '# @listCatRef : ', \@listCatRef );
704 6 hdebug( '# @listCatNew : ', \@listCatNew );
705  
706 # Check for deleted
707 my @diff =
708 6 grep !${ { map { $_, 1 } @listCatNew } }{$_}, @listCatRef;
709 6 ▶ if ( scalar @diff ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @diff) 1 5 6
710 1 $self->confChanged(1);
711 1 push @{ $self->changes },
712 {
713 new => join( ', ', 'categoryList', @listCatNew ),
714 key => join( ', ', 'Deletes in cat(s)', @diff ),
715 old => join( ', ', 'categoryList', @listCatRef ),
716 };
717 }
718 }
719 16 next;
720 }
721  
722 # Application list sub nodes
723 elsif ( $leaf->{id} =~ /^applicationList\/(.+)$/ ) {
724 60 hdebug('Application list subnode');
725 28 ▶ use feature 'state';
Subroutine BEGIN: called CC=1 SCAR=0.0
726 60 my @cats = split /\//, $1;
727 60 my $app = pop @cats;
728 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
729  
730 # $cn is a pointer to the parent
731 60 my $cn = $self->newConf->{applicationList};
732 60 my $cmp = $self->refConf->{applicationList};
733 60 my @path;
734  
735 # Makes $cn point to the parent
736 60 foreach my $cat (@cats) {
737 43 hdebug(" looking to cat $cat");
738 43 ▶ unless ( defined $knownCat->{$cat} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $knownCat->{$cat}) 0 43 43
739 0 push @{ $self->{errors} },
740 { message =>
741 "Fatal: sub cat/app before parent ($leaf->{id})" };
742 0 return 0;
743 }
744 43 $cn = $cn->{ $knownCat->{$cat} };
745 43 push @path, $cn->{catname};
746 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
747 43 $cmp = $cmp->{$cat};
748 }
749  
750 60 my $newapp = $app;
751  
752 # Compute a nice name for new nodes, taking care of potential conflicts
753 # For some reason, the manager sends /nNaN sometimes
754 60 ▶ if ( $newapp =~ /^n(\d+|NaN)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($newapp =~ /^n(\d+|NaN)$/) 3 57 60
755  
756 # Remove all special characters
757 3 my $baseName = $leaf->{title} =~ s/\W//gr;
758 3 $baseName = lc $baseName;
759 3 $newapp = $baseName;
760 3 my $cnt = 1;
761 3 ▶ while ( exists $cn->{$newapp} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $cn->{$newapp}) 0 3 3
762 0 $newapp = "${baseName}_" . $cnt++;
763 }
764 }
765  
766 # Create new category
767 #
768 # Note that this works because nodes are ordered so "cat/cat2/app"
769 # is looked after "cat" and "cat/cat2"
770 60 ▶ if ( $leaf->{type} eq 'menuCat' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($leaf->{"type"} eq "menuCat") 17 43 60
771 17 hdebug(' menu cat');
772 17 $knownCat->{__id}++;
773 17 $knownCat->{$app} = $newapp;
774 $cn->{$newapp} = {
775 catname => $leaf->{title},
776 type => 'category',
777 order => $knownCat->{__id}
778 17 };
779 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
780 and $cmp->{$app}->{catname} eq $cn->{$newapp}->{catname} )
781 {
782 0 $self->confChanged(1);
783 0 ▶ push @{ $self->changes },
Branch: 1 branch
BranchTrueFalseTotal
$cn->{$newapp} ? : 0 0 0
784 {
785 key => join(
786 ', ', 'applicationList', @path, $leaf->{title}
787 ),
788 new => $cn->{$newapp}->{catname},
789 old => (
790 $cn->{$newapp} ? $cn->{$newapp}->{catname} : undef
791 )
792 0 };
793 }
794 17 ▶ if ( ref $subNodes ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $subNodes) 17 0 17
795 17 ▶ $self->_scanNodes($subNodes) or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->_scanNodes($subNodes) or return 0 17 0 17
796 }
797 17 my @listCatRef = keys %{ $cmp->{$app} };
798 17 my @listCatNew = keys %{ $cn->{$newapp} };
799  
800 # Check for deleted
801 17 ▶ unless ( @listCatRef == @listCatNew ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@listCatRef == @listCatNew) 3 14 17
802 3 $self->confChanged(1);
803 3 push @{ $self->changes },
804 {
805 key => join( ', ', 'applicationList', @path ),
806 new => 'Changes in cat(s)/app(s)',
807 };
808 }
809 }
810  
811 # Create new apps
812 60 ▶ if ( $leaf->{type} eq 'menuApp' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($leaf->{"type"} eq "menuApp") 43 17 60
813 43 hdebug(' new app');
814 43 $knownCat->{__id}++;
815 $cn->{$newapp} = {
816 type => 'application',
817 options => $leaf->{data},
818 order => $knownCat->{__id}
819 43 };
820 43 $cn->{$newapp}->{options}->{name} = $leaf->{title};
821 43 ▶ unless ( $cmp->{$app} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmp->{$app}) { } 40 3 43
822 3 $self->confChanged(1);
823 3 push @{ $self->changes },
824 {
825 key => join( ', ', 'applicationList', @path ),
826 new => $leaf->{title},
827 3 };
828 }
829 else {
830 # Check for change in ordering
831 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
832 ( $cmp->{$newapp}->{order} || 0 ) )
833 {
834 22 $self->confChanged(1);
835 }
836  
837 # Check for change in options
838 40 foreach my $k ( keys %{ $cn->{$newapp}->{options} } ) {
839 200 ▶ unless ( $cmp->{$app}->{options}->{$k} eq
Branch: 1 branch
BranchTrueFalseTotal
unless ($cmp->{$app}{"options"}{$k} eq $cn->{$newapp}{"options"}{$k}) 3 197 200
840 $cn->{$newapp}->{options}->{$k} )
841 {
842 3 $self->confChanged(1);
843 3 push @{ $self->changes },
844 {
845 key => join( ', ',
846 'applicationList', @path,
847 $leaf->{title}, $k ),
848 new => $cn->{$newapp}->{options}->{$k},
849 3 old => $cmp->{$app}->{options}->{$k}
850 };
851 }
852 }
853 }
854 }
855 60 next;
856 }
857 elsif ( $leaf->{id} eq 'grantSessionRules' ) {
858 16 hdebug('grantSessionRules');
859 16 ▶ if ( $leaf->{cnodes} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($leaf->{'cnodes'}) { } 10 6 16
860 10 hdebug(' unopened');
861 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
862 }
863 else {
864 6 hdebug(' opened');
865 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
866 6 my $count = 0;
867 6 my $ref = $self->refConf->{grantSessionRules};
868 6 my $new = $self->newConf->{grantSessionRules};
869 6 ▶ my @old = ref $ref ? keys %$ref : ();
Branch: 1 branch
BranchTrueFalseTotal
ref $ref ? : 6 0 6
870 6 $self->newConf->{grantSessionRules} = {};
871 6 foreach my $n (@$subNodes) {
872 0 hdebug(" looking at $n subnode");
873 my $k =
874 0 ▶ $n->{re} . ( $n->{comment} ? "##$n->{comment}" : '' );
Branch: 1 branch
BranchTrueFalseTotal
$n->{'comment'} ? : 0 0 0
875 0 $self->newConf->{grantSessionRules}->{$k} = $n->{data};
876 0 $count++;
877 0 ▶ unless ( defined $ref->{$k} ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $ref->{$k}) { } 0 0 0
if (do { $ref->{$k} ne $n->{"data"} }) 0 0 0
878 0 $self->confChanged(1);
879 0 push @{ $self->changes },
880 { keys => 'grantSessionRules', new => $k };
881 }
882 0 elsif ( $ref->{$k} ne $n->{data} ) {
883 0 $self->confChanged(1);
884 0 push @{ $self->changes },
885 {
886 key => "grantSessionRules, $k",
887 old => $self->refConf->{grantSessionRules}->{$k},
888 new => $n->{data}
889 0 };
890 }
891 0 @old = grep { $_ ne $k } @old;
892 }
893 6 ▶ if (@old) {
Branch: 1 branch
BranchTrueFalseTotal
if (@old) 0 6 6
894 0 $self->confChanged(1);
895 0 push @{ $self->changes },
896 { key => 'grantSessionRules', old => $_, }
897 0 foreach (@old);
898 }
899 }
900 16 next;
901 }
902  
903 # openIdIDPList: data is splitted by Conf.pm into a boolean and a
904 # string
905 elsif ( $name eq 'openIdIDPList' ) {
906 16 hdebug('openIdIDPList');
907 16 ▶ if ( $leaf->{data} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($leaf->{'data'}) { } 0 16 16
908 0 ▶ unless ( ref $leaf->{data} eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $leaf->{"data"} eq "ARRAY") 0 0 0
909 0 push @{ $self->{errors} },
910 0 { message => 'Malformed openIdIDPList ' . $leaf->{data} };
911 0 return 0;
912 }
913 0 $self->set( $name, join( ';', @{ $leaf->{data} } ) );
914 }
915 else {
916 16 $self->set( $name, undef );
917 }
918 16 next;
919 }
920  
921 ####################
922 # Other hash nodes #
923 ####################
924 ▶ 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
925 and not $leaf->{title} eq 'applicationList' )
926 {
927 366 hdebug( $leaf->{title} );
928  
929 # If a `cnodes` key is found, keep old key unchanges
930 366 ▶ if ( $leaf->{cnodes} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($leaf->{'cnodes'}) { } 286 80 366
931 286 hdebug(' unopened');
932 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
933 }
934 else {
935 80 hdebug(' opened');
936  
937 # combModules: just to replace "over" key
938 80 ▶ if ( $name eq 'combModules' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "combModules") 1 79 80
939 1 hdebug(' combModules');
940 1 $self->newConf->{$name} = {};
941 1 foreach my $node ( @{ $leaf->{nodes} } ) {
942 2 my $tmp;
943 2 $tmp->{$_} = $node->{data}->{$_} foreach (qw(type for));
944 2 $tmp->{over} = {};
945 2 foreach ( @{ $node->{data}->{over} } ) {
946 0 $tmp->{over}->{ $_->[0] } = $_->[1];
947 }
948 2 $self->newConf->{$name}->{ $node->{title} } = $tmp;
949 }
950  
951 # TODO: check changes
952 1 $self->confChanged(1);
953 1 next;
954 }
955  
956 # sfExtra: just to replace "over" key
957 79 ▶ if ( $name eq 'sfExtra' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "sfExtra") 1 78 79
958 1 hdebug(' sfExtra');
959 1 $self->newConf->{$name} = {};
960 1 foreach my $node ( @{ $leaf->{nodes} } ) {
961 2 my $tmp;
962 $tmp->{$_} = $node->{data}->{$_}
963 2 foreach (qw(type rule logo level label regrule));
964 2 ▶ $tmp->{register} = $node->{data}->{register} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$node->{'data'}{'register'} ? : 0 2 2
965 2 $tmp->{over} = {};
966 2 foreach ( @{ $node->{data}->{over} } ) {
967 3 $tmp->{over}->{ $_->[0] } = $_->[1];
968 }
969 2 $self->newConf->{$name}->{ $node->{title} } = $tmp;
970 }
971  
972 # TODO: check changes
973 1 $self->confChanged(1);
974 1 next;
975 }
976  
977 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
978 78 my $count = 0;
979 my @old = (
980 ref( $self->refConf->{$name} )
981 78 ▶ ? ( keys %{ $self->refConf->{$name} } )
Branch: 1 branch
BranchTrueFalseTotal
ref $self->refConf->{$name} ? : 60 18 78
982 : ()
983 );
984 78 $self->newConf->{$name} = {};
985 78 foreach my $n (@$subNodes) {
986 61 hdebug(" looking at $n subnode");
987 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
988  
989 # authChoiceModules
990 0 ▶ if ( $name eq 'authChoiceModules' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "authChoiceModules") 0 0 0
991 0 hdebug(' authChoiceModules');
992 0 ▶ if ( ref( $n->{data}->[5] ) eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $n->{'data'}[5] eq 'ARRAY') { } 0 0 0
993 $n->{data}->[5] =
994 0 to_json( { map { @$_ } @{ $n->{data}->[5] } },
995 { canonical => 1 } );
996 }
997 else {
998 0 $n->{data}->[5] = '{}';
999 }
1000 }
1001  
1002 0 $n->{data} = join ';', @{ $n->{data} };
1003 }
1004 61 $self->newConf->{$name}->{ $n->{title} } = $n->{data};
1005 61 $count++;
1006 61 ▶ unless ( defined $self->refConf->{$name}->{ $n->{title} } )
Branch: 2 branches
BranchTrueFalseTotal
if (defined $self->refConf->{$name}{$n->{'title'}}) { } 58 3 61
if (do { $self->refConf->{$name}{$n->{"title"}} ne $n->{"data"} }) 1 57 58
1007 {
1008 3 $self->confChanged(1);
1009 3 push @{ $self->changes },
1010 3 { key => $name, new => $n->{title}, };
1011 }
1012 0 elsif (
1013 $self->refConf->{$name}->{ $n->{title} } ne $n->{data} )
1014 {
1015 1 $self->confChanged(1);
1016 1 push @{ $self->changes },
1017 {
1018 key => "$name, $n->{title}",
1019 old => $self->refConf->{$name}->{ $n->{title} },
1020 new => $n->{data}
1021 1 };
1022 }
1023 61 @old = grep { $_ ne $n->{title} } @old;
1024 }
1025 78 ▶ if (@old) {
Branch: 1 branch
BranchTrueFalseTotal
if (@old) 2 76 78
1026 2 $self->confChanged(1);
1027 2 push @{ $self->changes }, { key => $name, old => $_, }
1028 2 foreach (@old);
1029 }
1030 }
1031 364 next;
1032 }
1033  
1034 # Double hash nodes
1035 elsif ( $leaf->{title} =~ /^$doubleHashKeys$/ ) {
1036 2 hdebug( $leaf->{title} );
1037 my @oldHosts = (
1038 ref( $self->refConf->{$name} )
1039 0 ▶ ? ( keys %{ $self->refConf->{$name} } )
Branch: 1 branch
BranchTrueFalseTotal
ref $self->refConf->{$name} ? : 0 2 2
1040 : ()
1041 );
1042 2 $self->newConf->{$name} = {};
1043 2 ▶ unless ( defined $leaf->{data} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $leaf->{"data"}) 2 0 2
1044 2 hdebug(' unopened');
1045 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
1046 2 next;
1047 }
1048 0 foreach my $getHost ( @{ $leaf->{data} } ) {
1049 0 my $change = 0;
1050 0 my @oldKeys;
1051 0 my $host = $getHost->{k};
1052 0 hdebug(" looking at host: $host");
1053 0 $self->newConf->{$name}->{$host} = {};
1054 0 ▶ unless ( defined $self->refConf->{$name}->{$host} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->refConf->{$name}{$host}) { } 0 0 0
1055 0 $self->confChanged(1);
1056 0 $change++;
1057 0 push @{ $self->changes }, { key => $name, new => $host };
1058 0 hdebug(" $host is new");
1059 }
1060 else {
1061 0 @oldHosts = grep { $_ ne $host } @oldHosts;
1062 0 @oldKeys = keys %{ $self->refConf->{$name}->{$host} };
1063 }
1064 0 foreach my $prm ( @{ $getHost->{h} } ) {
1065 $self->newConf->{$name}->{$host}->{ $prm->{k} } =
1066 0 $prm->{v};
1067 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
1068 !$change
1069 and (
1070 not defined(
1071 $self->refConf->{$name}->{$host}->{ $prm->{k} }
1072 )
1073 or $self->newConf->{$name}->{$host}->{ $prm->{k} }
1074 ne $self->refConf->{$name}->{$host}->{ $prm->{k} }
1075 )
1076 )
1077 {
1078 0 $self->confChanged(1);
1079 0 hdebug(" key $prm->{k} has been changed");
1080 0 push @{ $self->changes },
1081 0 { key => "$name/$host", new => $prm->{k} };
1082 }
1083 elsif ( !$change ) {
1084 0 @oldKeys = grep { $_ ne $prm->{k} } @oldKeys;
1085 }
1086 }
1087 0 ▶ if (@oldKeys) {
Branch: 1 branch
BranchTrueFalseTotal
if (@oldKeys) 0 0 0
1088 0 $self->confChanged(1);
1089 0 hdebug( " old keys: " . join( ' ', @oldKeys ) );
1090 0 push @{ $self->changes },
1091 { key => "$name/$host", old => $_ }
1092 0 foreach (@oldKeys);
1093 }
1094 }
1095 0 ▶ if (@oldHosts) {
Branch: 1 branch
BranchTrueFalseTotal
if (@oldHosts) 0 0 0
1096 0 $self->confChanged(1);
1097 0 hdebug( " old hosts " . join( ' ', @oldHosts ) );
1098 0 push @{ $self->changes }, { key => "$name", old => $_ }
1099 0 foreach (@oldHosts);
1100 }
1101 0 next;
1102 }
1103  
1104 ###############
1105 # Other nodes #
1106 ###############
1107  
1108 # Check if subnodes
1109 5230 my $n = 0;
1110 5230 ▶ if ( ref $subNodesCond ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $subNodesCond) 16 5214 5230
1111 16 hdebug(' conditional subnodes detected');
1112  
1113 # Bad idea,subnode unopened are not read
1114 #$subNodesCond = [ grep { $_->{show} } @$subNodesCond ];
1115 16 ▶ $self->_scanNodes($subNodesCond) or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->_scanNodes($subNodesCond) or return 0 16 0 16
1116 16 $n++;
1117 }
1118 5230 ▶ if ( ref $subNodes ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $subNodes) 1380 3850 5230
1119 1380 hdebug(' subnodes detected');
1120 1380 ▶ $self->_scanNodes($subNodes) or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->_scanNodes($subNodes) or return 0 1380 0 1380
1121 1380 $n++;
1122 }
1123 5230 ▶ if ($n) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n) 1380 3850 5230
1124 1380 next;
1125 }
1126 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
1127 87 ▶ if ( ref( $leaf->{data}->[0] ) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $leaf->{'data'}[0] eq 'HASH') { } 0 87 87
1128 0 hdebug(" array found");
1129 0 ▶ $self->_scanNodes( $leaf->{data} ) or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->_scanNodes($leaf->{"data"}) or return 0 0 0 0
1130 }
1131 else {
1132 87 $self->set( $name, join( ';', @{ $leaf->{data} } ) );
1133 }
1134 }
1135  
1136 # Grouped nodes not opened
1137 ▶ 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
1138 6 hdebug(" unopened grouped node");
1139 6 foreach my $subkey ( @{ $leaf->{get} } ) {
1140 16 $self->set( $subkey, undef );
1141 }
1142 }
1143  
1144 # Normal leaf
1145 else {
1146 3757 $self->set( $name, $leaf->{data} );
1147 }
1148 }
1149 1541 return 1;
1150 }
1151  
1152 ##@method private void set($target, @path, $data)
1153 # Store a value in the $target key (following subkeys if @path is set)
1154 4032 ▶sub set {
Subroutine set: called CC=15 SCAR=27.1
Pod undocumented
1155 4032 my $self = shift;
1156 4032 my $data = pop;
1157 4032 my @confs = ( $self->refConf, $self->newConf );
1158 4032 my @path;
1159 4032 ▶ while ( @_ > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 1) 312 4032 4344
1160 312 my $tmp = shift;
1161 312 push @path, $tmp;
1162 312 foreach my $i ( 0, 1 ) {
1163 624 ▶ my $v = ref($tmp) ? $tmp->[$i] : $tmp;
Branch: 1 branch
BranchTrueFalseTotal
ref $tmp ? : 168 456 624
1164 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
1165 624 $confs[$i] = $confs[$i]->{$v};
1166 }
1167 }
1168 4032 my $target = shift;
1169 4032 hdebug( "# set() called:",
1170 { data => $data, path => \@path, target => $target } );
1171 4032 ▶ die @path unless ($target);
Branch: 1 branch
BranchTrueFalseTotal
unless $target 0 4032 4032
1172  
1173 # Check new value
1174 4032 ▶ if ( defined $data ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $data) { } 858 3174 4032
1175 858 hdebug(" data defined");
1176  
1177 # TODO: remove if $data == default value
1178 858 $confs[1]->{$target} = $data;
1179 858 eval {
1180 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
1181 $target eq 'cfgLog'
1182 or ( defined $confs[0]->{$target}
1183 and $confs[0]->{$target} eq $data )
1184 or ( !defined $confs[0]->{$target}
1185 and defined $self->defaultValue($target)
1186 and $data eq $self->defaultValue($target) )
1187 )
1188 {
1189 55 $self->confChanged(1);
1190 55 ▶ push @{ $self->changes },
Condition100%3/3
$confs[0]{$target} // $self->defaultValue($target)
l!l&&r!l&&!r
201619
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
1191 {
1192 key => join( ', ', @path, $target ),
1193 old => $confs[0]->{$target} // $self->defaultValue($target),
1194 55 new => $confs[1]->{$target}
1195 };
1196 }
1197 };
1198 }
1199  
1200 # Set old value if exists
1201 else {
1202 3174 hdebug(" data undefined");
1203 3174 ▶ if ( exists $confs[0]->{$target} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $confs[0]{$target}) { } 950 2224 3174
1204 950 hdebug(" old value exists");
1205 950 $confs[1]->{$target} = $confs[0]->{$target};
1206 }
1207 else {
1208 2224 hdebug(" no old value, skipping");
1209 }
1210 }
1211 }
1212  
1213 1062 ▶sub defaultValue {
Subroutine defaultValue: called CC=2 SCAR=7.0
Pod undocumented
1214 1062 my ( $self, $target ) = @_;
1215 1062 hdebug("# defaultValue($target)");
1216 1062 ▶ die unless ($target);
Branch: 1 branch
BranchTrueFalseTotal
unless $target 0 1062 1062
1217 1062 my $res = eval {
1218 &Lemonldap::NG::Manager::Attributes::attributes()->{$target}
1219 1062 ->{'default'};
1220 };
1221 1062 return $res;
1222 }
1223  
1224 ##@method boolean testNewConf()
1225 # Launch _unitTest() and _globaTest()
1226 #
1227 #@return true if tests succeed
1228 50 ▶sub testNewConf {
Subroutine testNewConf: called CC=2 SCAR=6.9
Pod undocumented
1229 50 my ( $self, $localConf ) = @_;
1230  
1231 50 hdebug('# testNewConf()');
1232 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
1233 && $self->_globalTest($localConf);
1234 }
1235  
1236 ##@method private boolean _unitTest()
1237 # Launch unit tests declared in Lemonldap::NG::Manager::Build::Attributes file
1238 #
1239 #@return true if tests succeed
1240 107 ▶sub _unitTest {
Subroutine _unitTest: called CC=29 SCAR=35.2
1241 107 my ( $self, $conf, $localConf ) = @_;
1242 107 hdebug('# _unitTest()');
1243 107 my $types = &Lemonldap::NG::Manager::Attributes::types();
1244 107 my $attrs = &Lemonldap::NG::Manager::Attributes::attributes();
1245 107 my $res = 1;
1246  
1247 107 foreach my $key ( keys %$conf ) {
1248 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
1249 and $localConf->{skippedUnitTests}
1250 and $localConf->{skippedUnitTests} =~ /\b$key\b/ )
1251 {
1252 1 $localConf->logger->debug("-> Ignore test for $key\n");
1253 1 next;
1254 }
1255 11649 hdebug("Testing $key");
1256 11649 my $attr = $attrs->{$key};
1257 11649 ▶ my $type = $types->{ $attr->{type} } if $attr;
Branch: 1 branch
BranchTrueFalseTotal
if $attr 11624 25 11649
1258 11649 ▶ unless ( $type or $attr->{test} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($type or $attr->{"test"}) 25 11624 11649
Condition100%3/3
$type or $attr->{"test"}
l!l&&r!l&&!r
1143818625
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
1259 25 ▶ $localConf->logger->debug("Unknown attribute $key, deleting it\n")
Branch: 1 branch
BranchTrueFalseTotal
if $localConf 25 0 25
1260 if $localConf;
1261 25 delete $conf->{$key};
1262 25 next;
1263 }
1264  
1265 # Vhost, CAS, SAML, OIDC options
1266 11624 ▶ if ( $key =~
Branch: 1 branch
BranchTrueFalseTotal
if ($key =~ /^(?^:(?:(?:(?:saml(?:ID|S)|oidc[OR])P|cas(?:App|Srv))MetaData|vhost)Options)$/) { } 103 11521 11624
1267 /^(?^:(?:(?:(?:saml(?:ID|S)|oidc[OR])P|cas(?:App|Srv))MetaData|vhost)Options)$/
1268 )
1269 {
1270  
1271 # Iterate on vhost names, or saml/cas/oidc configuration keys
1272 103 for my $vhost ( keys %{ $conf->{$key} } ) {
1273 57 my $options = $conf->{$key}->{$vhost};
1274 57 ▶ if ( ref($options) eq "HASH" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $options eq "HASH") 57 0 57
1275  
1276 # Recurse on option list,
1277 # FIXME this does check for oidcRPMetaDataOptionsXXX
1278 # appearing under samlSPMetadataOptions
1279 57 ▶ $res = 0
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_unitTest($options, $localConf, "$key/$vhost/") 2 55 57
1280 unless $self->_unitTest( $options, $localConf,
1281 "$key/$vhost/" );
1282 }
1283 }
1284 }
1285  
1286 else {
1287  
1288 # Check if key exists
1289 11521 ▶ unless ($attr) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($attr) 0 11521 11521
1290 0 push @{ $self->errors }, { message => "__unknownKey__: $key" };
1291 0 $res = 0;
1292 0 next;
1293 }
1294  
1295 # Hash parameters
1296 11521 ▶ if ( $key =~ /^$simpleHashKeys$/ ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($key =~ /^$Lemonldap::NG::Manager::Conf::Parser::simpleHashKeys$/) { } 946 10575 11521
elsif ($attr->{'type'} =~ /Container$/) { } 276 10299 10575
1297 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
1298 946 ▶ unless ( ref $conf->{$key} eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $conf->{$key} eq "HASH") 0 946 946
1299 0 push @{ $self->errors },
1300 { message => "$key is not a hash ref" };
1301 0 $res = 0;
1302 0 next;
1303 }
1304 }
1305 elsif ( $attr->{type} =~ /Container$/ ) {
1306  
1307 #TODO
1308 }
1309 11521 ▶ 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 10297 11521
elsif (defined $attr->{'keyTest'}) { } 0 10297 10297
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
94827610297
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
1310 or $attr->{type} =~ /Container$/ )
1311 {
1312 $res = 0
1313 unless (
1314 $self->_execTest( {
1315 keyTest => $attr->{keyTest} // $type->{keyTest},
1316 keyMsgFail => $attr->{keyMsgFail}
1317 // $type->{keyMsgFail},
1318 test => $attr->{test} // $type->{test},
1319 msgFail => $attr->{msgFail} // $type->{msgFail},
1320 },
1321 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
7185060
$attr->{"keyMsgFail"} // $type->{"keyMsgFail"}
l!l&&r!l&&!r
511583130
$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
1322 $key, $attr, undef, $conf
1323 )
1324 );
1325 }
1326 elsif ( defined $attr->{keyTest} ) {
1327  
1328 #TODO
1329 }
1330 else {
1331 10297 ▶ my $msg = $attr->{msgFail} // $type->{msgFail};
Condition100%3/3
$attr->{"msgFail"} // $type->{"msgFail"}
l!l&&r!l&&!r
23485411522
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
1332 $res = 0
1333 unless (
1334 $self->_execTest(
1335 $attr->{test} // $type->{test},
1336 10297 ▶ $conf->{$key}, $key, $attr, $msg, $conf
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_execTest($attr->{"test"} // $type->{"test"}, $conf->{$key}, $key, $attr, $msg, $conf) 3 10294 10297
Condition66%2/3
$attr->{"test"} // $type->{"test"}
l!l&&r!l&&!r
61196860
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
1337 )
1338 );
1339 }
1340 }
1341 }
1342 107 return $res;
1343 }
1344  
1345 ##@method private boolean _execTest($test, $value)
1346 # Execute the given test with value
1347 #@param test that can be a code-ref, or a regexp
1348 #@return result of test
1349 14871 ▶sub _execTest {
Subroutine _execTest: called CC=14 SCAR=28.6
1350 14871 my ( $self, $test, $value, $key, $attr, $msg, $conf ) = @_;
1351 14871 my $ref;
1352 14871 ▶ die
Branch: 1 branch
BranchTrueFalseTotal
unless $ref = ref $test and $ref =~ /^(CODE|Regexp|HASH)$/ 0 14871 14871
Condition33%1/3
$ref = ref $test and $ref =~ /^(CODE|Regexp|HASH)$/
!ll&&!rl&&r
0014871
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
1353 "Malformed test for $key: only regexp ref or sub are accepted (type \"$ref\")"
1354 unless ( $ref = ref($test) and $ref =~ /^(CODE|Regexp|HASH)$/ );
1355 14871 ▶ if ( $ref eq 'CODE' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ref eq 'CODE') { } 6726 8145 14871
elsif ($ref eq 'Regexp') { } 6625 1520 8145
1356 6726 my ( $r, $m ) = ( $test->( $value, $conf, $attr ) );
1357 6726 ▶ if ($m) {
Branch: 2 branches
BranchTrueFalseTotal
if ($m) { } 2 6724 6726
elsif (not $r) { } 0 6724 6724
1358 push @{
1359 2 $self->{ (
1360 2 ▶ $r > 0
Branch: 2 branches
BranchTrueFalseTotal
$r > 0 ? : 2 0 2
$r < 0 ? : 0 0 0
1361 ? 'warnings'
1362 : ( $r < 0 ? 'needConfirmation' : 'errors' )
1363 )
1364 }
1365 },
1366 { message => "$key: $m" };
1367 }
1368 elsif ( !$r ) {
1369 0 push @{ $self->{errors} }, { message => "$key: $msg" };
1370 }
1371 6726 return $r;
1372 }
1373 elsif ( $ref eq 'Regexp' ) {
1374 6625 my $r = $value =~ $test;
1375 6625 ▶ push @{ $self->errors }, { message => "$key: $msg" } unless ($r);
Branch: 1 branch
BranchTrueFalseTotal
unless $r 3 6622 6625
1376 6625 return $r;
1377 }
1378  
1379 # Recursive test (for locationRules,...)
1380 else {
1381 1520 my $res = 1;
1382 1520 ▶ return $res unless ( ref($value) eq 'HASH' );
Branch: 1 branch
BranchTrueFalseTotal
unless ref $value eq "HASH" 53 1467 1520
1383 1467 foreach my $k ( keys %$value ) {
1384 $res = 0
1385 unless (
1386 $self->_execTest(
1387 $test->{keyTest}, $k, "$key/$k",
1388 $attr, $test->{keyMsgFail}, $conf
1389 )
1390 and $self->_execTest(
1391 $test->{test}, $value->{$k}, "$key/$k",
1392 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
1393 )
1394 );
1395 }
1396 1467 return $res;
1397 }
1398 }
1399  
1400 ##@method private boolean _globalTest()
1401 # Launch all tests declared in Lemonldap::NG::Manager::Conf::Tests::tests()
1402 #
1403 #@return true if tests succeed
1404 47 ▶sub _globalTest {
Subroutine _globalTest: called CC=11 SCAR=24.5
1405 47 my ( $self, $localConf ) = @_;
1406  
1407 47 require Lemonldap::NG::Manager::Conf::Tests;
1408 47 hdebug('# _globalTest()');
1409 47 my $result = 1;
1410 47 my $tests = &Lemonldap::NG::Manager::Conf::Tests::tests( $self->newConf );
1411  
1412 47 foreach my $name ( keys %$tests ) {
1413 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
1414 and $localConf->{skippedGlobalTests}
1415 and $localConf->{skippedGlobalTests} =~ /\b$name\b/ )
1416 {
1417 138 ▶ $localConf->logger->debug("-> Ignore test for $name\n")
Branch: 1 branch
BranchTrueFalseTotal
if $localConf 138 0 138
1418 if $localConf;
1419 138 next;
1420 }
1421 3669 my $sub = $tests->{$name};
1422 3669 my ( $res, $msg );
1423 3669 eval {
1424 3669 ( $res, $msg ) = $sub->();
1425 3669 ▶ if ( $res == -1 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($res == -1) { } 2 3667 3669
elsif ($res) { } 3666 1 3667
1426 2 push @{ $self->needConfirmation }, { message => $msg };
1427 }
1428 elsif ($res) {
1429 3666 ▶ if ($msg) {
Branch: 1 branch
BranchTrueFalseTotal
if ($msg) 47 3619 3666
1430 47 push @{ $self->warnings }, { message => $msg };
1431 }
1432 }
1433 else {
1434 1 $result = 0;
1435 1 push @{ $self->errors }, { message => $msg };
1436 }
1437 };
1438 3669 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 3669 3669
1439 0 push @{ $self->warnings }, "Test $name failed: $@";
1440 0 ▶ $localConf->logger->debug("Test $name failed: $@\n") if $localConf;
Branch: 1 branch
BranchTrueFalseTotal
if $localConf 0 0 0
1441 }
1442 }
1443 47 return $result;
1444 }
1445  
1446 28 1;
1447 __END__
↑ Summary blib/lib/Lemonldap/NG/Manager/Sessions.pm »