Commit 5886cbe2 authored by Xavier Guimard's avatar Xavier Guimard

Tidy

parent e2b026b7
...@@ -16,8 +16,10 @@ BEGIN { use_ok('Lemonldap::NG::Common::Conf') } ...@@ -16,8 +16,10 @@ BEGIN { use_ok('Lemonldap::NG::Common::Conf') }
my $h; my $h;
ok( $h = new Lemonldap::NG::Common::Conf( ok(
{ type => 'File', $h = new Lemonldap::NG::Common::Conf(
{
type => 'File',
dirName => "t/", dirName => "t/",
} }
), ),
...@@ -37,15 +39,15 @@ my @test = ( ...@@ -37,15 +39,15 @@ my @test = (
{ cfgNum => 1, test => 'éà' } { cfgNum => 1, test => 'éà' }
); );
for ( my $i = 0; $i < @test; $i++ ) { for ( my $i = 0 ; $i < @test ; $i++ ) {
ok( $h->store( $test[$i] ) == 1, "Test $i is stored" ) ok( $h->store( $test[$i] ) == 1, "Test $i is stored" )
or print STDERR "$Lemonldap::NG::Common::Conf::msg $!"; or print STDERR "$Lemonldap::NG::Common::Conf::msg $!";
$count++; $count++;
my $cfg; my $cfg;
ok( $cfg = $h->load(1), "Test $i can be read" ) ok( $cfg = $h->load(1), "Test $i can be read" )
or print STDERR $Lemonldap::NG::Common::Conf::msg; or print STDERR $Lemonldap::NG::Common::Conf::msg;
ok( $cfg->{test} eq $test[$i]->{test}, "Test $i is restored" ) ok( $cfg->{test} eq $test[$i]->{test}, "Test $i is restored" )
or print STDERR "Expect $cfg->{test} eq $test[$i]->{test}\n"; or print STDERR "Expect $cfg->{test} eq $test[$i]->{test}\n";
$count += 2; $count += 2;
} }
......
...@@ -109,7 +109,7 @@ sub statusInit { ...@@ -109,7 +109,7 @@ sub statusInit {
exec $perl_exec, '-MLemonldap::NG::Handler::Lib::Status', exec $perl_exec, '-MLemonldap::NG::Handler::Lib::Status',
# Insert @INC in Perl path # Insert @INC in Perl path
map( {"-I$_"} @INC ), map( { "-I$_" } @INC ),
# Command to launch # Command to launch
'-e', '&Lemonldap::NG::Handler::Lib::Status::run()', '-e', '&Lemonldap::NG::Handler::Lib::Status::run()',
......
...@@ -5,21 +5,22 @@ use Data::Dumper; ...@@ -5,21 +5,22 @@ use Data::Dumper;
require 't/test-psgi-lib.pm'; require 't/test-psgi-lib.pm';
init('Lemonldap::NG::Handler::PSGI', { init(
vhostOptions => { 'Lemonldap::NG::Handler::PSGI',
'test1.example.com' => { {
vhostHttps => 1, vhostOptions => {
vhostPort => 443, 'test1.example.com' => {
vhostHttps => 1,
vhostPort => 443,
},
}, },
}, locationRules => {},
locationRules => { exportedHeaders => {},
}, https => undef,
exportedHeaders => { port => undef,
}, maintenance => undef,
https => undef, }
port => undef, );
maintenance => undef,
});
my $res; my $res;
......
...@@ -45,7 +45,7 @@ sub addRoutes { ...@@ -45,7 +45,7 @@ sub addRoutes {
$self->setTypes($conf); $self->setTypes($conf);
$self->{multiValuesSeparator} ||= '; '; $self->{multiValuesSeparator} ||= '; ';
$self->{hiddenAttributes} //= "_password"; $self->{hiddenAttributes} //= "_password";
$self->{TOTPCheck} = $self->{U2FCheck} = $self->{UBKCheck} = '1'; $self->{TOTPCheck} = $self->{U2FCheck} = $self->{UBKCheck} = '1';
} }
################### ###################
......
...@@ -2203,8 +2203,8 @@ sub attributes { ...@@ -2203,8 +2203,8 @@ sub attributes {
default => 0, default => 0,
}, },
samlIDPMetaDataOptionsUserAttribute => { type => 'text', }, samlIDPMetaDataOptionsUserAttribute => { type => 'text', },
samlIDPMetaDataOptionsDisplayName => { type => 'text', }, samlIDPMetaDataOptionsDisplayName => { type => 'text', },
samlIDPMetaDataOptionsIcon => { type => 'text', }, samlIDPMetaDataOptionsIcon => { type => 'text', },
# SP keys # SP keys
samlSPMetaDataExportedAttributes => { samlSPMetaDataExportedAttributes => {
...@@ -2563,10 +2563,9 @@ m{^(?:ldapi://[^/]*/?|\w[\w\-\.]*(?::\d{1,5})?|ldap(?:s|\+tls)?://\w[\w\-\.]*(?: ...@@ -2563,10 +2563,9 @@ m{^(?:ldapi://[^/]*/?|\w[\w\-\.]*(?::\d{1,5})?|ldap(?:s|\+tls)?://\w[\w\-\.]*(?:
documentation => 'LDAP filter for auth search' documentation => 'LDAP filter for auth search'
}, },
ldapGroupDecodeSearchedValue => { ldapGroupDecodeSearchedValue => {
default => 0, default => 0,
type => 'bool', type => 'bool',
documentation => documentation => 'Decode value before searching it in LDAP groups',
'Decode value before searching it in LDAP groups',
}, },
ldapGroupRecursive => { ldapGroupRecursive => {
default => 0, default => 0,
......
...@@ -88,7 +88,7 @@ sub cTrees { ...@@ -88,7 +88,7 @@ sub cTrees {
"samlIDPMetaDataOptionsCheckAudience" "samlIDPMetaDataOptionsCheckAudience"
] ]
}, },
{ {
title => "samlIDPMetaDataOptionsDisplay", title => "samlIDPMetaDataOptionsDisplay",
form => 'simpleInputContainer', form => 'simpleInputContainer',
nodes => [ nodes => [
......
...@@ -19,44 +19,50 @@ mkdir 't/sessions'; ...@@ -19,44 +19,50 @@ mkdir 't/sessions';
my ( $res, $resBody ); my ( $res, $resBody );
ok( $res = &client->_post( '/confs/', 'cfgNum=1', &body, 'application/json' ), ok( $res = &client->_post( '/confs/', 'cfgNum=1', &body, 'application/json' ),
"Request succeed" "Request succeed" );
);
ok( $res->[0] == 200, "Result code is 200" ); ok( $res->[0] == 200, "Result code is 200" );
ok( $resBody = from_json( $res->[2]->[0] ), ok( $resBody = from_json( $res->[2]->[0] ), "Result body contains JSON text" );
"Result body contains JSON text" );
ok( $resBody->{result} == 0, "JSON response contains \"result:0\"" ) ok( $resBody->{result} == 0, "JSON response contains \"result:0\"" )
or print STDERR Dumper($resBody); or print STDERR Dumper($resBody);
ok( $resBody->{needConfirm} == 1, "JSON response contains \"needConfirm:1\"" ) ok( $resBody->{needConfirm} == 1, "JSON response contains \"needConfirm:1\"" )
or print STDERR Dumper($resBody); or print STDERR Dumper($resBody);
ok( @{ $resBody->{details}->{__warnings__} } == 3, ok(
@{ $resBody->{details}->{__warnings__} } == 3,
'JSON response contains 3 warnings' 'JSON response contains 3 warnings'
) or print STDERR Dumper($resBody); ) or print STDERR Dumper($resBody);
foreach my $i (0 .. 2) { foreach my $i ( 0 .. 2 ) {
ok( $resBody->{details}->{__warnings__}->[$i]->{message} ok(
=~ /\b(unprotected|cross-domain-authentication|retries)\b/, $resBody->{details}->{__warnings__}->[$i]->{message} =~
/\b(unprotected|cross-domain-authentication|retries)\b/,
"Warning with 'unprotect', 'CDA' or 'retries' found" "Warning with 'unprotect', 'CDA' or 'retries' found"
) or print STDERR Dumper($resBody); ) or print STDERR Dumper($resBody);
} }
count(4); count(4);
ok( @{ $resBody->{details}->{__needConfirmation__} } == 1, ok(
@{ $resBody->{details}->{__needConfirmation__} } == 1,
'JSON response contains 1 needConfirmation' 'JSON response contains 1 needConfirmation'
) or print STDERR Dumper($resBody); ) or print STDERR Dumper($resBody);
ok( $resBody->{details}->{__needConfirmation__}->[0]->{message} ok(
=~ /\bplugin is enabled without CSRF Token neither Captcha required\b/, $resBody->{details}->{__needConfirmation__}->[0]->{message} =~
/\bplugin is enabled without CSRF Token neither Captcha required\b/,
"Warning with confirmation needed found" "Warning with confirmation needed found"
) or print STDERR Dumper($resBody); ) or print STDERR Dumper($resBody);
ok(
ok( @{ $resBody->{details}->{__changes__} } == 22, @{ $resBody->{details}->{__changes__} } == 22,
'JSON response contains 24 changes' 'JSON response contains 24 changes'
) or print STDERR Dumper($resBody); ) or print STDERR Dumper($resBody);
#print STDERR Dumper($resBody); #print STDERR Dumper($resBody);
ok( $res = &client->_post( '/confs/', 'cfgNum=1&force=1', &body, 'application/json' ), ok(
$res = &client->_post(
'/confs/', 'cfgNum=1&force=1', &body, 'application/json'
),
"Request succeed" "Request succeed"
); );
...@@ -79,13 +85,13 @@ while ( my $c = shift @{ $resBody->{details}->{__changes__} } ) { ...@@ -79,13 +85,13 @@ while ( my $c = shift @{ $resBody->{details}->{__changes__} } ) {
} }
else { else {
ok( ( $cmp1 - @changes ) == ( $cmp2 - @cmsg ), qq("$c->{key}" found) ) ok( ( $cmp1 - @changes ) == ( $cmp2 - @cmsg ), qq("$c->{key}" found) )
or print STDERR 'Expect: ' or print STDERR 'Expect: '
. ( $cmp1 - @changes ) . ( $cmp1 - @changes )
. ', got: ' . ', got: '
. ( $cmp2 - @cmsg ) . ( $cmp2 - @cmsg )
. "\nExpect: " . "\nExpect: "
. Dumper( \@d1 ) . "Got: " . Dumper( \@d1 ) . "Got: "
. Dumper( \@d2 ); . Dumper( \@d2 );
} }
count(1); count(1);
} }
...@@ -93,9 +99,9 @@ ok( !@changes, 'All changes detected' ) or $bug = 1; ...@@ -93,9 +99,9 @@ ok( !@changes, 'All changes detected' ) or $bug = 1;
if ($bug) { if ($bug) {
print STDERR 'Expected not found: ' print STDERR 'Expected not found: '
. Dumper( \@changes ) . Dumper( \@changes )
. 'Changes announced and not found: ' . 'Changes announced and not found: '
. Dumper( \@cmsg ); . Dumper( \@cmsg );
} }
#print STDERR Dumper(\@changes,\@cmsg); #print STDERR Dumper(\@changes,\@cmsg);
...@@ -108,9 +114,9 @@ my ( @c1, @c2 ); ...@@ -108,9 +114,9 @@ my ( @c1, @c2 );
ok( ( @c1 = sort keys %{ $res->[0] } ), 'diff() detects changes in conf 1' ); ok( ( @c1 = sort keys %{ $res->[0] } ), 'diff() detects changes in conf 1' );
ok( ( @c2 = sort keys %{ $res->[1] } ), 'diff() detects changes in conf 2' ); ok( ( @c2 = sort keys %{ $res->[1] } ), 'diff() detects changes in conf 2' );
ok( @c1 == 12, '11 keys changed in conf 1' ) ok( @c1 == 12, '11 keys changed in conf 1' )
or print STDERR "Expect: 12 keys, get: " . join( ', ', @c1 ) . "\n"; or print STDERR "Expect: 12 keys, get: " . join( ', ', @c1 ) . "\n";
ok( @c2 == 16, '14 keys changed or created in conf 2' ) ok( @c2 == 16, '14 keys changed or created in conf 2' )
or print STDERR "Expect: 16 keys, get: " . join( ',', @c2 ) . "\n"; or print STDERR "Expect: 16 keys, get: " . join( ',', @c2 ) . "\n";
count(5); count(5);
...@@ -124,89 +130,112 @@ done_testing( count() ); ...@@ -124,89 +130,112 @@ done_testing( count() );
sub changes { sub changes {
return [ return [
{ 'key' => 'portal', {
'key' => 'portal',
'new' => 'http://auth2.example.com/', 'new' => 'http://auth2.example.com/',
'old' => 'http://auth.example.com/' 'old' => 'http://auth.example.com/'
}, },
{ 'new' => 0, {
'new' => 0,
'old' => 1, 'old' => 1,
'key' => 'portalDisplayLogout' 'key' => 'portalDisplayLogout'
}, },
{ 'key' => {
'applicationList, Sample applications, Application Test 1, uri', 'key' =>
'applicationList, Sample applications, Application Test 1, uri',
'old' => 'http://test1.example.com/', 'old' => 'http://test1.example.com/',
'new' => 'http://testex.example.com/' 'new' => 'http://testex.example.com/'
}, },
{ 'new' => 'Application Test 3', {
'new' => 'Application Test 3',
'key' => 'applicationList, Sample applications' 'key' => 'applicationList, Sample applications'
}, },
{ 'new' => 'Changes in cat(s)/app(s)', {
'new' => 'Changes in cat(s)/app(s)',
'key' => 'applicationList', 'key' => 'applicationList',
}, },
{ 'key' => 'applicationList', {
'key' => 'applicationList',
'old' => 'Documentation', 'old' => 'Documentation',
'new' => 'Administration', 'new' => 'Administration',
}, },
{ 'key' => 'applicationList', {
'key' => 'applicationList',
'old' => 'Administration', 'old' => 'Administration',
'new' => 'Sample applications', 'new' => 'Sample applications',
}, },
{ 'key' => 'applicationList', {
'key' => 'applicationList',
'old' => 'Sample applications', 'old' => 'Sample applications',
'new' => 'Documentation', 'new' => 'Documentation',
}, },
{ 'key' => 'userDB', {
'key' => 'userDB',
'new' => 'LDAP', 'new' => 'LDAP',
'old' => 'Demo' 'old' => 'Demo'
}, },
{ 'key' => 'passwordDB', {
'key' => 'passwordDB',
'new' => 'LDAP', 'new' => 'LDAP',
'old' => 'Demo' 'old' => 'Demo'
}, },
{ 'key' => 'openIdSPList', {
'key' => 'openIdSPList',
'new' => '1;bad.com' 'new' => '1;bad.com'
}, },
{ 'new' => 'Uid', {
'new' => 'Uid',
'key' => 'exportedVars' 'key' => 'exportedVars'
}, },
{ 'key' => {
'locationRules, test1.example.com, (?#Logout comment)^/logout', 'key' =>
'locationRules, test1.example.com, (?#Logout comment)^/logout',
'new' => 'logout_sso', 'new' => 'logout_sso',
'old' => undef 'old' => undef
}, },
{ 'old' => '^/logout', {
'old' => '^/logout',
'key' => 'locationRules, test1.example.com' 'key' => 'locationRules, test1.example.com'
}, },
{ 'key' => 'locationRules, test3.example.com, ^/logout', {
'key' => 'locationRules, test3.example.com, ^/logout',
'new' => 'logout_sso', 'new' => 'logout_sso',
'old' => undef 'old' => undef
}, },
{ 'key' => 'locationRules, test3.example.com, default', {
'key' => 'locationRules, test3.example.com, default',
'old' => undef, 'old' => undef,
'new' => 'accept' 'new' => 'accept'
}, },
{ 'key' => 'locationRules', {
'key' => 'locationRules',
'new' => 'test3.example.com' 'new' => 'test3.example.com'
}, },
{ 'key' => 'exportedHeaders, test3.example.com, Auth-User', {
'key' => 'exportedHeaders, test3.example.com, Auth-User',
'old' => undef, 'old' => undef,
'new' => '$uid' 'new' => '$uid'
}, },
{ 'new' => 'test3.example.com', {
'new' => 'test3.example.com',
'key' => 'exportedHeaders' 'key' => 'exportedHeaders'
}, },
{ 'key' => 'locationRules, test.ex.com, default', {
'key' => 'locationRules, test.ex.com, default',
'old' => undef, 'old' => undef,
'new' => 'deny' 'new' => 'deny'
}, },
{ 'key' => 'locationRules', {
'key' => 'locationRules',
'new' => 'test.ex.com' 'new' => 'test.ex.com'
}, },
{ 'key' => 'virtualHosts', {
'key' => 'virtualHosts',
'new' => 'test3.example.com', 'new' => 'test3.example.com',
'old' => 'test2.example.com' 'old' => 'test2.example.com'
}, },
{ 'key' => 'virtualHosts', {
'key' => 'virtualHosts',
'old' => 'test2.example.com' 'old' => 'test2.example.com'
}, },
{ {
...@@ -218,6 +247,6 @@ sub changes { ...@@ -218,6 +247,6 @@ sub changes {
'new' => 0, 'new' => 0,
'key' => 'captcha_mail_enabled', 'key' => 'captcha_mail_enabled',
'old' => '1' 'old' => '1'
} }
]; ];
} }
...@@ -19,27 +19,29 @@ mkdir 't/sessions'; ...@@ -19,27 +19,29 @@ mkdir 't/sessions';
my ( $res, $resBody ); my ( $res, $resBody );
ok( $res = &client->_post( '/confs/', 'cfgNum=1', &body, 'application/json' ), ok( $res = &client->_post( '/confs/', 'cfgNum=1', &body, 'application/json' ),
"Request succeed" "Request succeed" );
);
ok( $res->[0] == 200, "Result code is 200" ); ok( $res->[0] == 200, "Result code is 200" );
ok( $resBody = from_json( $res->[2]->[0] ), ok( $resBody = from_json( $res->[2]->[0] ), "Result body contains JSON text" );
"Result body contains JSON text" );
ok( $resBody->{result} == 1, "JSON response contains \"result:1\"" ) ok( $resBody->{result} == 1, "JSON response contains \"result:1\"" )
or print STDERR Dumper($resBody); or print STDERR Dumper($resBody);
ok( @{ $resBody->{details}->{__warnings__} } == 2, ok(
@{ $resBody->{details}->{__warnings__} } == 2,
'JSON response contains 2 warnings' 'JSON response contains 2 warnings'
) or print STDERR Dumper($resBody); ) or print STDERR Dumper($resBody);
foreach my $i (0 .. 1) { foreach my $i ( 0 .. 1 ) {
ok( $resBody->{details}->{__warnings__}->[$i]->{message} ok(
=~ /\b(unprotected|cross-domain-authentication)\b/, $resBody->{details}->{__warnings__}->[$i]->{message} =~
/\b(unprotected|cross-domain-authentication)\b/,
"Warning with 'unprotect', 'CDA' or 'retries' found" "Warning with 'unprotect', 'CDA' or 'retries' found"
) or print STDERR Dumper($resBody); ) or print STDERR Dumper($resBody);
} }
ok( @{ $resBody->{details}->{__changes__} } == 20, ok(
@{ $resBody->{details}->{__changes__} } == 20,
'JSON response contains 24 changes' 'JSON response contains 24 changes'
) or print STDERR Dumper($resBody); ) or print STDERR Dumper($resBody);
#print STDERR Dumper($resBody); #print STDERR Dumper($resBody);
ok( -f $confFiles->[1], 'File is created' ); ok( -f $confFiles->[1], 'File is created' );
...@@ -61,13 +63,13 @@ while ( my $c = shift @{ $resBody->{details}->{__changes__} } ) { ...@@ -61,13 +63,13 @@ while ( my $c = shift @{ $resBody->{details}->{__changes__} } ) {
} }
else { else {
ok( ( $cmp1 - @changes ) == ( $cmp2 - @cmsg ), qq("$c->{key}" found) ) ok( ( $cmp1 - @changes ) == ( $cmp2 - @cmsg ), qq("$c->{key}" found) )
or print STDERR 'Expect: ' or print STDERR 'Expect: '
. ( $cmp1 - @changes ) . ( $cmp1 - @changes )
. ', got: ' . ', got: '
. ( $cmp2 - @cmsg ) . ( $cmp2 - @cmsg )
. "\nExpect: " . "\nExpect: "
. Dumper( \@d1 ) . "Got: " . Dumper( \@d1 ) . "Got: "
. Dumper( \@d2 ); . Dumper( \@d2 );
} }
count(1); count(1);
} }
...@@ -75,9 +77,9 @@ ok( !@changes, 'All changes detected' ) or $bug = 1; ...@@ -75,9 +77,9 @@ ok( !@changes, 'All changes detected' ) or $bug = 1;
if ($bug) { if ($bug) {
print STDERR 'Expected not found: ' print STDERR 'Expected not found: '
. Dumper( \@changes ) . Dumper( \@changes )
. 'Changes announced and not found: ' . 'Changes announced and not found: '
. Dumper( \@cmsg ); . Dumper( \@cmsg );
} }
#print STDERR Dumper(\@changes,\@cmsg); #print STDERR Dumper(\@changes,\@cmsg);
...@@ -90,9 +92,9 @@ my ( @c1, @c2 ); ...@@ -90,9 +92,9 @@ my ( @c1, @c2 );
ok( ( @c1 = sort keys %{ $res->[0] } ), 'diff() detects changes in conf 1' ); ok( ( @c1 = sort keys %{ $res->[0] } ), 'diff() detects changes in conf 1' );
ok( ( @c2 = sort keys %{ $res->[1] } ), 'diff() detects changes in conf 2' ); ok( ( @c2 = sort keys %{ $res->[1] } ), 'diff() detects changes in conf 2' );
ok( @c1 == 11, '11 keys changed in conf 1' ) ok( @c1 == 11, '11 keys changed in conf 1' )
or print STDERR "Expect: 11 keys, get: " . join( ', ', @c1 ) . "\n"; or print STDERR "Expect: 11 keys, get: " . join( ', ', @c1 ) . "\n";
ok( @c2 == 14, '14 keys changed or created in conf 2' ) ok( @c2 == 14, '14 keys changed or created in conf 2' )
or print STDERR "Expect: 14 keys, get: " . join( ',', @c2 ) . "\n"; or print STDERR "Expect: 14 keys, get: " . join( ',', @c2 ) . "\n";
count(5); count(5);
...@@ -106,89 +108,112 @@ done_testing( count() ); ...@@ -106,89 +108,112 @@ done_testing( count() );
sub changes { sub changes {
return [ return [
{ 'key' => 'portal', {
'key' => 'portal',
'new' => 'http://auth2.example.com/', 'new' => 'http://auth2.example.com/',
'old' => 'http://auth.example.com/' 'old' => 'http://auth.example.com/'
}, },
{ 'new' => 0, {
'new' => 0,
'old' => 1, 'old' => 1,
'key' => 'portalDisplayLogout' 'key' => 'portalDisplayLogout'
}, },
{ 'key' => {
'applicationList, Sample applications, Application Test 1, uri', 'key' =>
'applicationList, Sample applications, Application Test 1, uri',
'old' => 'http://test1.example.com/', 'old' => 'http://test1.example.com/',
'new' => 'http://testex.example.com/' 'new' => 'http://testex.example.com/'
}, },
{ 'new' => 'Application Test 3', {
'new' => 'Application Test 3',
'key' => 'applicationList, Sample applications' 'key' => 'applicationList, Sample applications'
}, },
{ 'new' => 'Changes in cat(s)/app(s)', {
'new' => 'Changes in cat(s)/app(s)',
'key' => 'applicationList', 'key' => 'applicationList',
}, },
{ 'key' => 'applicationList', {
'key' => 'applicationList',
'old' => 'Documentation', 'old' => 'Documentation',
'new' => 'Administration', 'new' => 'Administration',
}, },
{ 'key' => 'applicationList', {
'key' => 'applicationList',
'old' => 'Administration', 'old' => 'Administration',
'new' => 'Sample applications', 'new' => 'Sample applications',
}, },
{ 'key' => 'applicationList', {