Infrastructure/SystemUser.pm

filter: Statementstmt 52.3% 22 / 42 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 30.7% 4 / 13 Podpod 0.0% 0 / 1 totaltotal 43.3% 26 / 60 CC 3 SCAR 10.3
CC
3
Cov
48%
__ANON__
6.0
__ANON__
6.0
S
2.0
CRAP 2.8
« Infrastructure/Config/Facter.pm ↑ Summary Infrastructure/Compare.pm »
1 package Test::BDD::Infrastructure::SystemUser;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 our $VERSION = '1.005'; # VERSION
7 # ABSTRACT: cucumber step definitions for checking passwd/groups
8
9 1 ▶use Test::More;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Test::BDD::Cucumber::StepFile qw( Given When Then );
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 0 ▶sub S { Test::BDD::Cucumber::StepFile::S }
Subroutine S: not called CC=1 SCAR=6.9
Pod undocumented
13  
14  
15 0 ▶Given qr/^the system user (\S+) exists$/, sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
16 0 my @user = CORE::getpwnam($1);
17 0 ▶ if( ! @user ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@user) 0 0 0
18 0 fail('system user '.$1.' does not exist!');
19 0 return;
20 }
21 0 pass("system user $1 does exist.");
22 0 S->{'system_user'} = \@user;
23 1 };
24  
25 0 ▶Then qr/^the system users uid must be (\d+)$/, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
26 0 cmp_ok( S->{'system_user'}->[2], '==', $1, 'must have correct uid');
27 1 };
28  
29 0 ▶Then qr/^the system users primary group must be (\d+)$/, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
30 0 cmp_ok( S->{'system_user'}->[3], '==', $1, 'must have correct gid');
31 1 };
32  
33 0 ▶Then qr/^the system users comment must be like (.*)$/, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
34 0 like( S->{'system_user'}->[6], qr/$1/, "system users comment must match: $1");
35 1 };
36  
37 0 ▶Then qr/^the system users home directory must be (.*)$/, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
38 0 cmp_ok( S->{'system_user'}->[7], 'eq', $1, "home directory must be $1");
39 1 };
40  
41 0 ▶Then qr/^the system users shell must be (.*)$/, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
42 0 cmp_ok( S->{'system_user'}->[8], 'eq', $1, "shell must be $1");
43 1 };
44  
45 0 ▶Given qr/^the system group (\S+) exists$/, sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
46 0 my @group;
47 0 @group = CORE::getgrnam($1);
48 0 ▶ if( ! @group ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@group) 0 0 0
49 0 fail('system group '.$1.' does not exist!');
50 0 return;
51 }
52 0 pass("system group $1 does exist.");
53 0 S->{'system_group'} = \@group;
54 1 };
55  
56 0 ▶Then qr/^the system groups gid must be (\d+)$/, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
57 0 cmp_ok( S->{'system_group'}->[2], '==', $1, 'must have correct group id');
58 1 };
59  
60 1 1;
61  
62 __END__
« Infrastructure/Config/Facter.pm ↑ Summary Infrastructure/Compare.pm »