Commit c7b4eb50 authored by Xavier Guimard's avatar Xavier Guimard

tidy with new conf

parent 2532970b
Pipeline #4273 passed with stages
in 10 minutes and 46 seconds
......@@ -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',
......
......@@ -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',
nodes => [
......@@ -240,8 +236,7 @@ sub cTrees {
'casSrvMetaDataExportedVars',
'casSrvMetaDataOptionsProxiedServices',
],
casAppMetaDataNode => [
{
casAppMetaDataNode => [ {
title => 'casAppMetaDataOptions',
form => 'simpleInputContainer',
nodes => [
......
......@@ -24,11 +24,9 @@ our $VERSION = '2.0.2';
# * confirmFormMethod
# * redirectFormMethod
sub tree {
return [
{
return [ {
title => 'generalParameters',
nodes => [
{
nodes => [ {
title => 'portalParams',
help => 'portal.html',
nodes => [
......@@ -36,8 +34,7 @@ sub tree {
{
title => 'portalMenu',
help => 'portalmenu.html',
nodes => [
{
nodes => [ {
title => 'portalModules',
form => 'simpleInputContainer',
nodes => [
......@@ -119,8 +116,7 @@ sub tree {
nodes => [
'authentication', 'userDB', 'passwordDB', 'registerDB'
],
nodes_cond => [
{
nodes_cond => [ {
title => 'adParams',
help => 'authad.html',
form => 'simpleInputContainer',
......@@ -152,8 +148,7 @@ sub tree {
{
title => 'dbiConnection',
help => 'authdbi.html#connection',
nodes => [
{
nodes => [ {
title => 'dbiConnectionAuth',
form => 'simpleInputContainer',
nodes => [
......@@ -427,8 +422,7 @@ sub tree {
{
title => 'issuerParams',
help => 'start.html#identity_provider',
nodes => [
{
nodes => [ {
title => 'issuerDBSAML',
help => 'idpsaml.html',
form => 'simpleInputContainer',
......@@ -601,8 +595,7 @@ sub tree {
{
title => 'passwordManagement',
help => 'resetpassword.html',
nodes => [
{
nodes => [ {
title => 'mailContent',
form => 'simpleInputContainer',
nodes => [
......@@ -649,8 +642,7 @@ sub tree {
{
title => 'secondFactors',
help => 'secondfactor.html',
nodes => [
{
nodes => [ {
title => 'utotp2f',
help => 'utotp2f.html',
form => 'simpleInputContainer',
......@@ -839,8 +831,7 @@ sub tree {
{
title => 'samlServiceSecurity',
help => 'samlservice.html#security_parameters',
nodes => [
{
nodes => [ {
title => 'samlServiceSecuritySig',
form => 'RSAKey',
group => [
......@@ -957,8 +948,7 @@ sub tree {
{
title => 'samlAttributeAuthorityDescriptor',
help => 'samlservice.html#attribute_authority',
nodes => [
{
nodes => [ {
title =>
'samlAttributeAuthorityDescriptorAttributeService',
nodes => [
......@@ -1026,8 +1016,7 @@ sub tree {
'oidcServiceMetaDataAuthnContext',
{
title => 'oidcServiceMetaDataSecurity',
nodes => [
{
nodes => [ {
title => 'oidcServiceMetaDataKeys',
form => 'RSAKeyNoPassword',
group => [
......
......@@ -234,8 +234,7 @@ sub _setKey {
sub _save {
my ( $self, $new ) = @_;
require Lemonldap::NG::Manager::Conf::Parser;
my $parser = Lemonldap::NG::Manager::Conf::Parser->new(
{
my $parser = Lemonldap::NG::Manager::Conf::Parser->new( {
newConf => $new,
refConf => $self->mgr->currentConf,
req => $self->req
......
......@@ -90,10 +90,8 @@ sub diff {
while ( my $key = shift @{ $keys[1] } ) {
next unless ( defined( $conf[1]->{$key} ) );
next if ( $key =~ $hashParameters and not( %{ $conf[1]->{$key} } ) );
if (
(
not ref( $conf[1]->{$key} ) and not(
(
if ( (
not ref( $conf[1]->{$key} ) and not( (
defined defaultValue( $self, $key )
and $conf[1]->{$key} eq defaultValue( $self, $key )
)
......
......@@ -1070,8 +1070,7 @@ sub _unitTest {
my $msg = $attr->{msgFail} // $type->{msgFail};
$res = 0
unless (
$self->_execTest(
{
$self->_execTest( {
keyTest => $attr->{keyTest} // $type->{keyTest},
keyMsgFail => $attr->{keyMsgFail}
// $type->{keyMsgFail},
......
......@@ -499,8 +499,7 @@ sub tests {
return 1 unless ( defined $conf->{totp2fDigits} );
return (
1,
(
(
( (
$conf->{totp2fDigits} == 6
or $conf->{totp2fDigits} == 8
)
......
......@@ -109,8 +109,7 @@ sub setNotifAccess {
unless (
eval {
$self->notifAccess(
$type->new(
{
$type->new( {
%{ $self->{notificationStorageOptions} },
p => $self,
conf => $self
......
......@@ -236,8 +236,7 @@ sub sessions {
value => $uid,
count => scalar( @{ $r->{$uid} } ),
sessions => [
map {
{
map { {
session => $_->{_sessionId},
date => $_->{_utime}
}
......
......@@ -30,8 +30,7 @@ my $currentConf;
# 1
ok(
$currentConf = Lemonldap::NG::Common::Conf->new(
{
$currentConf = Lemonldap::NG::Common::Conf->new( {
confFile => 'test/lemonldap-ng.ini',
noCache => 1,
}
......@@ -43,8 +42,7 @@ $Lemonldap::NG::Common::Conf::msg = '';
# 2
my $new;
ok(
$new = Lemonldap::NG::Common::Conf->new(
{
$new = Lemonldap::NG::Common::Conf->new( {
type => $module,
%$args,
force => 1,
......
......@@ -64,8 +64,7 @@ count(2);
foreach my $query (@hkeys) {
my $href = &client->jsonResponse( "/confs/1/$query", '' );
ok(
(
ok( (
( ref $href eq 'ARRAY' )
or ( ( ref $href eq 'HASH' )
and ( $href->{error} =~ /setDefault$/ ) )
......
......@@ -129,8 +129,7 @@ done_testing( count() );
`rm -rf t/sessions`;
sub changes {
return [
{
return [ {
'key' => 'portal',
'new' => 'http://auth2.example.com/',
'old' => 'http://auth.example.com/'
......
......@@ -107,8 +107,7 @@ done_testing( count() );
`rm -rf t/sessions`;
sub changes {
return [
{
return [ {
'key' => 'portal',
'new' => 'http://auth2.example.com/',
'old' => 'http://auth.example.com/'
......
......@@ -20,8 +20,7 @@ ok( $res->[0] == 200, "Result code is 200" );
ok( $resBody = from_json( $res->[2]->[0] ), "Result body contains JSON text" );
ok( $resBody->{result} == 0, "JSON response contains \"result:0\"" )
or print STDERR Dumper($res);
ok(
(
ok( (
$resBody->{details}->{__errors__}
and @{ $resBody->{details}->{__errors__} } == 1
),
......
......@@ -15,8 +15,7 @@ $count += 2;
foreach my $attr ( keys %$attrs ) {
next if ( $attr =~ /^virtualHosts|.*MetaDataNodes|applicationList$/ );
ok(
(
ok( (
ref( $attrs->{$attr}->{test} )
or ref( $types->{ $attrs->{$attr}->{type} }->{test} )
),
......@@ -24,8 +23,7 @@ foreach my $attr ( keys %$attrs ) {
);
$count++;
if ( $attr =~ qr/^$simpleHashKeys$/o ) {
ok(
(
ok( (
ref $attrs->{$attr}->{keyTest}
or ref $types->{ $attrs->{$attr}->{type} }->{keyTest}
),
......
......@@ -13,8 +13,7 @@ sub newSession {
my ( $uid, $ip ) = splice @_;
my $tmp;
ok(
$tmp = Lemonldap::NG::Common::Session->new(
{
$tmp = Lemonldap::NG::Common::Session->new( {
storageModule => 'Apache::Session::File',
storageModuleOptions => {
Directory => 't/sessions',
......@@ -27,8 +26,7 @@ sub newSession {
'Sessions module'
);
count(1);
$tmp->update(
{
$tmp->update( {
ipAddr => $ip,
_whatToTrace => $uid,
uid => $uid,
......@@ -98,22 +96,19 @@ count(4);