| 1 | # Manager main component | ||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||
| 3 | # This package contains these parts: | ||||||||||||||||||||||||||||
| 4 | # - Properties and private methods | ||||||||||||||||||||||||||||
| 5 | # - Initialization method (launched by Lemonldap::NG::Common::PSGI) | ||||||||||||||||||||||||||||
| 6 | # that declares routes | ||||||||||||||||||||||||||||
| 7 | # - Upload methods (launched by Lemonldap::NG::Common::PSGI::Router) | ||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||
| 9 | # It inherits from Conf.pm to responds to display methods and from | ||||||||||||||||||||||||||||
| 10 | # Sessions.pm to manage sessions | ||||||||||||||||||||||||||||
| 11 | package Lemonldap::NG::Manager; | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 28 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 28 | ▶ | use utf8; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 28 | ▶ | use Mouse; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 28 | ▶ | use JSON; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 28 | ▶ | use Lemonldap::NG::Common::Conf::Constants; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | 28 | ▶ | use Lemonldap::NG::Common::PSGI::Constants; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 28 | our $VERSION = '2.23.4'; | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 28 | extends qw( | |||||||||||||||||||||||||||
| 23 | Lemonldap::NG::Handler::PSGI::Router | ||||||||||||||||||||||||||||
| 24 | Lemonldap::NG::Common::Conf::AccessLib | ||||||||||||||||||||||||||||
| 25 | ); | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 28 | has csp => ( is => 'rw' ); | |||||||||||||||||||||||||||
| 28 | 45 | ▶ | has loadedPlugins => ( is => 'rw', default => sub { [] } ); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 29 | 45 | ▶ | has hLoadedPlugins => ( is => 'rw', default => sub { {} } ); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | ## @method boolean init($args) | ||||||||||||||||||||||||||||
| 32 | # Launch initialization method | ||||||||||||||||||||||||||||
| 33 | # | ||||||||||||||||||||||||||||
| 34 | # @param $args hashref to merge with object | ||||||||||||||||||||||||||||
| 35 | # @return 0 in case of error, 1 else | ||||||||||||||||||||||||||||
| 36 | 45 | ▶ | sub init { | ||||||||||||||||||||||||||
|
Subroutine
init: called CC=20 SCAR=33.7
Pod
undocumented
| |||||||||||||||||||||||||||||
| 37 | 45 | my ( $self, $args ) = @_; | |||||||||||||||||||||||||||
| 38 | 45 | ▶ | $args ||= {}; | ||||||||||||||||||||||||||
|
Condition50%1/2
$args ||= {}
MC/DC0%0/1
$args ||= {}
$args
Truth table50%1/2
A
A= $args
| |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 45 | ▶ | if ( my $localconf = $self->confAcc->getLocalConf(MANAGERSECTION) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | 45 | foreach ( keys %$localconf ) { | |||||||||||||||||||||||||||
| 42 | 676 | ▶ | $args->{$_} //= $localconf->{$_}; | ||||||||||||||||||||||||||
|
Condition66%2/3
$args->{$_} //= $localconf->{$_}
MC/DC0%0/2
$args->{$_} //= $localconf->{$_}
$args->{$_}
$localconf->{$_}
Truth table66%2/3
A //= B
A= $args->{$_}B= $localconf->{$_}
| |||||||||||||||||||||||||||||
| 43 | 676 | ▶ | $self->{$_} = $args->{$_} unless (/^(?:l|userL)ogger$/); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | # Manager needs to keep new Ajax behaviour | ||||||||||||||||||||||||||||
| 48 | 45 | $args->{noAjaxHook} = 0; | |||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 45 | ▶ | return 0 | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | unless ( $self->Lemonldap::NG::Handler::PSGI::Router::init($args) ); | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | # TODO: manage errors | ||||||||||||||||||||||||||||
| 54 | 45 | ▶ | unless ( -r $self->{templateDir} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | 0 | $self->error("Unable to read $self->{templateDir}"); | |||||||||||||||||||||||||||
| 56 | 0 | return 0; | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 45 | my $conf = $self->confAcc->getConf; | |||||||||||||||||||||||||||
| 60 | 45 | $conf->{$_} = $args->{$_} foreach ( keys %$args ); | |||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 45 | ▶ | $self->{enabledModules} ||= "conf, sessions, notifications, 2ndFA, api"; | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"enabledModules"} ||= "conf, sessions, notifications, 2ndFA, api"
MC/DC0%0/1
$self->{"enabledModules"} ||= "conf, sessions, notifications, 2ndFA, api"
$self->{"enabledModules"}
Truth table50%1/2
A
A= $self->{"enabledModules"}
| |||||||||||||||||||||||||||||
| 63 | 45 | my @links; | |||||||||||||||||||||||||||
| 64 | my @enabledModules = | ||||||||||||||||||||||||||||
| 65 | map { | ||||||||||||||||||||||||||||
| 66 | 251 | my @res = ( "Lemonldap::NG::Manager::" . ucfirst($_) ); | |||||||||||||||||||||||||||
| 67 | 251 | ▶ | if ( my $tmp = $self->loadPlugin( @res, $conf ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | 251 | $self->logger->debug("Plugin $_ loaded"); | |||||||||||||||||||||||||||
| 69 | 251 | push @links, $_; | |||||||||||||||||||||||||||
| 70 | 251 | push @{ $self->loadedPlugins }, $tmp; | |||||||||||||||||||||||||||
| 71 | 251 | $self->hLoadedPlugins->{$_} = $tmp; | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | else { | ||||||||||||||||||||||||||||
| 74 | 0 | $self->logger->error("Unable to load $_, skipping"); | |||||||||||||||||||||||||||
| 75 | 0 | @res = (); | |||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | 251 | (@res); | |||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | 45 | split( /[,\s]+/, $self->{enabledModules} ); | |||||||||||||||||||||||||||
| 80 | 45 | ▶ | unless (@enabledModules) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | 0 | $self->logger->error('No plugins loaded, aborting'); | |||||||||||||||||||||||||||
| 82 | 0 | return 0; | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | 45 | ▶ | unless ($conf) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 85 | 0 | require Lemonldap::NG::Manager::Conf::Zero; | |||||||||||||||||||||||||||
| 86 | 0 | $conf = Lemonldap::NG::Manager::Conf::Zero::zeroConf(); | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | # TODO: -> loadPlugin | ||||||||||||||||||||||||||||
| 90 | #for ( my $i = 0 ; $i < @enabledModules ; $i++ ) { | ||||||||||||||||||||||||||||
| 91 | # my $mod = $enabledModules[$i]; | ||||||||||||||||||||||||||||
| 92 | # no strict 'refs'; | ||||||||||||||||||||||||||||
| 93 | # if ( &{"${mod}::addRoutes"}( $self, $conf ) ) { | ||||||||||||||||||||||||||||
| 94 | # $self->logger->debug("Module $mod enabled"); | ||||||||||||||||||||||||||||
| 95 | # push @working, $mod; | ||||||||||||||||||||||||||||
| 96 | # } | ||||||||||||||||||||||||||||
| 97 | # else { | ||||||||||||||||||||||||||||
| 98 | # $links[$i] = undef; | ||||||||||||||||||||||||||||
| 99 | # $self->logger->error( | ||||||||||||||||||||||||||||
| 100 | # "Module $mod can not be enabled: " . $self->error ); | ||||||||||||||||||||||||||||
| 101 | # } | ||||||||||||||||||||||||||||
| 102 | #} | ||||||||||||||||||||||||||||
| 103 | 45 | $self->addRoute( links => 'links', ['GET'] ); | |||||||||||||||||||||||||||
| 104 | 45 | $self->addRoute( 'psgi.js' => 'sendJs', ['GET'] ); | |||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 45 | my $portal = $conf->{portal}; | |||||||||||||||||||||||||||
| 107 | 45 | $portal =~ s#https?://([^/]*).*#$1#; | |||||||||||||||||||||||||||
| 108 | 45 | $self->csp( | |||||||||||||||||||||||||||
| 109 | "default-src 'self' $portal;frame-ancestors 'none';form-action 'self';" | ||||||||||||||||||||||||||||
| 110 | ); | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | # Avoid restricted users to access configuration by default route | ||||||||||||||||||||||||||||
| 113 | my $defaultMod = $self->{defaultModule} = | ||||||||||||||||||||||||||||
| 114 | 45 | ▶ | $self->{defaultModule} || $enabledModules[0]; | ||||||||||||||||||||||||||
|
Condition33%1/3
$self->{'defaultModule'} || $enabledModules[0]
MC/DC0%0/2
$self->{'defaultModule'} || $enabledModules[0]
$self->{'defaultModule'}
$enabledModules[0]
Truth table33%1/3
A || B
A= $self->{'defaultModule'}B= $enabledModules[0]
| |||||||||||||||||||||||||||||
| 115 | 45 | $self->logger->debug("Default module -> $defaultMod"); | |||||||||||||||||||||||||||
| 116 | my ($index) = | ||||||||||||||||||||||||||||
| 117 | 45 | grep { $enabledModules[$_] eq $defaultMod } ( 0 .. $#enabledModules ); | |||||||||||||||||||||||||||
| 118 | 45 | ▶ | $index //= 0; | ||||||||||||||||||||||||||
|
Condition50%1/2
$index //= 0
MC/DC0%0/1
$index //= 0
$index
Truth table50%1/2
A
A= $index
| |||||||||||||||||||||||||||||
| 119 | 45 | $self->logger->debug("Default index -> $index"); | |||||||||||||||||||||||||||
| 120 | 45 | $self->defaultRoute( $self->loadedPlugins->[$index]->defaultRoute ); | |||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 45 | $self->links( [] ); | |||||||||||||||||||||||||||
| 123 | 45 | ▶ | for ( my $i = 0 ; $i < @links ; $i++ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 124 | 251 | ▶ | next unless ( defined $links[$i] ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 125 | 251 | push @{ $self->links }, | |||||||||||||||||||||||||||
| 126 | { | ||||||||||||||||||||||||||||
| 127 | target => $self->loadedPlugins->[$i]->defaultRoute, | ||||||||||||||||||||||||||||
| 128 | title => $links[$i], | ||||||||||||||||||||||||||||
| 129 | icon => $self->loadedPlugins->[$i]->icon, | ||||||||||||||||||||||||||||
| 130 | }; | ||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | 45 | $self->menuLinks( [] ); | |||||||||||||||||||||||||||
| 134 | 45 | ▶ | if ( | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 135 | my $portal = | ||||||||||||||||||||||||||||
| 136 | $conf->{cfgNum} | ||||||||||||||||||||||||||||
| 137 | ? Lemonldap::NG::Handler::PSGI::Main->tsv->{portal}->() | ||||||||||||||||||||||||||||
| 138 | : $conf->{portal} | ||||||||||||||||||||||||||||
| 139 | ) | ||||||||||||||||||||||||||||
| 140 | { | ||||||||||||||||||||||||||||
| 141 | 45 | ▶ | $portal = $self->customPortalUrl || $portal; | ||||||||||||||||||||||||||
|
Condition33%1/3
$self->customPortalUrl || $portal
MC/DC0%0/2
$self->customPortalUrl || $portal
$self->customPortalUrl
$portal
Truth table33%1/3
A || B
A= $self->customPortalUrlB= $portal
| |||||||||||||||||||||||||||||
| 142 | 45 | push @{ $self->menuLinks }, | |||||||||||||||||||||||||||
| 143 | { | ||||||||||||||||||||||||||||
| 144 | target => $portal, | ||||||||||||||||||||||||||||
| 145 | title => 'backtoportal', | ||||||||||||||||||||||||||||
| 146 | icon => 'home' | ||||||||||||||||||||||||||||
| 147 | }, | ||||||||||||||||||||||||||||
| 148 | { | ||||||||||||||||||||||||||||
| 149 | target => "$portal?logout=1", | ||||||||||||||||||||||||||||
| 150 | title => 'logout', | ||||||||||||||||||||||||||||
| 151 | icon => 'log-out' | ||||||||||||||||||||||||||||
| 152 | }; | ||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||
| 154 | 45 | 1; | |||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 2 | ▶ | sub tplParams { | ||||||||||||||||||||||||||
|
Subroutine
tplParams: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 158 | 2 | my ( $self, $req ) = @_; | |||||||||||||||||||||||||||
| 159 | 2 | ▶ | my $res = eval { | ||||||||||||||||||||||||||
|
Condition50%1/2
eval {
do {
$self->hLoadedPlugins->{'viewer'}->brwRule->($req, $req->{'userData'})
}
} || 0
MC/DC0%0/1
eval {
do {
$self->hLoadedPlugins->{'viewer'}->brwRule->($req, $req->{'userData'})
}
} || 0
eval {
do {
$self->hLoadedPlugins->{'viewer'}->brwRule->($req, $req->{'userData'})
}
}
Truth table50%1/2
A
A= eval {
do {
$self->hLoadedPlugins->{'viewer'}->brwRule->($req, $req->{'userData'})
}
}
| |||||||||||||||||||||||||||||
| 160 | 2 | $self->hLoadedPlugins->{viewer}->brwRule->( $req, $req->{userData} ); | |||||||||||||||||||||||||||
| 161 | } || 0; | ||||||||||||||||||||||||||||
| 162 | return ( | ||||||||||||||||||||||||||||
| 163 | VERSION => $VERSION, | ||||||||||||||||||||||||||||
| 164 | ALLOWBROWSER => $res, | ||||||||||||||||||||||||||||
| 165 | 2 | ▶ | DOC_PREFIX => ( $self->{docPrefix} || '/doc' ), | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'docPrefix'} || '/doc'
MC/DC0%0/1
$self->{'docPrefix'} || '/doc'
$self->{'docPrefix'}
Truth table50%1/2
A
A= $self->{'docPrefix'}
| |||||||||||||||||||||||||||||
| 166 | ); | ||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | 0 | ▶ | sub javascript { | ||||||||||||||||||||||||||
|
Subroutine
javascript: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 170 | 0 | my ( $self, $req ) = @_; | |||||||||||||||||||||||||||
| 171 | 0 | ▶ | my $res = eval { | ||||||||||||||||||||||||||
|
Condition0%0/2
eval {
do {
$self->hLoadedPlugins->{'viewer'} and $self->hLoadedPlugins->{'viewer'}->diffRule->($req, $req->{'userData'})
}
} || 0
MC/DC0%0/1
eval {
do {
$self->hLoadedPlugins->{'viewer'} and $self->hLoadedPlugins->{'viewer'}->diffRule->($req, $req->{'userData'})
}
} || 0
eval {
do {
$self->hLoadedPlugins->{'viewer'} and $self->hLoadedPlugins->{'viewer'}->diffRule->($req, $req->{'userData'})
}
}
Truth table0%0/2
A
A= eval {
do {
$self->hLoadedPlugins->{'viewer'} and $self->hLoadedPlugins->{'viewer'}->diffRule->($req, $req->{'userData'})
}
}
| |||||||||||||||||||||||||||||
| 172 | $self->hLoadedPlugins->{viewer} | ||||||||||||||||||||||||||||
| 173 | && $self->hLoadedPlugins->{viewer} | ||||||||||||||||||||||||||||
| 174 | 0 | ▶ | ->diffRule->( $req, $req->{userData} ); | ||||||||||||||||||||||||||
|
Condition0%0/3
$self->hLoadedPlugins->{'viewer'} && $self->hLoadedPlugins->{'viewer'}->diffRule->($req, $req->{'userData'})
MC/DC0%0/2
$self->hLoadedPlugins->{'viewer'} && $self->hLoadedPlugins->{'viewer'}->diffRule->($req, $req->{'userData'})
$self->hLoadedPlugins->{'viewer'}
$self->hLoadedPlugins->{'viewer'}->diffRule->($req, $req->{'userData'})
Truth table0%0/3
A && B
A= $self->hLoadedPlugins->{'viewer'}B= $self->hLoadedPlugins->{'viewer'}->diffRule->($req, $req->{'userData'})
| |||||||||||||||||||||||||||||
| 175 | } || 0; | ||||||||||||||||||||||||||||
| 176 | 0 | ▶ | print STDERR $@ if $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 177 | 0 | ▶ | my $impPrefix = $self->{impersonationPrefix} || 'real_'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'impersonationPrefix'} || 'real_'
MC/DC0%0/1
$self->{'impersonationPrefix'} || 'real_'
$self->{'impersonationPrefix'}
Truth table0%0/2
A
A= $self->{'impersonationPrefix'}
| |||||||||||||||||||||||||||||
| 178 | 0 | ▶ | my $ttl = $self->{timeout} || 72000; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'timeout'} || 72000
MC/DC0%0/1
$self->{'timeout'} || 72000
$self->{'timeout'}
Truth table0%0/2
A
A= $self->{'timeout'}
| |||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | return | ||||||||||||||||||||||||||||
| 181 | 0 | ▶ | 'var formPrefix=staticPrefix+"forms/";var confPrefix=scriptname+"confs/";var viewPrefix=scriptname+"view/";' | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 182 | . "var allowDiff=$res;" | ||||||||||||||||||||||||||||
| 183 | . "var sessionTTL=$ttl;" | ||||||||||||||||||||||||||||
| 184 | . "var impPrefix='$impPrefix';" | ||||||||||||||||||||||||||||
| 185 | . ( $self->links ? 'var links=' . to_json( $self->links ) . ';' : '' ) | ||||||||||||||||||||||||||||
| 186 | . ( | ||||||||||||||||||||||||||||
| 187 | $self->menuLinks | ||||||||||||||||||||||||||||
| 188 | ? 'var menulinks=' . to_json( $self->menuLinks ) . ';' | ||||||||||||||||||||||||||||
| 189 | : '' | ||||||||||||||||||||||||||||
| 190 | ); | ||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | 2 | ▶ | sub sendHtml { | ||||||||||||||||||||||||||
|
Subroutine
sendHtml: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 194 | 2 | my ( $self, $req, $template, %args ) = @_; | |||||||||||||||||||||||||||
| 195 | 2 | my $res = $self->SUPER::sendHtml( $req, $template, %args ); | |||||||||||||||||||||||||||
| 196 | 2 | push @{ $res->[1] }, | |||||||||||||||||||||||||||
| 197 | 'Content-Security-Policy' => $self->csp, | ||||||||||||||||||||||||||||
| 198 | 'X-Content-Type-Options' => 'nosniff', | ||||||||||||||||||||||||||||
| 199 | 'X-Frame-Options' => 'DENY', | ||||||||||||||||||||||||||||
| 200 | 'X-XSS-Protection' => '1; mode=block'; | ||||||||||||||||||||||||||||
| 201 | 2 | return $res; | |||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | 251 | ▶ | sub loadPlugin { | ||||||||||||||||||||||||||
|
Subroutine
loadPlugin: called CC=7 SCAR=23.6
Pod
undocumented
| |||||||||||||||||||||||||||||
| 205 | 251 | my ( $self, $plugin, $conf ) = @_; | |||||||||||||||||||||||||||
| 206 | 251 | ▶ | unless ($plugin) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 207 | 0 | require Carp; | |||||||||||||||||||||||||||
| 208 | 0 | Carp::confess('Calling loadPugin without arg !'); | |||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||
| 210 | 251 | my $obj; | |||||||||||||||||||||||||||
| 211 | 251 | ▶ | $plugin = "Lemonldap::NG::Manager$plugin" if ( $plugin =~ /^::/ ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | 251 | eval "require $plugin"; | |||||||||||||||||||||||||||
| 214 | 251 | ▶ | if ($@) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 215 | 0 | $self->logger->error("$plugin load error: $@"); | |||||||||||||||||||||||||||
| 216 | 0 | return 0; | |||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||
| 218 | 251 | eval { | |||||||||||||||||||||||||||
| 219 | 251 | $obj = $plugin->new( { p => $self, conf => $conf } ); | |||||||||||||||||||||||||||
| 220 | 251 | $self->logger->debug("Module $plugin loaded"); | |||||||||||||||||||||||||||
| 221 | }; | ||||||||||||||||||||||||||||
| 222 | 251 | ▶ | if ($@) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 223 | 0 | $self->error("Unable to build $plugin object: $@"); | |||||||||||||||||||||||||||
| 224 | 0 | return 0; | |||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||
| 226 | 251 | ▶ | ( $obj and $obj->init($conf) ) or return 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$obj and $obj->init($conf)
MC/DC0%0/2
$obj and $obj->init($conf)
$obj
$obj->init($conf)
Truth table33%1/3
A and B
A= $objB= $obj->init($conf)
| |||||||||||||||||||||||||||||
| 227 | 251 | return $obj; | |||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | 28 | 1; | |||||||||||||||||||||||||||
| 231 | __END__ | ||||||||||||||||||||||||||||