Start templates (#595)

environments/ppa-mbqj77/deployments/1
Xavier Guimard 9 years ago
parent 4f8830fdf6
commit 2fb42670f8
  1. 26
      lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf.pm
  2. 19
      lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Init.pm
  3. 15
      lemonldap-ng-portal/t/01-AuthDemo.t
  4. 1
      lemonldap-ng-portal/t/test-lib.pm

@ -169,6 +169,18 @@ sub getConf {
unless ( ref( $self->{refLocalStorage} ) ) {
$msg .= "Get remote configuration (localStorage unavailable).\n";
$r = $self->getDBConf($args);
unless ( $args->{raw} ) {
# Adapt some values before storing in local cache
# Get default values
my $defaultValues =
Lemonldap::NG::Common::Conf::DefaultValues->defaultValues();
foreach my $k ( keys %$defaultValues ) {
$r->{$k} //= $defaultValues->{$k};
}
}
}
else {
eval { $r = $self->{refLocalStorage}->get('conf') }
@ -187,20 +199,6 @@ sub getConf {
$r = $self->getDBConf($args);
return undef unless ( $r->{cfgNum} );
# TODO: default values may not be set here
unless ( $args->{raw} ) {
# Adapt some values before storing in local cache
# Get default values
my $defaultValues =
Lemonldap::NG::Common::Conf::DefaultValues
->defaultValues();
foreach my $k ( keys %$defaultValues ) {
$r->{$k} //= $defaultValues->{$k};
}
}
# Convert old option useXForwardedForIP into trustedProxies
if ( defined $r->{useXForwardedForIP}
and $r->{useXForwardedForIP} == 1 )

@ -87,13 +87,8 @@ sub init {
sub reloadConf {
my ( $self, $conf ) = @_;
# Delete keys that will be generated
foreach my $key (
qw(persistentStorage samlStorage casStorage captchaStorage oidcStorage)
)
{
delete $self->conf->{$key};
}
# Reinitialize $self->conf
%{ $self->{conf} } = %{ $self->localConfig };
# Reinitialize arrays
foreach (
@ -105,10 +100,13 @@ sub reloadConf {
# Load conf in portal object
foreach my $key ( keys %$conf ) {
$self->conf->{$key} =
$self->localConfig->{$key} // $conf->{$key};
$self->{conf}->{$key} ||= $conf->{$key};
}
# Initialize templateDir
$self->{templateDir} =
$self->conf->{templateDir} . '/' . $self->conf->{portalSkin};
# Initialize session DBs
unless ( $self->conf->{globalStorage} ) {
$self->error(
@ -120,7 +118,8 @@ sub reloadConf {
# Initialize persistent session DB
unless ( $self->conf->{persistentStorage} ) {
$self->conf->{persistentStorage} = $self->conf->{globalStorage};
$self->conf->{persistentStorageOptions} = $self->conf->{globalStorageOptions};
$self->conf->{persistentStorageOptions} =
$self->conf->{globalStorageOptions};
}
# Initialize cookie domain

@ -50,6 +50,21 @@ ok( $hdrs{'Lm-Remote-User'} eq 'dwho', 'User is set' )
or explain( \%hdrs, 'Lm-Remote-User => "dwho"' );
count(4);
#ok(
# $res = &client->_get(
# '/',
# query => 'url=aHR0cHM6Ly90LmV4YW1wbGUuY29tLw==',
# cookie => "lemonldap=$id",
# accept => 'text/html'
# ),
# 'Auth request with bad url'
#);
#ok( $res->[0] == 200, 'Get redirection' ) or explain( $res, 200 );
#my %hdrs = @{ $res->[1] };
#ok( $hdrs{'Lm-Remote-User'} eq 'dwho', 'User is set' )
# or explain( \%hdrs, 'Lm-Remote-User => "dwho"' );
#count(3);
#print STDERR Dumper($res);
clean_sessions();

@ -19,6 +19,7 @@ sub init {
$ini->{configStorage} ||= { type => 'File', dirName => 't' };
$ini->{logLevel} ||= 'error';
$ini->{cookieName} ||= 'lemonldap';
$ini->{templateDir} ||= 'site/templates';
$ini->{securedCookie} //= 0;
$ini->{https} //= 0;
ok( $client = My::Cli->new(), 'Portal app' );

Loading…
Cancel
Save