Branch Coverage

blib/lib/Unix/Passwd/File.pm
Criterion Covered Total %
branch 370 438 84.4


line true false branch
251 0 4 unless seek $fh, 0, 0
252 0 4 unless open my $bak, '>', "$path.bak"
254 0 4 unless close $bak
300 38 57 if ($args{'_lock'})
313 37 58 if ($args{'_read_shadow'} or $args{'_write_shadow'})
314 18 19 $args{'_write_shadow'} ? :
2 35 unless (open $fhs, ($args{'_write_shadow'} ? '+' : '') . '<', "$etc/shadow")
316 2 0 if ($args{'_read_shadow'} == 2 and not $args{'_write_shadow'}) { }
324 0 178 unless /\S/
328 168 10 if ($wfn)
341 47 48 if ($args{'_read_passwd'} or $args{'_write_passwd'})
342 18 29 $args{'_write_passwd'} ? :
1 46 unless open $fhp, ($args{'_write_passwd'} ? '+' : '') . '<', "$etc/passwd"
346 0 255 unless /\S/
349 158 97 if ($wfn)
352 157 1 if $shadow{$r[0]}
356 56 199 if ($args{'_after_read_passwd_entry'})
358 0 56 if $res->[0] != 200
359 9 47 if $stash{'exit'}
369 56 29 if ($args{'_read_gshadow'} or $args{'_write_gshadow'})
370 30 26 $args{'_write_gshadow'} ? :
2 54 unless (open $fhgs, ($args{'_write_gshadow'} ? '+' : '') . '<', "$etc/gshadow")
372 2 0 if ($args{'_read_gshadow'} == 2 and not $args{'_write_gshadow'}) { }
380 0 330 unless /\S/
384 318 12 if ($wfn)
397 70 15 if ($args{'_read_group'} or $args{'_write_group'})
398 33 37 $args{'_write_group'} ? :
1 69 unless open $fhg, ($args{'_write_group'} ? '+' : '') . '<', "$etc/group"
403 0 465 unless /\S/
406 320 145 if ($wfn)
409 301 19 if $gshadow{$r[0]}
413 106 359 if ($args{'_after_read_group_entry'})
415 0 106 if $res->[0] != 200
416 16 90 if $stash{'exit'}
421 68 0 if ($args{'_after_read'})
423 21 47 if $res->[0] != 200
424 19 28 if $stash{'exit'}
429 12 1 if ($args{'_write_shadow'} and $stash{'write_shadow'} // 1)
430 1 11 if ($args{'backup'})
432 0 1 if $res->[0] != 200
434 0 12 unless seek $fhs, 0, 0
439 0 12 unless close $fhs
443 12 1 if ($args{'_write_passwd'} and $stash{'write_passwd'} // 1)
444 1 11 if ($args{'backup'})
446 0 1 if $res->[0] != 200
448 0 12 unless seek $fhp, 0, 0
453 0 12 unless close $fhp
457 21 1 if ($args{'_write_gshadow'} and $stash{'write_gshadow'} // 1)
458 1 20 if ($args{'backup'})
460 0 1 if $res->[0] != 200
462 0 21 unless seek $fhgs, 0, 0
467 0 21 unless close $fhgs
471 23 2 if ($args{'_write_group'} and $stash{'write_group'} // 1)
472 1 22 if ($args{'backup'})
474 0 1 if $res->[0] != 200
476 0 23 unless seek $fhg, 0, 0
481 0 23 unless close $fhg
487 0 95 if $@
492 23 72 if $e and $e->[0] != 200
493 23 72 if $e and $e->[0] != 200
525 1 2 $detail ? :
540 10 10 if (not $detail) { }
5 5 elsif ($wfn) { }
550 2 2 if $detail
555 2 2 $detail ? :
597 1 15 unless defined $user xor defined $uid
613 9 47 if (defined $user and $passwd->[-1][0] eq $user or defined $uid and $passwd->[-1][2] == $uid)
615 9 0 $wfn ? :
650 1 1 if ($res->[0] == 404) { }
1 0 elsif ($res->[0] == 200) { }
681 1 3 $detail ? :
696 18 12 if (not $detail) { }
6 6 elsif ($wfn) { }
706 2 3 if $detail
710 2 3 $detail ? :
752 1 22 unless defined $gn xor defined $gid
768 16 90 if (defined $gn and $group->[-1][0] eq $gn or defined $gid and $group->[-1][2] == $gid)
770 16 0 $wfn ? :
807 1 2 $detail ? :
823 10 10 if (not $detail) { }
5 5 elsif ($wfn) { }
836 12 12 if (not $detail) { }
6 6 elsif ($wfn) { }
850 2 2 $detail ? :
2 2 $detail ? :
876 1 1 if ($res->[0] == 404) { }
1 0 elsif ($res->[0] == 200) { }
914 0 5 unless my $user = $args{'user'}
916 0 5 $detail ? :
929 1 4 unless &first(sub { $_->[0] eq $user; } , @$passwd)
937 14 10 unless $user ~~ \@mm or $group->[$i][0] eq $user
938 10 0 if (not $detail) { }
0 0 elsif ($wfn) { }
952 0 5 $detail ? :
978 1 5 unless my $user = $args{'user'}
979 1 4 unless my $group = $args{'group'}
981 1 3 unless $res->[0] == 200
983 2 1 $user ~~ \@mm ? :
1051 18 9 if ($which eq 'user')
1052 1 17 unless $user = $args{'user'}
1053 1 16 unless $user =~ /$re_user/o
1056 2 14 if $gn ne $user
1059 1 24 unless $gn
1060 1 23 unless $gn =~ /$re_group/o
1064 0 23 if $min_gid < 0
1065 0 23 if $max_gid > 65535
1067 7 16 if ($which eq 'group') { }
1069 0 7 if ($members and ref $members eq 'ARRAY')
1073 1 6 unless $members =~ /$re_field/o
1083 16 6 if ($which eq 'user')
1085 0 16 if $min_uid < 0
1086 0 16 if $min_uid > 65535
1089 0 16 unless ($pass =~ /$re_field/o)
1092 1 15 unless ($gecos =~ /$re_field/o)
1095 1 14 unless ($home =~ /$re_field/o)
1098 1 13 unless ($shell =~ /$re_field/o)
1100 11 1 $pass eq '' ? :
1101 1 12 unless ($encpass =~ /$re_field/o)
1108 1 11 unless ($pass_inactive_period =~ /$re_field/o)
1111 1 10 unless ($expire_date =~ /$re_field/o)
1130 1 15 if ($which eq 'group' and $cur_g) { }
2 13 elsif ($cur_g) { }
1 12 elsif (not $create_group) { }
1131 1 0 if $cur_g
1138 10 2 unless (defined $gid)
1140 9 19 unless ($_ ~~ \@gids)
1142 1 9 unless defined $gid
1151 9 4 if ($which eq 'user')
1155 1 8 if &first(sub { $_->[0] eq $user; } , @$passwd)
1157 6 2 unless (defined $uid)
1159 5 10 unless ($_ ~~ \@uids)
1161 1 5 unless defined $uid
1172 39 7 unless $l->[0] eq $gn
1174 1 6 unless ($user ~~ \@mm)
1182 0 11 unless $write_g
1323 19 16 if ($which eq 'user') { }
1324 1 18 unless $user = $args{'user'}
1326 3 13 unless $gn = $args{'group'}
1329 18 13 if ($which eq 'user')
1330 1 17 if (defined $args{'uid'} and not $args{'uid'} =~ /$re_posint/o)
1332 1 16 if (defined $args{'gid'} and not $args{'gid'} =~ /$re_posint/o)
1334 1 15 if (defined $args{'gecos'} and not $args{'gecos'} =~ /$re_field/o)
1336 1 14 if (defined $args{'home'} and not $args{'home'} =~ /$re_field/o)
1338 1 13 if (defined $args{'shell'} and not $args{'shell'} =~ /$re_field/o)
1340 2 11 if (defined $args{'pass'})
1341 0 2 $args{'pass'} eq '' ? :
1344 2 11 if (defined $args{'encpass'} and not $args{'encpass'} =~ /$re_field/o)
1346 1 10 if (defined $args{'last_pwchange'} and not $args{'last_pwchange'} =~ /$re_posint/o)
1348 1 9 if (defined $args{'min_pass_age'} and not $args{'min_pass_age'} =~ /$re_posint/o)
1350 1 8 if (defined $args{'max_pass_age'} and not $args{'max_pass_age'} =~ /$re_posint/o)
1352 1 7 if (defined $args{'pass_warn_period'} and not $args{'pass_warn_period'} =~ /$re_posint/o)
1354 1 6 if (defined $args{'pass_inactive_period'} and not $args{'pass_inactive_period'} =~ /$re_posint/o)
1357 1 5 if (defined $args{'expire_date'} and not $args{'expire_date'} =~ /$re_posint/o)
1362 13 5 if ($which eq 'group')
1363 1 12 if (defined $args{'gid'} and not $args{'gid'} =~ /$re_posint/o)
1365 0 12 if (defined $args{'pass'})
1366 0 0 $args{'pass'} eq '' ? :
1369 1 11 if (defined $args{'encpass'} and not $args{'encpass'} =~ /$re_field/o)
1371 2 9 if (defined $args{'members'})
1372 0 2 if (ref $args{'members'} eq 'ARRAY')
1373 1 1 unless $args{'members'} =~ /$re_field/o
1375 2 8 if (defined $args{'admins'})
1376 0 2 if (ref $args{'admins'} eq 'ARRAY')
1377 1 1 unless $args{'admins'} =~ /$re_field/o
1392 5 9 if ($which eq 'user') { }
1395 19 3 unless $l->[0] eq $user
1398 6 12 if (defined $args{$f})
1406 2 3 unless $found
1407 1 2 unless $changed
1412 9 3 unless $l->[0] eq $user
1415 8 13 if (defined $args{$f})
1423 1 2 unless $changed
1427 46 6 unless $l->[0] eq $gn
1430 12 6 if ($args{'_before_set_group_field'})
1433 6 12 if (defined $args{$f})
1441 3 6 unless $found
1442 1 5 unless $changed
1447 28 6 unless $l->[0] eq $gn
1449 7 11 if (defined $args{$f})
1457 1 5 unless $changed
1541 2 4 unless my $user = $args{'user'}
1542 0 4 unless $user =~ /$re_user/o
1551 0 6 unless $l->[0] eq $gn
1553 0 6 if $user ~~ \@mm
1580 2 4 unless my $user = $args{'user'}
1581 0 4 unless $user =~ /$re_user/o
1590 0 6 unless $l->[0] eq $gn
1592 0 6 unless $user ~~ \@mm
1638 0 2 unless my $user = $args{'user'}
1639 0 2 unless $user =~ /$re_user/o
1657 2 10 if ($l->[0] ~~ $add and not $user ~~ \@mm)
1661 1 11 if ($l->[0] ~~ $del and $user ~~ \@mm)
1665 5 7 if ($changed)
1669 1 1 unless $changed
1702 0 1 unless my $user = $args{'user'}
1703 0 1 unless $user =~ /$re_user/o
1704 0 1 unless my $gg = $args{'groups'}
1720 2 4 if ($l->[0] ~~ $gg and not $user ~~ \@mm)
1724 1 5 if (not $l->[0] ~~ $gg and $user ~~ \@mm)
1728 5 1 if ($changed)
1732 0 1 unless $changed
1760 0 3 unless $args{'user'}
1761 1 2 unless defined $args{'pass'}
1770 3 2 if ($which eq 'user')
1771 0 3 unless $user = $args{'user'}
1775 0 5 unless $gn
1791 20 14 if ($which eq 'user')
1794 4 16 if ($user ~~ \@mm)
1799 5 29 if ($group->[$i][0] eq $gn)
1805 0 5 unless $changed
1810 19 14 if ($which eq 'user')
1813 2 17 if ($user ~~ \@mm)
1818 5 28 if ($gshadow->[$i][0] eq $gn)
1825 0 5 unless $changed
1827 3 2 if ($which eq 'user')
1831 3 13 if ($passwd->[$i][0] eq $user)
1838 0 3 unless $changed
1843 3 13 if ($shadow->[$i][0] eq $user)
1850 0 3 unless $changed