lemonldap-ng/lemonldap-ng-manager/t/71-viewer-with-no-diff.t
2019-04-01 21:58:05 +02:00

53 lines
1.3 KiB
Perl

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