Commit 04658502 authored by Xavier Guimard's avatar Xavier Guimard

Allow hashes in Combination module overload (Closes: #1707)

parent f1cb8d23
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";
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment