Commit c7b4eb50 authored by Xavier Guimard's avatar Xavier Guimard

tidy with new conf

parent 2532970b
......@@ -8,7 +8,7 @@
--nobreak-before-all-operators
--blanks-before-comments
--nocuddled-else
--maximum-line-length=79
--maximum-line-length=80
--paren-tightness=1
--square-bracket-tightness=1
--space-for-semicolon
......
......@@ -9,9 +9,7 @@ our $VERSION = '2.0.0';
has confAccess => (
is => 'rw',
builder => sub {
my $res = Lemonldap::NG::Common::Conf->new(
{
(
my $res = Lemonldap::NG::Common::Conf->new( { (
ref $_[0] && $_[0]->{iniFile}
? ( confFile => $_[0]->{iniFile} )
: ()
......
......@@ -13,8 +13,7 @@ has app => ( is => 'ro', isa => 'CodeRef' );
sub _get {
my ( $self, $path, $query ) = @_;
$query //= '';
return $self->app->(
{
return $self->app->( {
'HTTP_ACCEPT' => 'application/json, text/plain, */*',
'SCRIPT_NAME' => '',
'HTTP_ACCEPT_ENCODING' => 'gzip, deflate',
......@@ -39,8 +38,7 @@ sub _post {
my ( $self, $path, $query, $body, $type, $len ) = @_;
die "$body must be a IO::Handle"
unless ( ref($body) and $body->can('read') );
return $self->app->(
{
return $self->app->( {
'HTTP_ACCEPT' => 'application/json, text/plain, */*',
'SCRIPT_NAME' => '',
'HTTP_ACCEPT_ENCODING' => 'gzip, deflate',
......@@ -69,8 +67,7 @@ sub _put {
my ( $self, $path, $query, $body, $type, $len ) = @_;
die "$body must be a IO::Handle"
unless ( ref($body) and $body->can('read') );
return $self->app->(
{
return $self->app->( {
'HTTP_ACCEPT' => 'application/json, text/plain, */*',
'SCRIPT_NAME' => '',
'HTTP_ACCEPT_ENCODING' => 'gzip, deflate',
......@@ -97,8 +94,7 @@ sub _put {
sub _del {
my ( $self, $path, $query ) = @_;
return $self->app->(
{
return $self->app->( {
'HTTP_ACCEPT' => 'application/json, text/plain, */*',
'SCRIPT_NAME' => '',
'HTTP_ACCEPT_ENCODING' => 'gzip, deflate',
......
......@@ -239,8 +239,7 @@ sub session {
sub getApacheSession {
my ( $self, $mod, $id, $info, $force ) = @_;
my $apacheSession = Lemonldap::NG::Common::Session->new(
{
my $apacheSession = Lemonldap::NG::Common::Session->new( {
storageModule => $mod->{module},
storageModuleOptions => $mod->{options},
cacheModule =>
......
......@@ -17,8 +17,7 @@ my $h;
my $inifile = "lemonldap-ng.ini";
my $confsection = "configuration";
ok(
(
ok( (
Lemonldap::NG::Common::Conf->new( type => 'bad' ) == 0
and $Lemonldap::NG::Common::Conf::msg =~
/Error: Unknown package Lemonldap::NG::Common::Conf::Backends::bad\.$/
......@@ -28,8 +27,7 @@ ok(
$h = bless {}, 'Lemonldap::NG::Common::Conf';
ok(
(
ok( (
%$h = ( %$h, %{ $h->getLocalConf( $confsection, $inifile, 0 ) } )
and exists $h->{localStorage}
),
......
......@@ -17,8 +17,7 @@ BEGIN { use_ok('Lemonldap::NG::Common::Conf') }
my $h;
ok(
$h = new Lemonldap::NG::Common::Conf(
{
$h = new Lemonldap::NG::Common::Conf( {
type => 'File',
dirName => "t/",
}
......
......@@ -27,8 +27,7 @@ SKIP: {
my $skipSQLite = 0;
ok(
$h = new Lemonldap::NG::Common::Conf(
{
$h = new Lemonldap::NG::Common::Conf( {
type => 'CDBI',
dbiChain => "DBI:SQLite:dbname=t/lmConf.sql",
dbiUser => '',
......
......@@ -27,8 +27,7 @@ SKIP: {
my $skipSQLite = 0;
ok(
$h = new Lemonldap::NG::Common::Conf(
{
$h = new Lemonldap::NG::Common::Conf( {
type => 'RDBI',
dbiChain => "DBI:SQLite:dbname=t/lmConf.sql",
dbiUser => '',
......
......@@ -18,8 +18,7 @@ SKIP: {
use_ok('Lemonldap::NG::Common::Conf');
my $h;
ok(
$h = new Lemonldap::NG::Common::Conf(
{
$h = new Lemonldap::NG::Common::Conf( {
type => 'LDAP',
ldapServer => 'ldap://localhost',
ldapConfBase => 'ou=conf,ou=websso,dc=example,dc=com',
......
......@@ -23,8 +23,7 @@ my $sessionOptions = {
LockDirectory => $dir,
};
my $session = Lemonldap::NG::Common::Session->new(
{
my $session = Lemonldap::NG::Common::Session->new( {
storageModule => $sessionModule,
storageModuleOptions => $sessionOptions,
kind => "TEST",
......@@ -43,8 +42,7 @@ use_ok('Lemonldap::NG::Common::Apache::Session::Generate::SHA256');
$sessionOptions->{generateModule} =
"Lemonldap::NG::Common::Apache::Session::Generate::SHA256";
my $session2 = Lemonldap::NG::Common::Session->new(
{
my $session2 = Lemonldap::NG::Common::Session->new( {
storageModule => $sessionModule,
storageModuleOptions => $sessionOptions,
kind => "TEST",
......
......@@ -161,8 +161,7 @@ our $_ua;
sub ua {
my ($class) = @_;
return $_ua if ($_ua);
$_ua = Lemonldap::NG::Common::UserAgent->new(
{
$_ua = Lemonldap::NG::Common::UserAgent->new( {
lwpOpts => $class->localConfig->{lwpOpts},
lwpSslOpts => $class->localConfig->{lwpSslOpts}
}
......
......@@ -59,8 +59,7 @@ sub getCDAInfos {
my $infos = {};
# Get the session
my $cdaSession = Lemonldap::NG::Common::Session->new(
{
my $cdaSession = Lemonldap::NG::Common::Session->new( {
storageModule => $class->tsv->{sessionStorageModule},
storageModuleOptions => $class->tsv->{sessionStorageOptions},
cacheModule => $class->tsv->{sessionCacheModule},
......
......@@ -37,8 +37,7 @@ sub loadVhostConfig {
my $json;
if ( $class->tsv->{useSafeJail} ) {
my $rUrl = $req->{env}->{RULES_URL}
|| (
(
|| ( (
$class->localConfig->{loopBackUrl}
|| "http://127.0.0.1:" . $req->{env}->{SERVER_PORT}
)
......
......@@ -178,8 +178,7 @@ sub configReload {
sub jailInit {
my ( $class, $conf ) = @_;
$class->tsv->{jail} = Lemonldap::NG::Handler::Main::Jail->new(
{
$class->tsv->{jail} = Lemonldap::NG::Handler::Main::Jail->new( {
useSafeJail => $conf->{useSafeJail},
customFunctions => $conf->{customFunctions},
}
......@@ -193,8 +192,7 @@ sub jailInit {
sub defaultValuesInit {
my ( $class, $conf ) = @_;
$class->tsv->{$_} = $conf->{$_} foreach (
qw(
$class->tsv->{$_} = $conf->{$_} foreach ( qw(
cookieExpiration cookieName customFunctions httpOnly
securedCookie timeout timeoutActivity
timeoutActivityInterval useRedirectOnError useRedirectOnForbidden
......
......@@ -446,8 +446,7 @@ sub retrieveSession {
# 2. Get the session from cache or backend
my $session = $req->data->{session} = (
Lemonldap::NG::Common::Session->new(
{
Lemonldap::NG::Common::Session->new( {
storageModule => $class->tsv->{sessionStorageModule},
storageModuleOptions => $class->tsv->{sessionStorageOptions},
cacheModule => $class->tsv->{sessionCacheModule},
......
......@@ -30,8 +30,7 @@ eval { Lemonldap::NG::Handler::Main->logLevelInit('error') };
ok( !$@, 'logLevelInit' );
ok(
Lemonldap::NG::Handler::Main->jailInit(
{
Lemonldap::NG::Handler::Main->jailInit( {
https => 0,
port => 0,
maintenance => 0,
......@@ -51,8 +50,7 @@ ok(
);
ok(
Lemonldap::NG::Handler::Main->defaultValuesInit(
{
Lemonldap::NG::Handler::Main->defaultValuesInit( {
https => 0,
port => 0,
maintenance => 0,
......@@ -72,8 +70,7 @@ ok(
);
ok(
Lemonldap::NG::Handler::Main->locationRulesInit(
{
Lemonldap::NG::Handler::Main->locationRulesInit( {
'locationRules' => {
'www1' => {
'default' => 'accept',
......
......@@ -13,8 +13,7 @@ ok( $app = module( Lemonldap::NG::Handler::PSGI::Try->new() ), 'New object' );
init();
ok(
$app->init(
{
$app->init( {
configStorage => { type => 'File', dirName => 't' },
localSessionStorage => '',
logLevel => 'warn',
......
......@@ -105,8 +105,7 @@ sub _get {
my ( $self, $path, $query, $host, $cookie, %custom ) = @_;
$query //= '';
$host ||= 'test1.example.com';
return $self->app->(
{
return $self->app->( {
'HTTP_ACCEPT' => 'text/html',
'SCRIPT_NAME' => 'lmAuth',
'SERVER_NAME' => '127.0.0.1',
......
......@@ -274,9 +274,7 @@ sub attributes {
'authChoiceModules' => {
'keyMsgFail' => '__badChoiceKey__',
'keyTest' => qr/^(\d*)?[a-zA-Z0-9_]+$/,
'select' => [
[
{
'select' => [ [ {
'k' => 'Apache',
'v' => 'Apache'
},
......@@ -373,8 +371,7 @@ sub attributes {
'v' => 'customModule'
}
],
[
{
[ {
'k' => 'AD',
'v' => 'Active Directory'
},
......@@ -439,8 +436,7 @@ sub attributes {
'v' => 'customModule'
}
],
[
{
[ {
'k' => 'AD',
'v' => 'Active Directory'
},
......@@ -481,8 +477,7 @@ sub attributes {
},
'authentication' => {
'default' => 'Demo',
'select' => [
{
'select' => [ {
'k' => 'Apache',
'v' => 'Apache'
},
......@@ -637,8 +632,7 @@ sub attributes {
},
'casAccessControlPolicy' => {
'default' => 'none',
'select' => [
{
'select' => [ {
'k' => 'none',
'v' => 'None'
},
......@@ -782,8 +776,7 @@ qr/(?:(?:https?):\/\/(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.]
},
'combModules' => {
'keyTest' => qr/^\w+$/,
'select' => [
{
'select' => [ {
'k' => 'Apache',
'v' => 'Apache'
},
......@@ -886,8 +879,7 @@ qr/(?:(?:https?):\/\/(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.]
},
'confirmFormMethod' => {
'default' => 'post',
'select' => [
{
'select' => [ {
'k' => 'get',
'v' => 'GET'
},
......@@ -1185,8 +1177,7 @@ qr/^(?:\*\.)?(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][
},
'infoFormMethod' => {
'default' => 'get',
'select' => [
{
'select' => [ {
'k' => 'get',
'v' => 'GET'
},
......@@ -1392,8 +1383,7 @@ qr/^(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-zA-Z0-
},
'ldapSearchDeref' => {
'default' => 'find',
'select' => [
{
'select' => [ {
'k' => 'never',
'v' => 'never'
},
......@@ -1750,8 +1740,7 @@ qr/^(?:\*\.)?(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][
},
'oidcOPMetaDataOptionsDisplay' => {
'default' => '',
'select' => [
{
'select' => [ {
'k' => '',
'v' => ''
},
......@@ -1805,8 +1794,7 @@ qr/^(?:\*\.)?(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][
},
'oidcOPMetaDataOptionsTokenEndpointAuthMethod' => {
'default' => 'client_secret_post',
'select' => [
{
'select' => [ {
'k' => 'client_secret_post',
'v' => 'client_secret_post'
},
......@@ -1872,8 +1860,7 @@ qr/^(?:\*\.)?(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][
},
'oidcRPMetaDataOptionsIDTokenSignAlg' => {
'default' => 'HS512',
'select' => [
{
'select' => [ {
'k' => 'none',
'v' => 'None'
},
......@@ -1910,8 +1897,7 @@ qr/^(?:\*\.)?(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][
},
'oidcRPMetaDataOptionsLogoutType' => {
'default' => 'front',
'select' => [
{
'select' => [ {
'k' => 'front',
'v' => 'Front Channel'
},
......@@ -2108,8 +2094,7 @@ qr/^(?:\*\.)?(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][
},
'passwordDB' => {
'default' => 'Demo',
'select' => [
{
'select' => [ {
'k' => 'AD',
'v' => 'Active Directory'
},
......@@ -2235,8 +2220,7 @@ qr/(?:(?:https?):\/\/(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.]
},
'portalSkin' => {
'default' => 'bootstrap',
'select' => [
{
'select' => [ {
'k' => 'bootstrap',
'v' => 'Bootstrap'
}
......@@ -2244,8 +2228,7 @@ qr/(?:(?:https?):\/\/(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.]
'type' => 'portalskin'
},
'portalSkinBackground' => {
'select' => [
{
'select' => [ {
'k' => '',
'v' => 'None'
},
......@@ -2347,8 +2330,7 @@ qr/^(?:\*\.)?(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][
},
'redirectFormMethod' => {
'default' => 'get',
'select' => [
{
'select' => [ {
'k' => 'get',
'v' => 'GET'
},
......@@ -2364,8 +2346,7 @@ qr/^(?:\*\.)?(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][
},
'registerDB' => {
'default' => 'Null',
'select' => [
{
'select' => [ {
'k' => 'AD',
'v' => 'Active Directory'
},
......@@ -2596,8 +2577,7 @@ qr/(?:(?:https?):\/\/(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.]
},
'samlIDPMetaDataOptionsEncryptionMode' => {
'default' => 'none',
'select' => [
{
'select' => [ {
'k' => 'none',
'v' => 'None'
},
......@@ -2629,8 +2609,7 @@ qr/(?:(?:https?):\/\/(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.]
},
'samlIDPMetaDataOptionsNameIDFormat' => {
'default' => '',
'select' => [
{
'select' => [ {
'k' => '',
'v' => ''
},
......@@ -2679,8 +2658,7 @@ qr/(?:(?:https?):\/\/(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.]
},
'samlIDPMetaDataOptionsRequestedAuthnContext' => {
'default' => '',
'select' => [
{
'select' => [ {
'k' => '',
'v' => ''
},
......@@ -2717,8 +2695,7 @@ qr/(?:(?:https?):\/\/(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.]
},
'samlIDPMetaDataOptionsSLOBinding' => {
'default' => '',
'select' => [
{
'select' => [ {
'k' => '',
'v' => ''
},
......@@ -2739,8 +2716,7 @@ qr/(?:(?:https?):\/\/(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.]
},
'samlIDPMetaDataOptionsSSOBinding' => {
'default' => '',
'select' => [
{
'select' => [ {
'k' => '',
'v' => ''
},
......@@ -2898,8 +2874,7 @@ qr/(?:(?:https?):\/\/(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.]
},
'samlServiceSignatureMethod' => {
'default' => 'RSA_SHA1',
'select' => [
{
'select' => [ {
'k' => 'RSA_SHA1',
'v' => 'RSA SHA1'
},
......@@ -2944,8 +2919,7 @@ qr/(?:(?:https?):\/\/(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.]
},
'samlSPMetaDataOptionsEncryptionMode' => {
'default' => 'none',
'select' => [
{
'select' => [ {
'k' => 'none',
'v' => 'None'
},
......@@ -2966,8 +2940,7 @@ qr/(?:(?:https?):\/\/(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.]
},
'samlSPMetaDataOptionsNameIDFormat' => {
'default' => '',
'select' => [
{
'select' => [ {
'k' => '',
'v' => ''
},
......@@ -3100,8 +3073,7 @@ qr/(?:(?:https?):\/\/(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.]
},
'securedCookie' => {
'default' => 0,
'select' => [
{
'select' => [ {
'k' => '0',
'v' => 'unsecuredCookie'
},
......@@ -3221,8 +3193,7 @@ qr/^(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-
},
'SMTPTLS' => {
'default' => '',
'select' => [
{
'select' => [ {
'k' => '',
'v' => 'none'
},
......@@ -3400,8 +3371,7 @@ qr/^(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-
},
'userDB' => {
'default' => 'Same',
'select' => [
{
'select' => [ {
'k' => 'Same',
'v' => 'Same'
},
......@@ -3483,8 +3453,7 @@ qr/^(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-
},
'vhostType' => {
'default' => 'Main',
'select' => [
{
'select' => [ {
'k' => 'Main',
'v' => 'Main'
},
......
......@@ -269,8 +269,7 @@ $defaultAttr}
foreach ( @simpleHashKeys, @doubleHashKeys, sort keys %cnodesRe ) {
$ra->add($_);
}
foreach (
qw(
foreach ( qw(
exportedHeaders locationRules post vhostOptions
samlIDPMetaDataXML samlIDPMetaDataExportedAttributes
samlIDPMetaDataOptions samlSPMetaDataXML
......@@ -462,8 +461,7 @@ sub scanTree {
$jleaf->{"_$n"} = [];
$self->scanTree( $leaf->{$n}, $jleaf->{"_$n"}, $prefix,
"$path.$nodeName\[$ord\]" );
if (
(
if ( (
$leaf->{title} eq 'authParams'
and $n eq 'nodes_cond'
)
......
......@@ -2944,8 +2944,7 @@ m{^(?:ldapi://[^/]*/?|\w[\w\-\.]*(?::\d{1,5})?|ldap(?:s|\+tls)?://\w[\w\-\.]*(?:
keyTest => qr/^(\d*)?[a-zA-Z0-9_]+$/,
keyMsgFail => '__badChoiceKey__',
test => sub { 1 },
select => [
[
select => [ [
{ k => 'Apache', v => 'Apache' },
{ k => 'AD', v => 'Active Directory' },
{
......
......@@ -103,8 +103,7 @@ sub cTrees {
{
title => "samlSPMetaDataOptions",
help => 'idpsaml.html#options',
nodes => [
{
nodes => [ {
title => "samlSPMetaDataOptionsAuthnResponse",
form => 'simpleInputContainer',
nodes => [
......@@ -144,8 +143,7 @@ sub cTrees {
'oidcOPMetaDataExportedVars',
{
title => 'oidcOPMetaDataOptions',
nodes => [
{
nodes => [ {
title => 'oidcOPMetaDataOptionsConfiguration',
form => 'simpleInputContainer',
nodes => [
......@@ -187,8 +185,7 @@ sub cTrees {
'oidcRPMetaDataExportedVars',
{
title => 'oidcRPMetaDataOptions',
nodes => [
{
nodes => [ {
title => 'oidcRPMetaDataOptionsAuthentication',
form => 'simpleInputContainer',
nodes => [
......@@ -225,8 +222,7 @@ sub cTrees {
},
'oidcRPMetaDataOptionsExtraClaims',
],
casSrvMetaDataNode => [
{
casSrvMetaDataNode => [ {
title => 'casSrvMetaDataOptions',
form => 'simpleInputContainer',