Macros are working now (#595)

This commit is contained in:
Xavier Guimard 2016-04-05 20:46:11 +00:00
parent 3290e2bdb9
commit 4f8830fdf6
5 changed files with 30 additions and 11 deletions

View File

@ -117,6 +117,12 @@ sub reloadConf {
return 0; return 0;
} }
# Initialize persistent session DB
unless ( $self->conf->{persistentStorage} ) {
$self->conf->{persistentStorage} = $self->conf->{globalStorage};
$self->conf->{persistentStorageOptions} = $self->conf->{globalStorageOptions};
}
# Initialize cookie domain # Initialize cookie domain
unless ( $self->conf->{domain} ) { unless ( $self->conf->{domain} ) {
$self->error('Configuration error: no domain'); $self->error('Configuration error: no domain');
@ -193,8 +199,10 @@ sub reloadConf {
$self->{"_$type"} = {}; $self->{"_$type"} = {};
if ( $self->conf->{$type} ) { if ( $self->conf->{$type} ) {
for my $name ( sort keys %{ $self->conf->{$type} } ) { for my $name ( sort keys %{ $self->conf->{$type} } ) {
my $sub = HANDLER->tsv->{jail}->jail_reval( my $sub =
"sub{return(" . $self->conf->{$type}->{$name} . ")}" ); HANDLER->tsv->{jail}->jail_reval( "sub{return("
. HANDLER->substitute( $self->conf->{$type}->{$name} )
. ")}" );
if ($sub) { if ($sub) {
$self->{"_$type"}->{$name} = $sub; $self->{"_$type"}->{$name} = $sub;
} }

View File

@ -143,6 +143,9 @@ sub authenticate {
sub setSessionInfo { sub setSessionInfo {
my ( $self, $req ) = @_; my ( $self, $req ) = @_;
# Set _user
$req->{sessionInfo}->{_user} = $req->{user};
# Get the current user module # Get the current user module
$req->{sessionInfo}->{_auth} = $self->getModule( $req, "auth" ); $req->{sessionInfo}->{_auth} = $self->getModule( $req, "auth" );
$req->{sessionInfo}->{_userDB} = $self->getModule( $req, "user" ); $req->{sessionInfo}->{_userDB} = $self->getModule( $req, "user" );

View File

@ -227,10 +227,10 @@ sub getPersistentSession {
my $ps = Lemonldap::NG::Common::Session->new( my $ps = Lemonldap::NG::Common::Session->new(
{ {
storageModule => $self->{persistentStorage}, storageModule => $self->conf->{persistentStorage},
storageModuleOptions => $self->{persistentStorageOptions}, storageModuleOptions => $self->conf->{persistentStorageOptions},
cacheModule => $self->{localSessionStorage}, cacheModule => $self->conf->{localSessionStorage},
cacheModuleOptions => $self->{localSessionStorageOptions}, cacheModuleOptions => $self->conf->{localSessionStorageOptions},
id => $pid, id => $pid,
force => 1, force => 1,
kind => "Persistent", kind => "Persistent",

View File

@ -6,7 +6,7 @@ require 't/test-lib.pm';
my $res; my $res;
init( { logLevel => 'debug' } ); init( { logLevel => 'debug', useSafeJail => 1 } );
ok( $res = &client->_get('/'), 'Unauth JSON request' ); ok( $res = &client->_get('/'), 'Unauth JSON request' );
ok( $res->[0] == 401, 'Response is 401' ) or explain( $res, 401 ); ok( $res->[0] == 401, 'Response is 401' ) or explain( $res, 401 );
@ -40,9 +40,18 @@ ok(
), ),
'Auth ajax request with good url' 'Auth ajax request with good url'
); );
count(1); ok( $res->[0] == 302, 'Get redirection' ) or explain( $res, 302 );
print STDERR Dumper($res); my %hdrs = @{ $res->[1] };
ok(
$hdrs{Location} eq 'http://test1.example.com/',
'Location is http://test1.example.com/'
) or explain( \%hdrs, 'Location => "http://test1.example.com/"' );
ok( $hdrs{'Lm-Remote-User'} eq 'dwho', 'User is set' )
or explain( \%hdrs, 'Lm-Remote-User => "dwho"' );
count(4);
#clean_sessions(); #print STDERR Dumper($res);
clean_sessions();
done_testing( count() ); done_testing( count() );

View File

@ -80,7 +80,6 @@ has app => (
sub _get { sub _get {
my ( $self, $path, %args ) = @_; my ( $self, $path, %args ) = @_;
print STDERR Data::Dumper::Dumper( \%args );
return $self->app->( return $self->app->(
{ {
'HTTP_ACCEPT' => $args{accept} 'HTTP_ACCEPT' => $args{accept}