Commit 58ee26a1 authored by Xavier Guimard's avatar Xavier Guimard

Combination seems finished (except tests) (#1151)

parent 4741948f
......@@ -581,6 +581,28 @@ sub _scanCatsAndApps {
return \@res;
}
# 325 - Combination modules
# Returns raw value, just transform "over" key
sub combModules {
my ( $self, $req, $key ) = @_;
return $self->sendError( 'Subkeys forbidden for combModules', 400 )
if ($key);
my $val = $self->getConfKey( $req, 'combModules' ) // {};
my $res = [];
foreach my $mod ( keys %$val ) {
my $tmp;
$tmp->{title} = $mod;
$tmp->{id} = "combModules/$mod";
$tmp->{type} = 'cmbModule';
$tmp->{data}->{$_} = $val->{$mod}->{$_} foreach (qw(type for));
my $over = $val->{$mod}->{over} // {};
$tmp->{data}->{over} = [ map { [ $_, $over->{$_} ] } keys %$over ];
push @$res, $tmp;
}
return $self->sendJSONresponse($req,$res);
}
# 33 - Root queries
# -----------
......
......@@ -78,6 +78,8 @@ site/static/forms/blackWhiteList.html
site/static/forms/bool.html
site/static/forms/boolOrExpr.html
site/static/forms/catAndAppList.html
site/static/forms/cmbModule.html
site/static/forms/cmbModuleContainer.html
site/static/forms/doubleHash.html
site/static/forms/file.html
site/static/forms/grant.html
......@@ -165,6 +167,7 @@ t/07-utf8.t
t/10-save-unchanged-conf.t
t/12-save-changed-conf.t
t/14-bad-changes-in-conf.t
t/15-combination.t
t/20-test-coverage.t
t/40-sessions.t
t/50-notifications.t
......@@ -176,5 +179,6 @@ t/jsonfiles/01-base-tree.json
t/jsonfiles/02-base-tree-all-nodes-opened.json
t/jsonfiles/12-modified.json
t/jsonfiles/14-bad.json
t/jsonfiles/15-combination.json
t/lemonldap-ng.ini
t/test-lib.pm
......@@ -39,7 +39,8 @@ sub addRoutes {
':cfgNum' => [
qw(virtualHosts samlIDPMetaDataNodes samlSPMetaDataNodes
applicationList oidcOPMetaDataNodes oidcRPMetaDataNodes
authChoiceModules grantSessionRules)
authChoiceModules grantSessionRules combModules
openIdIDPList)
]
},
['GET']
......
......@@ -643,6 +643,25 @@ sub _scanNodes {
next;
}
# combModules: just to replace "over" key
elsif ( $name eq 'combModules' ) {
hdebug('combModules');
$self->newConf->{$name} = {};
foreach my $node ( @{ $leaf->{nodes} } ) {
my $tmp;
$tmp->{$_} = $node->{data}->{$_} foreach (qw(type for));
$tmp->{over} = {};
foreach ( @{ $node->{data}->{over} } ) {
$tmp->{over}->{ $_->[0] } = $_->[1];
}
$self->newConf->{$name}->{ $node->{title} } = $tmp;
}
# TODO: check changes
$self->confChanged(1);
next;
}
####################
# Other hash nodes #
####################
......
#!/usr/bin/env perl -I pl/lib
#
# Verify that bas changes are detected
use Test::More;
use strict;
use JSON;
use Data::Dumper;
require 't/test-lib.pm';
my $struct = 't/jsonfiles/15-combination.json';
sub body {
return IO::File->new( $struct, 'r' );
}
unlink 't/conf/lmConf-2.json';
my ( $res, $resBody );
ok( $res = &client->_post( '/confs/', 'cfgNum=1', &body, 'application/json' ),
"Request succeed" );
ok( $res->[0] == 200, "Result code is 200" );
ok( $resBody = from_json( $res->[2]->[0] ), "Result body contains JSON text" );
ok( $resBody->{result} == 1, "JSON response contains \"result:1\"" )
or print STDERR Dumper($res);
ok( $res = &client->_get( '/confs/2/combModules', 'application/json' ), 'Get combModules');
ok( $resBody = from_json( $res->[2]->[0] ), "Result body contains JSON text" );
count(6);
done_testing( count() );
unlink 't/conf/lmConf-2.json';
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