Commit c9d70418 authored by Christophe Maudoux's avatar Christophe Maudoux

Append unit tests (#1661)

parent 98869b5a
......@@ -42,7 +42,7 @@ protection = manager
viewerHiddenKeys = samlIDPMetaDataNodes samlSPMetaDataNodes portalDisplayLogout captcha_login_enabled
viewerAllowBrowser = 1
viewerAllowDiff = 0
viewerAllowDiff = 1
staticPrefix = /static
languages = fr, en, vi, ar, de, it, zh
......
......@@ -7,6 +7,11 @@ use JSON qw(from_json);
require 't/test-lib.pm';
my $struct = 't/jsonfiles/70-diff.json';
sub body {
return IO::File->new( $struct, 'r' );
}
# Test that key value is sent
my $res = &client->jsonResponse('/view/1/portalDisplayOidcConsents');
ok( $res->{value} eq '$_oidcConnectedRP', 'Key found' );
......@@ -24,20 +29,31 @@ $res = &client->jsonResponse('/view/latest');
ok( $res->{cfgNum} eq '1', 'Browser is allowed' );
count(1);
# Load lemonldap-ng-noBrowser.ini
use_ok('Lemonldap::NG::Manager::Cli::Lib');
my $client2;
ok(
$client2 = Lemonldap::NG::Manager::Cli::Lib->new(
iniFile => 't/lemonldap-ng-noBrowser.ini'
),
'Client object'
);
# Try to display latest conf
$res = $client2->jsonResponse('/view/1');
ok( $res->{value} eq '_Hidden_', 'Browser is NOT allowed' );
ok( $res = &client->_post( '/confs/', 'cfgNum=1&force=1', &body, 'application/json' ),
"Request succeed" );
ok( $res->[0] == 200, "Result code is 200" );
my $resBody;
ok( $resBody = from_json( $res->[2]->[0] ), "Result body contains JSON text" );
count(3);
foreach my $i ( 0 .. 1 ) {
ok(
$resBody->{details}->{__changes__}->[$i]->{key} =~
/\b(captcha_login_enabled|captcha_mail_enabled)\b/,
"Details with captcha 'login' or 'mail' found"
) or print STDERR Dumper($resBody);
}
count(2);
# Try to compare confs 1 & 2
$res = &client->jsonResponse('/view/diff/1/2');
# ok( $res->[1]->{captcha_login_enabled} eq '1', 'Key found' );
ok( $res->[1]->{captcha_mail_enabled} eq '0', 'Key found' );
ok( 6 == keys %{ $res->[1] }, 'Right number of keys found')
or print STDERR Dumper($res);
count(2);
# Remove new conf
`rm -rf t/conf/lmConf-2.json`;
done_testing( count() );
# Test viewer API
use Test::More;
use strict;
use IO::String;
use JSON qw(from_json);
require 't/test-lib.pm';
my $struct = 't/jsonfiles/70-diff.json';
sub body {
return IO::File->new( $struct, 'r' );
}
# Load lemonldap-ng-noDiff.ini
my $client2;
ok(
$client2 = Lemonldap::NG::Manager::Cli::Lib->new(
iniFile => 't/lemonldap-ng-noDiff.ini'
),
'Client object'
);
# Try to display latest conf
my $res = $client2->jsonResponse('/view/1');
ok( $res->{value} eq '_Hidden_', 'Browser is NOT allowed' );
count(2);
# Try to compare confs 1 & 2
ok( $res = $client2->_post( '/confs/', 'cfgNum=1&force=1', &body, 'application/json' ),
"Request succeed" );
ok( $res->[0] == 200, "Result code is 200" );
my $resBody;
ok( $resBody = from_json( $res->[2]->[0] ), "Result body contains JSON text" );
count(3);
foreach my $i ( 0 .. 1 ) {
ok(
$resBody->{details}->{__changes__}->[$i]->{key} =~
/\b(captcha_login_enabled|captcha_mail_enabled)\b/,
"Details with captcha 'login' or 'mail' found"
) or print STDERR Dumper($resBody);
}
count(2);
$res = $client2->jsonResponse('/view/diff/1/2');
ok( $res->{value} eq '_Hidden_', 'Diff is NOT allowed' );
count(1);
# Remove new conf
`rm -rf t/conf/lmConf-2.json`;
done_testing( count() );
This diff is collapsed.
......@@ -29,6 +29,7 @@ templateDir = site/templates/
enabledModules = conf, sessions, notifications, 2ndFA, viewer
viewerHiddenKeys = samlIDPMetaDataNodes samlSPMetaDataNodes portalDisplayLogout
viewerAllowBrowser = 0
viewerAllowDiff = 0
[sessionsExplorer]
......
......@@ -27,8 +27,9 @@ staticPrefix = app/
languages = fr, en, vi, ar
templateDir = site/templates/
enabledModules = conf, sessions, notifications, 2ndFA, viewer
viewerHiddenKeys = samlIDPMetaDataNodes samlSPMetaDataNodes portalDisplayLogout
viewerHiddenKeys = samlIDPMetaDataNodes samlSPMetaDataNodes portalDisplayLogout captcha_login_enabled
viewerAllowBrowser = 1
viewerAllowDiff = 1
[sessionsExplorer]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment