Append unit tests (#1661)

environments/ppa-mbqj77/deployments/719^2
maudoux 6 years ago
parent 98869b5ae6
commit c9d704189b
  1. 2
      e2e-tests/lemonldap-ng.ini
  2. 42
      lemonldap-ng-manager/t/70-viewer.t
  3. 52
      lemonldap-ng-manager/t/71-viewer-with-no-diff.t
  4. 1797
      lemonldap-ng-manager/t/jsonfiles/70-diff.json
  5. 1
      lemonldap-ng-manager/t/lemonldap-ng-noDiff.ini
  6. 3
      lemonldap-ng-manager/t/lemonldap-ng.ini

@ -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() );

@ -0,0 +1,52 @@
# 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() );

File diff suppressed because it is too large Load Diff

@ -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]

Loading…
Cancel
Save