Allow hashes in Combination module overload (Closes: #1707)
This commit is contained in:
parent
f1cb8d236e
commit
046585020f
|
@ -1,14 +1,27 @@
|
|||
package Lemonldap::NG::Common::Conf::Wrapper;
|
||||
|
||||
use strict;
|
||||
use JSON;
|
||||
|
||||
our $VERSION = '2.0.0';
|
||||
|
||||
sub TIEHASH {
|
||||
my ( $class, $conf, $overrides ) = @_;
|
||||
my %h = %$overrides;
|
||||
foreach ( keys %h ) {
|
||||
if ( $h{$_} =~ /^[\[\{]/ ) {
|
||||
my $tmp = eval { JSON::from_json( $h{$_} ) };
|
||||
if ($@) {
|
||||
print STDERR "Wrapper: unable to compile $_ key, skipping\n";
|
||||
}
|
||||
else {
|
||||
$h{$_} = $tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
return bless {
|
||||
_wrapC => $conf,
|
||||
_wrapO => $overrides,
|
||||
_wrapO => \%h,
|
||||
}, $class;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ sub set_user {
|
|||
sub set_header_in {
|
||||
my ( $class, $req, %headers ) = @_;
|
||||
while ( my ( $h, $v ) = each %headers ) {
|
||||
$req->{env}->{ cgiName($h) } = $v;
|
||||
$req->{env}->{ cgiName($h) } = $v if ( defined $v );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -47,8 +47,9 @@ sub try {
|
|||
|
||||
sub iniCmb {
|
||||
my $expr = shift;
|
||||
count(1);
|
||||
if (
|
||||
my $res = LLNG::Manager::Test->new( {
|
||||
my $client = LLNG::Manager::Test->new( {
|
||||
ini => {
|
||||
logLevel => 'error',
|
||||
useSafeJail => 1,
|
||||
|
@ -68,7 +69,7 @@ sub iniCmb {
|
|||
dbiAuthLoginCol => 'user',
|
||||
dbiAuthPasswordCol => 'password',
|
||||
dbiAuthPasswordHash => '',
|
||||
dbiExportedVars => {},
|
||||
dbiExportedVars => '{"user":"user"}',
|
||||
}
|
||||
},
|
||||
Dm => {
|
||||
|
@ -84,7 +85,15 @@ sub iniCmb {
|
|||
)
|
||||
{
|
||||
pass(qq'Expression loaded: "$expr"');
|
||||
ok(
|
||||
$client->{p}->{loadedModules}->{'Lemonldap::NG::Portal::Auth::DBI'}
|
||||
->{conf}->{dbiExportedVars}->{user} eq 'user',
|
||||
'JSON is parsed'
|
||||
);
|
||||
count(1);
|
||||
return $res;
|
||||
return $client;
|
||||
}
|
||||
else {
|
||||
fail "Unable to build object";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user