OpenInteract2/SPOPS/LDAP.pm

filter: Statementstmt 36.6% 11 / 30 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 42.8% 3 / 7 Podpod 0.0% 0 / 4 totaltotal 21.2% 14 / 66 CC 8 SCAR 23.2
CC
8
Cov
23%
get_connect_key
20.0
get_partial_dn
12.0
connection_info
6.0
CRAP 10.2
« OpenInteract2/Config/GlobalOverride.pm ↑ Summary OpenInteract2/Response/Apache.pm »
1 package OpenInteract2::SPOPS::LDAP;
2  
3 # $Id: LDAP.pm,v 1.8 2005/03/18 04:09:51 lachoy Exp $
4  
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use base qw( OpenInteract2::SPOPS );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use OpenInteract2::Context qw( CTX );
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 $OpenInteract2::SPOPS::LDAP::VERSION = sprintf("%d.%02d", q$Revision: 1.8 $ =~ /(\d+)\.(\d+)/);
10  
11 # See OpenInteract2::Config::Initializer for initialization behavior
12  
13  
14 # TODO: Ensure stub is in SPOPS::LDAP for this
15  
16 0 ▶sub connection_info {
Subroutine connection_info: not called CC=2 SCAR=17.9
Pod undocumented
17 0 my ( $self, $connect_key ) = @_;
18 0 ▶ $connect_key ||= $self->get_connect_key();
Condition0%0/3
$connect_key ||= $self->get_connect_key
l!l&&r!l&&!r
000
MC/DC0%0/2
$connect_key ||= $self->get_connect_key
$connect_key $self->get_connect_key
Truth table0%0/3
A ||= B
A= $connect_keyB= $self->get_connect_key
ABresult
1X1
011
000
19 0 return \%{ $self->global_config->{datasource}{ $connect_key } };
20 }
21  
22  
23 # TODO: Move this to SPOPS::LDAP and document
24  
25 0 ▶sub base_dn {
Subroutine base_dn: not called CC=2 SCAR=17.9
Pod undocumented
26 0 my ( $class, $connect_key ) = @_;
27 0 my $partial_dn = $class->get_partial_dn( $connect_key );
28 0 ▶ unless ( $partial_dn ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($partial_dn) 0 0 0
29 0 die "No Base DN defined in SPOPS configuration key 'ldap_base_dn', cannot continue!\n";
30 }
31 0 my $connect_info = $class->connection_info( $connect_key );
32 0 return join( ',', $partial_dn, $connect_info->{base_dn} );
33 }
34  
35  
36 # Retrieves the connect key when none is passed in
37  
38 # TODO: Move this (minus the 'global_config' option) to SPOPS::LDAP
39 # and document
40  
41 0 ▶sub get_connect_key {
Subroutine get_connect_key: not called CC=4 SCAR=30.0
Pod undocumented
42 0 my ( $class ) = @_;
43 my $connect_key = $class->CONFIG->{datasource} ||
44 $class->global_config->{datasource}{default_connection_ldap} ||
45 0 ▶ $class->global_config->{default_connection_ldap};
Condition0%0/6
$class->CONFIG->{'datasource'} || $class->global_config->{'datasource'}{'default_connection_ldap'} || $class->global_config->{'default_connection_ldap'}
l!l&&r!l&&!r
000
$class->CONFIG->{"datasource"} or $class->global_config->{"datasource"}{"default_connection_ldap"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$class->CONFIG->{'datasource'} || $class->global_config->{'datasource'}{'default_connection_ldap'} || $class->global_config->{'default_connection_ldap'}
$class->CONFIG->{"datasource"} $class->global_config->{"datasource"}{"default_connection_ldap"} $class->global_config->{'default_connection_ldap'}
Truth table0%0/4
A or B || C
A= $class->CONFIG->{"datasource"}B= $class->global_config->{"datasource"}{"default_connection_ldap"}C= $class->global_config->{'default_connection_ldap'}
ABCresult
1XX1
01X1
0011
0000
46 0 ▶ $connect_key = $connect_key->[0] if ( ref $connect_key eq 'ARRAY' );
Branch: 1 branch
BranchTrueFalseTotal
if ref $connect_key eq "ARRAY" 0 0 0
47 0 return $connect_key;
48 }
49  
50 # Retrieves the 'partial dn', or the section that's prepended to the
51 # server's 'base DN' to identify the branch on which these objects
52 # live
53  
54 # TODO: Move this to SPOPS::LDAP (?) and document
55  
56 0 ▶sub get_partial_dn {
Subroutine get_partial_dn: not called CC=3 SCAR=24.8
Pod undocumented
57 0 my ( $class, $connect_key ) = @_;
58 0 my $base_dn_info = $class->CONFIG->{ldap_base_dn};
59 0 ▶ return $base_dn_info unless ( ref $base_dn_info eq 'HASH' );
Branch: 1 branch
BranchTrueFalseTotal
unless ref $base_dn_info eq "HASH" 0 0 0
60 0 ▶ $connect_key ||= $class->get_connect_key;
Condition0%0/3
$connect_key ||= $class->get_connect_key
l!l&&r!l&&!r
000
MC/DC0%0/2
$connect_key ||= $class->get_connect_key
$connect_key $class->get_connect_key
Truth table0%0/3
A ||= B
A= $connect_keyB= $class->get_connect_key
ABresult
1X1
011
000
61 0 return $base_dn_info->{ $connect_key };
62 }
63  
64 1 1;
65  
66 __END__
« OpenInteract2/Config/GlobalOverride.pm ↑ Summary OpenInteract2/Response/Apache.pm »