LDAP/Role/Bindable.pm

filter: Statementstmt 71.4% 15 / 21 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 57.1% 4 / 7 Podpod 0.0% 0 / 2 totaltotal 45.2% 19 / 42 CC 4 SCAR 13.9
CC
4
Cov
52%
__ANON__
6.0
bindroot
6.0
binduser
6.0
CRAP 4.0
« LDAP/Command/Del/Sudoer.pm ↑ Summary LDAP/LDIF.pm »
1 package App::LDAP::Role::Bindable;
2  
3 5 ▶use Modern::Perl;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 5 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 5 ▶use Term::ReadPassword;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 5 with 'App::LDAP::Role';
10  
11 0 ▶around prepare => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
12 0 my $orig = shift;
13 0 my $self = shift;
14  
15 0 ▶ ($< == 0) ? bindroot() : binduser();
Branch: 1 branch
BranchTrueFalseTotal
$< == 0 ? : 0 0 0
16  
17 0 $self->$orig(@_);
18 5 };
19  
20 0 ▶sub bindroot {
Subroutine bindroot: not called CC=2 SCAR=17.9
Pod undocumented
21 ldap()->bind(
22 config()->{rootbinddn},
23 0 ▶ password => secret() // read_password("ldap admin password: "),
Condition0%0/3
secret() // read_password("ldap admin password: ")
l!l&&r!l&&!r
000
MC/DC0%0/2
secret() // read_password("ldap admin password: ")
secret() read_password("ldap admin password: ")
Truth table0%0/3
A // B
A= secret()B= read_password("ldap admin password: ")
ABresult
1X1
011
000
24 );
25 }
26  
27 0 ▶sub binduser {
Subroutine binduser: not called CC=2 SCAR=17.9
Pod undocumented
28 0 ▶ ldap()->bind(
Condition0%0/3
secret() // read_password("your password: ")
l!l&&r!l&&!r
000
MC/DC0%0/2
secret() // read_password("your password: ")
secret() read_password("your password: ")
Truth table0%0/3
A // B
A= secret()B= read_password("your password: ")
ABresult
1X1
011
000
29 find_user("uidNumber", $<)->dn,
30 password => secret() // read_password("your password: "),
31 );
32 }
33  
34 5 ▶no Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
35  
36 5 1;
37  
38 =pod
39  
40 =head1 NAME
41  
42 App::LDAP::Role::Bindable - make a command itself bindable to a LDAP server
43  
44 =head1 SYNOPSIS
45  
46 package App::LDAP::Command::YourCommand;
47 use Moose;
48 with qw( App::LDAP::Role::Command
49 App::LDAP::Role::Bindable );
50  
51 package main;
52 App::LDAP::Command::YourCommand->new_with_options()->prepare()->run();
53  
54 =head1 DESCRIPTION
55  
56 This role hook the prepare() method to bind the handler through $UID to the LDAP server before running.
57  
58 =cut
« LDAP/Command/Del/Sudoer.pm ↑ Summary LDAP/LDIF.pm »