LDAP/Command/Export.pm

filter: Statementstmt 62.5% 15 / 24 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 75.0% 3 / 4 Podpod 0.0% 0 / 1 totaltotal 39.1% 18 / 46 CC 7 SCAR 36.8
CC
7
Cov
42%
run
56.0
BEGIN
1.0
BEGIN
1.0
CRAP 39.5
↑ Summary LDAP/Command/Passwd.pm »
1 package App::LDAP::Command::Export;
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 scope => (
16 is => "rw",
17 isa => "Str",
18 );
19  
20 1 has filter => (
21 is => "rw",
22 isa => "Str",
23 );
24  
25 0 ▶sub run {
Subroutine run: not called CC=7 SCAR=40.3
Pod undocumented
26 0 my ($self) = shift;
27  
28 0 my $file = $self->extra_argv->[1];
29  
30 0 ▶ if (! defined($file)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $file) 0 0 0
31 0 say "you must give the file name to export";
32 0 exit;
33 }
34  
35 my @entries = ldap()->search(
36 base => $self->base // config()->{base},
37 scope => $self->scope // config()->{scope},
38 0 ▶ filter => $self->filter // "objectClass=*",
Condition0%0/8
$self->base // config()->{"base"}
l!l&&r!l&&!r
000
$self->scope // config()->{"scope"}
l!l&&r!l&&!r
000
$self->filter // "objectClass=*"
l!l
00
MC/DC0%0/2
$self->base // config()->{"base"}
$self->base config()->{"base"}
MC/DC0%0/2
$self->scope // config()->{"scope"}
$self->scope config()->{"scope"}
MC/DC0%0/1
$self->filter // "objectClass=*"
$self->filter
Truth table0%0/3
A // B
A= $self->baseB= config()->{"base"}
ABresult
1X1
011
000
Truth table0%0/3
A // B
A= $self->scopeB= config()->{"scope"}
ABresult
1X1
011
000
Truth table0%0/2
A
A= $self->filter
Aresult
11
00
39 )->entries;
40  
41  
42 0 ▶ open my $output, ">", $file or die "can not open $file";
Branch: 1 branch
BranchTrueFalseTotal
open my $output, ">", $file or die "can not open $file" 0 0 0
43 0 for (@entries) {
44 0 print $output $_->ldif;
45 }
46  
47 }
48  
49  
50 1 __PACKAGE__->meta->make_immutable;
51 1 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
52  
53 1 1;
54  
55 =head1 NAME
56  
57 App::LDAP::Command::Export
58  
59 =head1 SYNOPSIS
60  
61 $ sudo ldap export backup.ldif
62 backup whole DIT
63  
64 $ ldap export people.ldif --base ou=people,dc=example,dc=com
65 dump user information without password
66  
67 $ sudo ldap export people.ldif --base ou=people,dc=example,dc=com
68 dump user information with password
69  
70 =cut
↑ Summary LDAP/Command/Passwd.pm »