Branch Coverage

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


line true false branch
257 0 4 unless seek $fh, 0, 0
258 0 4 unless open my $bak, '>', "$path.bak"
260 0 4 unless close $bak
306 38 57 if ($args{'_lock'})
319 37 58 if ($args{'_read_shadow'} or $args{'_write_shadow'})
320 18 19 $args{'_write_shadow'} ? :
2 35 unless (open $fhs, ($args{'_write_shadow'} ? '+' : '') . '<', "$etc/shadow")
322 2 0 if ($args{'_read_shadow'} == 2 and not $args{'_write_shadow'}) { }
330 0 178 unless /\S/
334 168 10 if ($wfn)
347 47 48 if ($args{'_read_passwd'} or $args{'_write_passwd'})
348 18 29 $args{'_write_passwd'} ? :
1 46 unless open $fhp, ($args{'_write_passwd'} ? '+' : '') . '<', "$etc/passwd"
352 0 255 unless /\S/
355 158 97 if ($wfn)
358 157 1 if $shadow{$r[0]}
362 56 199 if ($args{'_after_read_passwd_entry'})
364 0 56 if $res->[0] != 200
365 9 47 if $stash{'exit'}
375 56 29 if ($args{'_read_gshadow'} or $args{'_write_gshadow'})
376 30 26 $args{'_write_gshadow'} ? :
2 54 unless (open $fhgs, ($args{'_write_gshadow'} ? '+' : '') . '<', "$etc/gshadow")
378 2 0 if ($args{'_read_gshadow'} == 2 and not $args{'_write_gshadow'}) { }
386 0 330 unless /\S/
390 318 12 if ($wfn)
403 70 15 if ($args{'_read_group'} or $args{'_write_group'})
404 33 37 $args{'_write_group'} ? :
1 69 unless open $fhg, ($args{'_write_group'} ? '+' : '') . '<', "$etc/group"
409 0 465 unless /\S/
412 320 145 if ($wfn)
415 301 19 if $gshadow{$r[0]}
419 106 359 if ($args{'_after_read_group_entry'})
421 0 106 if $res->[0] != 200
422 16 90 if $stash{'exit'}
427 68 0 if ($args{'_after_read'})
429 21 47 if $res->[0] != 200
430 19 28 if $stash{'exit'}
435 12 1 if ($args{'_write_shadow'} and $stash{'write_shadow'} // 1)
436 1 11 if ($args{'backup'})
438 0 1 if $res->[0] != 200
440 0 12 unless seek $fhs, 0, 0
445 0 12 unless close $fhs
449 12 1 if ($args{'_write_passwd'} and $stash{'write_passwd'} // 1)
450 1 11 if ($args{'backup'})
452 0 1 if $res->[0] != 200
454 0 12 unless seek $fhp, 0, 0
459 0 12 unless close $fhp
463 21 1 if ($args{'_write_gshadow'} and $stash{'write_gshadow'} // 1)
464 1 20 if ($args{'backup'})
466 0 1 if $res->[0] != 200
468 0 21 unless seek $fhgs, 0, 0
473 0 21 unless close $fhgs
477 23 2 if ($args{'_write_group'} and $stash{'write_group'} // 1)
478 1 22 if ($args{'backup'})
480 0 1 if $res->[0] != 200
482 0 23 unless seek $fhg, 0, 0
487 0 23 unless close $fhg
493 0 95 if $@
498 23 72 if $e and $e->[0] != 200
499 23 72 if $e and $e->[0] != 200
531 1 2 $detail ? :
546 10 10 if (not $detail) { }
5 5 elsif ($wfn) { }
556 2 2 if $detail
561 2 2 $detail ? :
605 1 15 unless defined $user xor defined $uid
621 9 47 if (defined $user and $passwd->[-1][0] eq $user or defined $uid and $passwd->[-1][2] == $uid)
623 9 0 $wfn ? :
660 1 1 if ($res->[0] == 404) { }
1 0 elsif ($res->[0] == 200) { }
691 1 3 $detail ? :
706 18 12 if (not $detail) { }
6 6 elsif ($wfn) { }
716 2 3 if $detail
720 2 3 $detail ? :
764 1 22 unless defined $gn xor defined $gid
780 16 90 if (defined $gn and $group->[-1][0] eq $gn or defined $gid and $group->[-1][2] == $gid)
782 16 0 $wfn ? :
819 1 2 $detail ? :
835 10 10 if (not $detail) { }
5 5 elsif ($wfn) { }
848 12 12 if (not $detail) { }
6 6 elsif ($wfn) { }
862 2 2 $detail ? :
2 2 $detail ? :
890 1 1 if ($res->[0] == 404) { }
1 0 elsif ($res->[0] == 200) { }
929 0 5 unless my $user = $args{'user'}
931 0 5 $detail ? :
944 1 4 unless &first(sub { $_->[0] eq $user; } , @$passwd)
952 14 10 unless $user ~~ \@mm or $group->[$i][0] eq $user
953 10 0 if (not $detail) { }
0 0 elsif ($wfn) { }
967 0 5 $detail ? :
995 1 5 unless my $user = $args{'user'}
996 1 4 unless my $group = $args{'group'}
998 1 3 unless $res->[0] == 200
1000 2 1 $user ~~ \@mm ? :
1068 18 9 if ($which eq 'user')
1069 1 17 unless $user = $args{'user'}
1070 1 16 unless $user =~ /$re_user/o
1073 2 14 if $gn ne $user
1076 1 24 unless $gn
1077 1 23 unless $gn =~ /$re_group/o
1081 0 23 if $min_gid < 0
1082 0 23 if $max_gid > 65535
1084 7 16 if ($which eq 'group') { }
1086 0 7 if ($members and ref $members eq 'ARRAY')
1090 1 6 unless $members =~ /$re_field/o
1100 16 6 if ($which eq 'user')
1102 0 16 if $min_uid < 0
1103 0 16 if $min_uid > 65535
1106 0 16 unless ($pass =~ /$re_field/o)
1109 1 15 unless ($gecos =~ /$re_field/o)
1112 1 14 unless ($home =~ /$re_field/o)
1115 1 13 unless ($shell =~ /$re_field/o)
1117 11 1 $pass eq '' ? :
1118 1 12 unless ($encpass =~ /$re_field/o)
1125 1 11 unless ($pass_inactive_period =~ /$re_field/o)
1128 1 10 unless ($expire_date =~ /$re_field/o)
1147 1 15 if ($which eq 'group' and $cur_g) { }
2 13 elsif ($cur_g) { }
1 12 elsif (not $create_group) { }
1148 1 0 if $cur_g
1155 10 2 unless (defined $gid)
1157 9 19 unless ($_ ~~ \@gids)
1159 1 9 unless defined $gid
1168 9 4 if ($which eq 'user')
1172 1 8 if &first(sub { $_->[0] eq $user; } , @$passwd)
1174 6 2 unless (defined $uid)
1176 5 10 unless ($_ ~~ \@uids)
1178 1 5 unless defined $uid
1189 39 7 unless $l->[0] eq $gn
1191 1 6 unless ($user ~~ \@mm)
1199 0 11 unless $write_g
1344 19 16 if ($which eq 'user') { }
1345 1 18 unless $user = $args{'user'}
1347 3 13 unless $gn = $args{'group'}
1350 18 13 if ($which eq 'user')
1351 1 17 if (defined $args{'uid'} and not $args{'uid'} =~ /$re_posint/o)
1353 1 16 if (defined $args{'gid'} and not $args{'gid'} =~ /$re_posint/o)
1355 1 15 if (defined $args{'gecos'} and not $args{'gecos'} =~ /$re_field/o)
1357 1 14 if (defined $args{'home'} and not $args{'home'} =~ /$re_field/o)
1359 1 13 if (defined $args{'shell'} and not $args{'shell'} =~ /$re_field/o)
1361 2 11 if (defined $args{'pass'})
1362 0 2 $args{'pass'} eq '' ? :
1365 2 11 if (defined $args{'encpass'} and not $args{'encpass'} =~ /$re_field/o)
1367 1 10 if (defined $args{'last_pwchange'} and not $args{'last_pwchange'} =~ /$re_posint/o)
1369 1 9 if (defined $args{'min_pass_age'} and not $args{'min_pass_age'} =~ /$re_posint/o)
1371 1 8 if (defined $args{'max_pass_age'} and not $args{'max_pass_age'} =~ /$re_posint/o)
1373 1 7 if (defined $args{'pass_warn_period'} and not $args{'pass_warn_period'} =~ /$re_posint/o)
1375 1 6 if (defined $args{'pass_inactive_period'} and not $args{'pass_inactive_period'} =~ /$re_posint/o)
1378 1 5 if (defined $args{'expire_date'} and not $args{'expire_date'} =~ /$re_posint/o)
1383 13 5 if ($which eq 'group')
1384 1 12 if (defined $args{'gid'} and not $args{'gid'} =~ /$re_posint/o)
1386 0 12 if (defined $args{'pass'})
1387 0 0 $args{'pass'} eq '' ? :
1390 1 11 if (defined $args{'encpass'} and not $args{'encpass'} =~ /$re_field/o)
1392 2 9 if (defined $args{'members'})
1393 0 2 if (ref $args{'members'} eq 'ARRAY')
1394 1 1 unless $args{'members'} =~ /$re_field/o
1396 2 8 if (defined $args{'admins'})
1397 0 2 if (ref $args{'admins'} eq 'ARRAY')
1398 1 1 unless $args{'admins'} =~ /$re_field/o
1413 5 9 if ($which eq 'user') { }
1416 19 3 unless $l->[0] eq $user
1419 6 12 if (defined $args{$f})
1427 2 3 unless $found
1428 1 2 unless $changed
1433 9 3 unless $l->[0] eq $user
1436 8 13 if (defined $args{$f})
1444 1 2 unless $changed
1448 46 6 unless $l->[0] eq $gn
1451 12 6 if ($args{'_before_set_group_field'})
1454 6 12 if (defined $args{$f})
1462 3 6 unless $found
1463 1 5 unless $changed
1468 28 6 unless $l->[0] eq $gn
1470 7 11 if (defined $args{$f})
1478 1 5 unless $changed
1564 2 4 unless my $user = $args{'user'}
1565 0 4 unless $user =~ /$re_user/o
1574 0 6 unless $l->[0] eq $gn
1576 0 6 if $user ~~ \@mm
1605 2 4 unless my $user = $args{'user'}
1606 0 4 unless $user =~ /$re_user/o
1615 0 6 unless $l->[0] eq $gn
1617 0 6 unless $user ~~ \@mm
1666 0 2 unless my $user = $args{'user'}
1667 0 2 unless $user =~ /$re_user/o
1685 2 10 if ($l->[0] ~~ $add and not $user ~~ \@mm)
1689 1 11 if ($l->[0] ~~ $del and $user ~~ \@mm)
1693 5 7 if ($changed)
1697 1 1 unless $changed
1732 0 1 unless my $user = $args{'user'}
1733 0 1 unless $user =~ /$re_user/o
1734 0 1 unless my $gg = $args{'groups'}
1750 2 4 if ($l->[0] ~~ $gg and not $user ~~ \@mm)
1754 1 5 if (not $l->[0] ~~ $gg and $user ~~ \@mm)
1758 5 1 if ($changed)
1762 0 1 unless $changed
1791 0 3 unless $args{'user'}
1792 1 2 unless defined $args{'pass'}
1801 3 2 if ($which eq 'user')
1802 0 3 unless $user = $args{'user'}
1806 0 5 unless $gn
1822 20 14 if ($which eq 'user')
1825 4 16 if ($user ~~ \@mm)
1830 5 29 if ($group->[$i][0] eq $gn)
1836 0 5 unless $changed
1841 19 14 if ($which eq 'user')
1844 2 17 if ($user ~~ \@mm)
1849 5 28 if ($gshadow->[$i][0] eq $gn)
1856 0 5 unless $changed
1858 3 2 if ($which eq 'user')
1862 3 13 if ($passwd->[$i][0] eq $user)
1869 0 3 unless $changed
1874 3 13 if ($shadow->[$i][0] eq $user)
1881 0 3 unless $changed