Branch Coverage

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


line true false branch
255 0 4 unless seek $fh, 0, 0
256 0 4 unless open my $bak, '>', "$path.bak"
258 0 4 unless close $bak
304 38 57 if ($args{'_lock'})
317 37 58 if ($args{'_read_shadow'} or $args{'_write_shadow'})
318 18 19 $args{'_write_shadow'} ? :
2 35 unless (open $fhs, ($args{'_write_shadow'} ? '+' : '') . '<', "$etc/shadow")
320 2 0 if ($args{'_read_shadow'} == 2 and not $args{'_write_shadow'}) { }
328 0 178 unless /\S/
332 168 10 if ($wfn)
345 47 48 if ($args{'_read_passwd'} or $args{'_write_passwd'})
346 18 29 $args{'_write_passwd'} ? :
1 46 unless open $fhp, ($args{'_write_passwd'} ? '+' : '') . '<', "$etc/passwd"
350 0 255 unless /\S/
353 158 97 if ($wfn)
356 157 1 if $shadow{$r[0]}
360 56 199 if ($args{'_after_read_passwd_entry'})
362 0 56 if $res->[0] != 200
363 9 47 if $stash{'exit'}
373 56 29 if ($args{'_read_gshadow'} or $args{'_write_gshadow'})
374 30 26 $args{'_write_gshadow'} ? :
2 54 unless (open $fhgs, ($args{'_write_gshadow'} ? '+' : '') . '<', "$etc/gshadow")
376 2 0 if ($args{'_read_gshadow'} == 2 and not $args{'_write_gshadow'}) { }
384 0 330 unless /\S/
388 318 12 if ($wfn)
401 70 15 if ($args{'_read_group'} or $args{'_write_group'})
402 33 37 $args{'_write_group'} ? :
1 69 unless open $fhg, ($args{'_write_group'} ? '+' : '') . '<', "$etc/group"
407 0 465 unless /\S/
410 320 145 if ($wfn)
413 301 19 if $gshadow{$r[0]}
417 106 359 if ($args{'_after_read_group_entry'})
419 0 106 if $res->[0] != 200
420 16 90 if $stash{'exit'}
425 68 0 if ($args{'_after_read'})
427 21 47 if $res->[0] != 200
428 19 28 if $stash{'exit'}
433 12 1 if ($args{'_write_shadow'} and $stash{'write_shadow'} // 1)
434 1 11 if ($args{'backup'})
436 0 1 if $res->[0] != 200
438 0 12 unless seek $fhs, 0, 0
443 0 12 unless close $fhs
447 12 1 if ($args{'_write_passwd'} and $stash{'write_passwd'} // 1)
448 1 11 if ($args{'backup'})
450 0 1 if $res->[0] != 200
452 0 12 unless seek $fhp, 0, 0
457 0 12 unless close $fhp
461 21 1 if ($args{'_write_gshadow'} and $stash{'write_gshadow'} // 1)
462 1 20 if ($args{'backup'})
464 0 1 if $res->[0] != 200
466 0 21 unless seek $fhgs, 0, 0
471 0 21 unless close $fhgs
475 23 2 if ($args{'_write_group'} and $stash{'write_group'} // 1)
476 1 22 if ($args{'backup'})
478 0 1 if $res->[0] != 200
480 0 23 unless seek $fhg, 0, 0
485 0 23 unless close $fhg
491 0 95 if $@
496 23 72 if $e and $e->[0] != 200
497 23 72 if $e and $e->[0] != 200
529 1 2 $detail ? :
544 10 10 if (not $detail) { }
5 5 elsif ($wfn) { }
554 2 2 if $detail
559 2 2 $detail ? :
603 1 15 unless defined $user xor defined $uid
619 9 47 if (defined $user and $passwd->[-1][0] eq $user or defined $uid and $passwd->[-1][2] == $uid)
621 9 0 $wfn ? :
658 1 1 if ($res->[0] == 404) { }
1 0 elsif ($res->[0] == 200) { }
689 1 3 $detail ? :
704 18 12 if (not $detail) { }
6 6 elsif ($wfn) { }
714 2 3 if $detail
718 2 3 $detail ? :
762 1 22 unless defined $gn xor defined $gid
778 16 90 if (defined $gn and $group->[-1][0] eq $gn or defined $gid and $group->[-1][2] == $gid)
780 16 0 $wfn ? :
817 1 2 $detail ? :
833 10 10 if (not $detail) { }
5 5 elsif ($wfn) { }
846 12 12 if (not $detail) { }
6 6 elsif ($wfn) { }
860 2 2 $detail ? :
2 2 $detail ? :
888 1 1 if ($res->[0] == 404) { }
1 0 elsif ($res->[0] == 200) { }
927 0 5 unless my $user = $args{'user'}
929 0 5 $detail ? :
942 1 4 unless &first(sub { $_->[0] eq $user; } , @$passwd)
950 14 10 unless $user ~~ \@mm or $group->[$i][0] eq $user
951 10 0 if (not $detail) { }
0 0 elsif ($wfn) { }
965 0 5 $detail ? :
993 1 5 unless my $user = $args{'user'}
994 1 4 unless my $group = $args{'group'}
996 1 3 unless $res->[0] == 200
998 2 1 $user ~~ \@mm ? :
1066 18 9 if ($which eq 'user')
1067 1 17 unless $user = $args{'user'}
1068 1 16 unless $user =~ /$re_user/o
1071 2 14 if $gn ne $user
1074 1 24 unless $gn
1075 1 23 unless $gn =~ /$re_group/o
1079 0 23 if $min_gid < 0
1080 0 23 if $max_gid > 65535
1082 7 16 if ($which eq 'group') { }
1084 0 7 if ($members and ref $members eq 'ARRAY')
1088 1 6 unless $members =~ /$re_field/o
1098 16 6 if ($which eq 'user')
1100 0 16 if $min_uid < 0
1101 0 16 if $min_uid > 65535
1104 0 16 unless ($pass =~ /$re_field/o)
1107 1 15 unless ($gecos =~ /$re_field/o)
1110 1 14 unless ($home =~ /$re_field/o)
1113 1 13 unless ($shell =~ /$re_field/o)
1115 11 1 $pass eq '' ? :
1116 1 12 unless ($encpass =~ /$re_field/o)
1123 1 11 unless ($pass_inactive_period =~ /$re_field/o)
1126 1 10 unless ($expire_date =~ /$re_field/o)
1145 1 15 if ($which eq 'group' and $cur_g) { }
2 13 elsif ($cur_g) { }
1 12 elsif (not $create_group) { }
1146 1 0 if $cur_g
1153 10 2 unless (defined $gid)
1155 9 19 unless ($_ ~~ \@gids)
1157 1 9 unless defined $gid
1166 9 4 if ($which eq 'user')
1170 1 8 if &first(sub { $_->[0] eq $user; } , @$passwd)
1172 6 2 unless (defined $uid)
1174 5 10 unless ($_ ~~ \@uids)
1176 1 5 unless defined $uid
1187 39 7 unless $l->[0] eq $gn
1189 1 6 unless ($user ~~ \@mm)
1197 0 11 unless $write_g
1342 19 16 if ($which eq 'user') { }
1343 1 18 unless $user = $args{'user'}
1345 3 13 unless $gn = $args{'group'}
1348 18 13 if ($which eq 'user')
1349 1 17 if (defined $args{'uid'} and not $args{'uid'} =~ /$re_posint/o)
1351 1 16 if (defined $args{'gid'} and not $args{'gid'} =~ /$re_posint/o)
1353 1 15 if (defined $args{'gecos'} and not $args{'gecos'} =~ /$re_field/o)
1355 1 14 if (defined $args{'home'} and not $args{'home'} =~ /$re_field/o)
1357 1 13 if (defined $args{'shell'} and not $args{'shell'} =~ /$re_field/o)
1359 2 11 if (defined $args{'pass'})
1360 0 2 $args{'pass'} eq '' ? :
1363 2 11 if (defined $args{'encpass'} and not $args{'encpass'} =~ /$re_field/o)
1365 1 10 if (defined $args{'last_pwchange'} and not $args{'last_pwchange'} =~ /$re_posint/o)
1367 1 9 if (defined $args{'min_pass_age'} and not $args{'min_pass_age'} =~ /$re_posint/o)
1369 1 8 if (defined $args{'max_pass_age'} and not $args{'max_pass_age'} =~ /$re_posint/o)
1371 1 7 if (defined $args{'pass_warn_period'} and not $args{'pass_warn_period'} =~ /$re_posint/o)
1373 1 6 if (defined $args{'pass_inactive_period'} and not $args{'pass_inactive_period'} =~ /$re_posint/o)
1376 1 5 if (defined $args{'expire_date'} and not $args{'expire_date'} =~ /$re_posint/o)
1381 13 5 if ($which eq 'group')
1382 1 12 if (defined $args{'gid'} and not $args{'gid'} =~ /$re_posint/o)
1384 0 12 if (defined $args{'pass'})
1385 0 0 $args{'pass'} eq '' ? :
1388 1 11 if (defined $args{'encpass'} and not $args{'encpass'} =~ /$re_field/o)
1390 2 9 if (defined $args{'members'})
1391 0 2 if (ref $args{'members'} eq 'ARRAY')
1392 1 1 unless $args{'members'} =~ /$re_field/o
1394 2 8 if (defined $args{'admins'})
1395 0 2 if (ref $args{'admins'} eq 'ARRAY')
1396 1 1 unless $args{'admins'} =~ /$re_field/o
1411 5 9 if ($which eq 'user') { }
1414 19 3 unless $l->[0] eq $user
1417 6 12 if (defined $args{$f})
1425 2 3 unless $found
1426 1 2 unless $changed
1431 9 3 unless $l->[0] eq $user
1434 8 13 if (defined $args{$f})
1442 1 2 unless $changed
1446 46 6 unless $l->[0] eq $gn
1449 12 6 if ($args{'_before_set_group_field'})
1452 6 12 if (defined $args{$f})
1460 3 6 unless $found
1461 1 5 unless $changed
1466 28 6 unless $l->[0] eq $gn
1468 7 11 if (defined $args{$f})
1476 1 5 unless $changed
1562 2 4 unless my $user = $args{'user'}
1563 0 4 unless $user =~ /$re_user/o
1572 0 6 unless $l->[0] eq $gn
1574 0 6 if $user ~~ \@mm
1603 2 4 unless my $user = $args{'user'}
1604 0 4 unless $user =~ /$re_user/o
1613 0 6 unless $l->[0] eq $gn
1615 0 6 unless $user ~~ \@mm
1664 0 2 unless my $user = $args{'user'}
1665 0 2 unless $user =~ /$re_user/o
1683 2 10 if ($l->[0] ~~ $add and not $user ~~ \@mm)
1687 1 11 if ($l->[0] ~~ $del and $user ~~ \@mm)
1691 5 7 if ($changed)
1695 1 1 unless $changed
1730 0 1 unless my $user = $args{'user'}
1731 0 1 unless $user =~ /$re_user/o
1732 0 1 unless my $gg = $args{'groups'}
1748 2 4 if ($l->[0] ~~ $gg and not $user ~~ \@mm)
1752 1 5 if (not $l->[0] ~~ $gg and $user ~~ \@mm)
1756 5 1 if ($changed)
1760 0 1 unless $changed
1789 0 3 unless $args{'user'}
1790 1 2 unless defined $args{'pass'}
1799 3 2 if ($which eq 'user')
1800 0 3 unless $user = $args{'user'}
1804 0 5 unless $gn
1820 20 14 if ($which eq 'user')
1823 4 16 if ($user ~~ \@mm)
1828 5 29 if ($group->[$i][0] eq $gn)
1834 0 5 unless $changed
1839 19 14 if ($which eq 'user')
1842 2 17 if ($user ~~ \@mm)
1847 5 28 if ($gshadow->[$i][0] eq $gn)
1854 0 5 unless $changed
1856 3 2 if ($which eq 'user')
1860 3 13 if ($passwd->[$i][0] eq $user)
1867 0 3 unless $changed
1872 3 13 if ($shadow->[$i][0] eq $user)
1879 0 3 unless $changed