LDAP/Command/Add/Group.pm

filter: Statementstmt 62.9% 17 / 27 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 66.6% 4 / 6 Podpod 0.0% 0 / 2 totaltotal 45.6% 21 / 46 CC 5 SCAR 27.5
CC
5
Cov
47%
run
30.0
next_gid
2.0
BEGIN
1.0
CRAP 15.6
« LDAP/Command/Add/Sudoer.pm ↑ Summary LDAP/Command/Add/User.pm »
1 package App::LDAP::Command::Add::Group;
2  
3 1 ▶use Modern::Perl;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 with qw( App::LDAP::Role::Command
8 App::LDAP::Role::Bindable );
9  
10 1 has base => (
11 is => "rw",
12 isa => "Str",
13 );
14  
15 1 has member => (
16 is => "rw",
17 isa => "ArrayRef[Str]",
18 );
19  
20 1 ▶use App::LDAP::LDIF::Group;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 # {{{
23 0 ▶sub run {
Subroutine run: not called CC=5 SCAR=34.0
Pod undocumented
24 0 my ($self) = shift;
25  
26 0 my $gid = next_gid();
27  
28 0 ▶ my $groupname = $self->extra_argv->[2] or die "no group name specified";
Branch: 1 branch
BranchTrueFalseTotal
my $groupname = $self->extra_argv->[2] or die "no group name specified" 0 0 0
29  
30 die "group $groupname already exists" if App::LDAP::LDIF::Group->search(
31 base => config()->{nss_base_group}->[0],
32 0 ▶ scope => config()->{nss_base_group}->[1],
Branch: 1 branch
BranchTrueFalseTotal
if "App::LDAP::LDIF::Group"->search("base", config()->{"nss_base_group"}[0], "scope", config()->{"nss_base_group"}[1], "filter", "cn=$groupname") 0 0 0
33 filter => "cn=$groupname",
34 );
35  
36 my $group = App::LDAP::LDIF::Group->new(
37 0 ▶ base => $self->base // config()->{nss_base_group}->[0],
Condition0%0/3
$self->base // config()->{"nss_base_group"}[0]
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->base // config()->{"nss_base_group"}[0]
$self->base config()->{"nss_base_group"}[0]
Truth table0%0/3
A // B
A= $self->baseB= config()->{"nss_base_group"}[0]
ABresult
1X1
011
000
38 cn => [$groupname],
39 gidNumber => $gid->get_value("gidNumber"),
40 );
41  
42 0 ▶ $group->memberUid( $self->member ) if $self->member;
Branch: 1 branch
BranchTrueFalseTotal
if $self->member 0 0 0
43  
44 0 $group->save;
45  
46 0 $gid->replace(gidNumber => $gid->get_value("gidNumber")+1)->update(ldap());
47  
48 0 $group;
49 }
50 # }}}
51  
52 0 ▶sub next_gid {
Subroutine next_gid: not called CC=1 SCAR=6.9
Pod undocumented
53 ldap()->search(
54 base => config()->{base},
55 0 filter => "(objectClass=gidnext)",
56 )->entry(0);
57 }
58  
59 1 __PACKAGE__->meta->make_immutable;
60 1 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
61  
62 1 1;
« LDAP/Command/Add/Sudoer.pm ↑ Summary LDAP/Command/Add/User.pm »