Create fake type "subContainer"
This commit is contained in:
parent
9cfb59ad81
commit
baa2be3d78
|
@ -835,6 +835,9 @@ sub attributes {
|
||||||
documentation => 'Virtualhost urls/Datas to post',
|
documentation => 'Virtualhost urls/Datas to post',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
vhostOptions => {
|
||||||
|
type => 'subContainer',
|
||||||
|
},
|
||||||
vhostPort => {
|
vhostPort => {
|
||||||
type => 'int',
|
type => 'int',
|
||||||
default => -1,
|
default => -1,
|
||||||
|
@ -2003,6 +2006,8 @@ m{^(?:ldapi://[^/]*/?|\w[\w\-\.]*(?::\d{1,5})?|ldap(?:s|\+tls)?://\w[\w\-\.]*(?:
|
||||||
{ type => 'oidcOPMetaDataNodeContainer', help => 'oidcop.html', },
|
{ type => 'oidcOPMetaDataNodeContainer', help => 'oidcop.html', },
|
||||||
oidcRPMetaDataNodes =>
|
oidcRPMetaDataNodes =>
|
||||||
{ type => 'oidcRPMetaDataNodeContainer', help => 'oidcrp.html', },
|
{ type => 'oidcRPMetaDataNodeContainer', help => 'oidcrp.html', },
|
||||||
|
oidcOPMetaDataOptions => { type => 'subContainer', },
|
||||||
|
oidcRPMetaDataOptions => { type => 'subContainer', },
|
||||||
|
|
||||||
# OpenID Connect providers
|
# OpenID Connect providers
|
||||||
oidcOPMetaDataJSON => { type => 'oidcmetadatajson', },
|
oidcOPMetaDataJSON => { type => 'oidcmetadatajson', },
|
||||||
|
|
|
@ -474,52 +474,64 @@ sub _unitTest {
|
||||||
foreach my $key ( keys %$conf ) {
|
foreach my $key ( keys %$conf ) {
|
||||||
my ( $attr, $type );
|
my ( $attr, $type );
|
||||||
|
|
||||||
# Check if key exists
|
if ( $attr->{type} and $attr->{type} eq 'subContainer' ) {
|
||||||
unless ( $attr = $attrs->{$key} ) {
|
|
||||||
push @{ $self->errors }, { message => "__unknownKey__: $key" };
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
if ( $key =~ $simpleHashKeys ) {
|
|
||||||
|
|
||||||
#TODO
|
# TODO Recursive
|
||||||
}
|
|
||||||
elsif ( defined $attr->{keyTest} ) {
|
|
||||||
|
|
||||||
#TODO
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
die "Unkown type $attr->{type}"
|
|
||||||
unless ( $type = $types->{ $attr->{type} } );
|
# Check if key exists
|
||||||
my $test = $attr->{test} // $type->{test};
|
unless ( $attr = $attrs->{$key} ) {
|
||||||
my $msg = $attr->{msgFail} // $type->{msgFail};
|
push @{ $self->errors }, { message => "__unknownKey__: $key" };
|
||||||
if ( my $ref = ref($test) ) {
|
next;
|
||||||
if ( $ref eq 'CODE' ) {
|
}
|
||||||
my ( $r, $w ) = $test->( $conf->{$key}, $conf, $attr );
|
if ( $key =~ $simpleHashKeys ) {
|
||||||
unless ($r) {
|
|
||||||
push @{ $self->errors },
|
#TODO
|
||||||
{ message => "$key: " . ( $w ? $w : $msg ) };
|
}
|
||||||
$res = 0;
|
elsif ( defined $attr->{keyTest} ) {
|
||||||
|
|
||||||
|
#TODO
|
||||||
|
}
|
||||||
|
elsif ( $attr->{type} =~ /Container$/ ) {
|
||||||
|
|
||||||
|
#TODO
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
die "Unkown type $attr->{type}"
|
||||||
|
unless ( $type = $types->{ $attr->{type} } );
|
||||||
|
my $test = $attr->{test} // $type->{test};
|
||||||
|
my $msg = $attr->{msgFail} // $type->{msgFail};
|
||||||
|
if ( my $ref = ref($test) ) {
|
||||||
|
if ( $ref eq 'CODE' ) {
|
||||||
|
my ( $r, $w ) = $test->( $conf->{$key}, $conf, $attr );
|
||||||
|
unless ($r) {
|
||||||
|
push @{ $self->errors },
|
||||||
|
{ message => "$key: " . ( $w ? $w : $msg ) };
|
||||||
|
$res = 0;
|
||||||
|
}
|
||||||
|
elsif ($w) {
|
||||||
|
push @{ $self->warnings },
|
||||||
|
{ message => "$key: $w" };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
elsif ($w) {
|
elsif ( $ref eq 'Regexp' ) {
|
||||||
push @{ $self->warnings }, { message => "$key: $w" };
|
die "msgFail undefined for type \"$attr->{type}\""
|
||||||
|
unless ( defined $msg );
|
||||||
|
unless ( $conf->{$key} =~ $test ) {
|
||||||
|
push @{ $self->errors },
|
||||||
|
{ message => "$key: $msg ($conf->{$key})" };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
else {
|
||||||
elsif ( $ref eq 'Regexp' ) {
|
die
|
||||||
die "msgFail undefined for type \"$attr->{type}\""
|
"Malformed test: only regexp ref or sub are accepted (type \"$ref\")";
|
||||||
unless ( defined $msg );
|
|
||||||
unless ( $conf->{$key} =~ $test ) {
|
|
||||||
push @{ $self->errors },
|
|
||||||
{ message => "$key: $msg ($conf->{$key})" };
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
die
|
die
|
||||||
"Malformed test: only regexp ref or sub are accepted (type \"$ref\")";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
die
|
|
||||||
"Malformed test: only regexp ref or sub are accepted (\"$test\")";
|
"Malformed test: only regexp ref or sub are accepted (\"$test\")";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,38 +15,42 @@ $count += 3;
|
||||||
ok( opendir( D, $formDir ), 'Found forms dir' );
|
ok( opendir( D, $formDir ), 'Found forms dir' );
|
||||||
my %forms = map { s/\.html$// ? ( $_ => 1 ) : () } readdir D;
|
my %forms = map { s/\.html$// ? ( $_ => 1 ) : () } readdir D;
|
||||||
close D;
|
close D;
|
||||||
|
|
||||||
delete $forms{white};
|
delete $forms{white};
|
||||||
delete $forms{restore};
|
delete $forms{restore};
|
||||||
|
|
||||||
my ( @types, $attr, $tree, $ctrees );
|
my ( @types, $attr, $tree, $ctrees );
|
||||||
ok( $tree = Lemonldap::NG::Manager::Tree::tree(), 'Get tree' );
|
ok( $tree = Lemonldap::NG::Manager::Tree::tree(), 'Get tree' );
|
||||||
ok( $ctrees = Lemonldap::NG::Manager::CTrees::cTrees(), 'Get cTrees' );
|
ok( $ctrees = Lemonldap::NG::Manager::CTrees::cTrees(), 'Get cTrees' );
|
||||||
ok( $attr = Lemonldap::NG::Manager::Attributes::attributes(),
|
ok( $attr = Lemonldap::NG::Manager::Attributes::attributes(),
|
||||||
'Get attributes' );
|
'Get attributes' );
|
||||||
$count +=4;
|
$count += 4;
|
||||||
|
|
||||||
my %types = %{ getTypes( $tree, values(%$ctrees), $attr ) };
|
my %types = %{ getTypes( $tree, values(%$ctrees), $attr ) };
|
||||||
|
|
||||||
foreach(qw(home menuCat menuApp)){
|
foreach (qw(home menuCat menuApp)) {
|
||||||
ok($forms{$_},"Found $_ form");
|
ok( $forms{$_}, "Found $_ form" );
|
||||||
$count ++;
|
$count++;
|
||||||
delete $forms{$_};
|
delete $forms{$_};
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach my $type ( keys %types ) {
|
foreach my $type ( keys %types ) {
|
||||||
delete $types{$type};
|
delete $types{$type};
|
||||||
next if($type =~ /^(?:url|PerlModule|hostname|pcre|lmAttrOrMacro|RSAP(?:ublic|rivate)Key)$/);
|
next
|
||||||
|
if ( $type =~
|
||||||
|
/^(?:url|PerlModule|hostname|pcre|lmAttrOrMacro|subContainer|RSAP(?:ublic|rivate)Key)$/
|
||||||
|
);
|
||||||
ok( $forms{$type}, "Found $type" );
|
ok( $forms{$type}, "Found $type" );
|
||||||
delete $forms{$type};
|
delete $forms{$type};
|
||||||
$count++;
|
$count++;
|
||||||
if ( $type =~ s/Container$// ) {
|
if ( $type =~ s/Container$// ) {
|
||||||
next if($type eq 'simpleInput');
|
next if ( $type eq 'simpleInput' );
|
||||||
ok( $forms{$type}, "Found $type" );
|
ok( $forms{$type}, "Found $type" );
|
||||||
delete $forms{$type};
|
delete $forms{$type};
|
||||||
$count++;
|
$count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ok(!%forms, "No unused forms");
|
ok( !%forms, "No unused forms" );
|
||||||
$count++;
|
$count++;
|
||||||
|
|
||||||
done_testing($count);
|
done_testing($count);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user