Update tests
This commit is contained in:
parent
ef71c9dbb1
commit
876c420ed5
|
@ -55,6 +55,12 @@ qr/^(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-
|
||||||
'msgFail' => '__badValue__',
|
'msgFail' => '__badValue__',
|
||||||
'test' => qr/^.*$/
|
'test' => qr/^.*$/
|
||||||
},
|
},
|
||||||
|
'keyTextContainer' => {
|
||||||
|
'keyMsgFail' => 'Bad key name',
|
||||||
|
'keyTest' => qr/^\w[\w\.\-]*$/,
|
||||||
|
'msgFail' => 'Empty value non accorded',
|
||||||
|
'test' => qr/./
|
||||||
|
},
|
||||||
'lmAttrOrMacro' => {
|
'lmAttrOrMacro' => {
|
||||||
'form' => 'text',
|
'form' => 'text',
|
||||||
'test' => sub {
|
'test' => sub {
|
||||||
|
@ -175,12 +181,18 @@ qr/^(?:(?:\-+\s*BEGIN\s+PUBLIC\s+KEY\s*\-+\r?\n)?[a-zA-Z0-9\/\+\r\n]+={0,2}(?:\r
|
||||||
'test' => sub {
|
'test' => sub {
|
||||||
my $test =
|
my $test =
|
||||||
grep( { $_ eq $_[0]; }
|
grep( { $_ eq $_[0]; }
|
||||||
map( { $$_{'k'}; } @{ $_[2]{'select'}; } ) );
|
map( { $_->{'k'}; } @{ $_[2]{'select'}; } ) );
|
||||||
return $test
|
return $test
|
||||||
? 1
|
? 1
|
||||||
: ( 0, "Invalid value '$_[0]' for this select" );
|
: ( 0, "Invalid value '$_[0]' for this select" );
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
'subContainer' => {
|
||||||
|
'keyTest' => qr/\w/,
|
||||||
|
'test' => sub {
|
||||||
|
1;
|
||||||
|
}
|
||||||
|
},
|
||||||
'text' => {
|
'text' => {
|
||||||
'msgFail' => '__malformedValue__',
|
'msgFail' => '__malformedValue__',
|
||||||
'test' => qr/.*/
|
'test' => qr/.*/
|
||||||
|
@ -194,11 +206,6 @@ qr/^(?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-F0-9]))*))*)(?:\/(?:(?:(?:[a-zA-Z0-9\-_.!~*'():@&=+$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)(?:;(?:(?:[a-zA-Z0-9\-_.!~*'():@&=+$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*))*))*))(?:[?](?:(?:(?:[;\/?:@&=+$,a-zA-Z0-9\-_.!~*'()]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)))?))?)$/
|
||||||
},
|
|
||||||
'virtualHost' => {
|
|
||||||
'test' => sub {
|
|
||||||
1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -392,6 +399,9 @@ sub attributes {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
'test' => sub {
|
||||||
|
1;
|
||||||
|
},
|
||||||
'type' => 'authChoiceContainer'
|
'type' => 'authChoiceContainer'
|
||||||
},
|
},
|
||||||
'authChoiceParam' => {
|
'authChoiceParam' => {
|
||||||
|
@ -787,6 +797,9 @@ qr/^(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-zA-Z0-
|
||||||
};
|
};
|
||||||
return $@ ? ( 0, "__badExpression__: $@" ) : 1;
|
return $@ ? ( 0, "__badExpression__: $@" ) : 1;
|
||||||
},
|
},
|
||||||
|
'test' => sub {
|
||||||
|
1;
|
||||||
|
},
|
||||||
'type' => 'grantContainer'
|
'type' => 'grantContainer'
|
||||||
},
|
},
|
||||||
'groups' => {
|
'groups' => {
|
||||||
|
@ -985,7 +998,7 @@ qr/^(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-zA-Z0-
|
||||||
'default' => 'ldap://localhost',
|
'default' => 'ldap://localhost',
|
||||||
'test' => sub {
|
'test' => sub {
|
||||||
my $l = shift();
|
my $l = shift();
|
||||||
my (@s) = split( /[\s,]+/, $l, 0 );
|
my @s = split( /[\s,]+/, $l, 0 );
|
||||||
foreach my $s (@s) {
|
foreach my $s (@s) {
|
||||||
return 0, qq[Bad ldap uri "$s"]
|
return 0, qq[Bad ldap uri "$s"]
|
||||||
unless $s =~
|
unless $s =~
|
||||||
|
@ -1031,8 +1044,10 @@ m[^(?:ldapi://[^/]*/?|\w[\w\-\.]*(?::\d{1,5})?|ldap(?:s|\+tls)?://\w[\w\-\.]*(?:
|
||||||
},
|
},
|
||||||
'keyTest' =>
|
'keyTest' =>
|
||||||
qr/^(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-zA-Z0-9]*[a-zA-Z0-9]|[a-zA-Z])[.]?)$/,
|
qr/^(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-zA-Z0-9]*[a-zA-Z0-9]|[a-zA-Z])[.]?)$/,
|
||||||
'msgFail' => '__badHostname__',
|
'test' => sub {
|
||||||
'type' => 'ruleContainer'
|
1;
|
||||||
|
},
|
||||||
|
'type' => 'ruleContainer'
|
||||||
},
|
},
|
||||||
'loginHistoryEnabled' => {
|
'loginHistoryEnabled' => {
|
||||||
'default' => 1,
|
'default' => 1,
|
||||||
|
@ -1561,6 +1576,9 @@ qr/^(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-zA-Z0-
|
||||||
'post' => {
|
'post' => {
|
||||||
'keyTest' =>
|
'keyTest' =>
|
||||||
qr/^(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-zA-Z0-9]*[a-zA-Z0-9]|[a-zA-Z])[.]?)$/,
|
qr/^(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-zA-Z0-9]*[a-zA-Z0-9]|[a-zA-Z])[.]?)$/,
|
||||||
|
'test' => sub {
|
||||||
|
1;
|
||||||
|
},
|
||||||
'type' => 'postContainer'
|
'type' => 'postContainer'
|
||||||
},
|
},
|
||||||
'protection' => {
|
'protection' => {
|
||||||
|
@ -1711,6 +1729,8 @@ qr/^(?:(?:https?):\/\/(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.
|
||||||
'samlIDPMetaDataExportedAttributes' => {
|
'samlIDPMetaDataExportedAttributes' => {
|
||||||
'default' => ';;;',
|
'default' => ';;;',
|
||||||
'keyTest' => qr/^[a-zA-Z](?:[a-zA-Z0-9_\-\.]*\w)?$/,
|
'keyTest' => qr/^[a-zA-Z](?:[a-zA-Z0-9_\-\.]*\w)?$/,
|
||||||
|
'msgFail' => '__badValue__',
|
||||||
|
'test' => qr/\w/,
|
||||||
'type' => 'samlAttributeContainer'
|
'type' => 'samlAttributeContainer'
|
||||||
},
|
},
|
||||||
'samlIDPMetaDataNodes' => {
|
'samlIDPMetaDataNodes' => {
|
||||||
|
@ -2000,6 +2020,8 @@ qr/^(?:(?:https?):\/\/(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.
|
||||||
'samlSPMetaDataExportedAttributes' => {
|
'samlSPMetaDataExportedAttributes' => {
|
||||||
'default' => ';;;',
|
'default' => ';;;',
|
||||||
'keyTest' => qr/^[a-zA-Z](?:[a-zA-Z0-9_\-\.]*\w)?$/,
|
'keyTest' => qr/^[a-zA-Z](?:[a-zA-Z0-9_\-\.]*\w)?$/,
|
||||||
|
'msgFail' => '__badValue__',
|
||||||
|
'test' => qr/\w/,
|
||||||
'type' => 'samlAttributeContainer'
|
'type' => 'samlAttributeContainer'
|
||||||
},
|
},
|
||||||
'samlSPMetaDataNodes' => {
|
'samlSPMetaDataNodes' => {
|
||||||
|
|
|
@ -74,6 +74,16 @@ sub types {
|
||||||
test => $perlExpr,
|
test => $perlExpr,
|
||||||
msgFail => '__notAValidPerlExpression__',
|
msgFail => '__notAValidPerlExpression__',
|
||||||
},
|
},
|
||||||
|
keyTextContainer => {
|
||||||
|
test => qr/./,
|
||||||
|
msgFail => 'Empty value non accorded',
|
||||||
|
keyTest => qr/^\w[\w\.\-]*$/,
|
||||||
|
keyMsgFail => 'Bad key name',
|
||||||
|
},
|
||||||
|
subContainer => {
|
||||||
|
keyTest => qr/\w/,
|
||||||
|
test => sub { 1 },
|
||||||
|
},
|
||||||
|
|
||||||
# Files type (long text)
|
# Files type (long text)
|
||||||
file => {
|
file => {
|
||||||
|
@ -158,10 +168,6 @@ qr/^(?:(?:\-+\s*BEGIN\s+RSA\s+PRIVATE\s+KEY\s*\-+\r?\n)?[a-zA-Z0-9\/\+\r\n]+={0,
|
||||||
: ( 0, "Invalid value '$_[0]' for this select" );
|
: ( 0, "Invalid value '$_[0]' for this select" );
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
virtualHost => {
|
|
||||||
test => sub { 1 }
|
|
||||||
},
|
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -359,6 +365,7 @@ sub attributes {
|
||||||
grantSessionRules => {
|
grantSessionRules => {
|
||||||
type => 'grantContainer',
|
type => 'grantContainer',
|
||||||
keyTest => $perlExpr,
|
keyTest => $perlExpr,
|
||||||
|
test => sub { 1 },
|
||||||
},
|
},
|
||||||
hiddenAttributes => {
|
hiddenAttributes => {
|
||||||
type => 'text',
|
type => 'text',
|
||||||
|
@ -534,7 +541,6 @@ sub attributes {
|
||||||
},
|
},
|
||||||
|
|
||||||
# Notification
|
# Notification
|
||||||
notificationStorage => { type => 'PerlModule', },
|
|
||||||
notificationWildcard => {
|
notificationWildcard => {
|
||||||
type => 'text',
|
type => 'text',
|
||||||
default => 'allusers',
|
default => 'allusers',
|
||||||
|
@ -845,11 +851,12 @@ sub attributes {
|
||||||
},
|
},
|
||||||
|
|
||||||
locationRules => {
|
locationRules => {
|
||||||
type => 'ruleContainer',
|
type => 'ruleContainer',
|
||||||
help => 'writingrulesand_headers.html#rules',
|
help => 'writingrulesand_headers.html#rules',
|
||||||
keyTest => qr/^$Regexp::Common::URI::RFC2396::hostname$/,
|
test => sub { 1 },
|
||||||
msgFail => '__badHostname__',
|
keyTest => qr/^$Regexp::Common::URI::RFC2396::hostname$/,
|
||||||
default => {
|
keyMsgFail => '__badHostname__',
|
||||||
|
default => {
|
||||||
default => 'deny',
|
default => 'deny',
|
||||||
},
|
},
|
||||||
documentation => 'Virtualhost rules',
|
documentation => 'Virtualhost rules',
|
||||||
|
@ -864,6 +871,7 @@ sub attributes {
|
||||||
post => {
|
post => {
|
||||||
type => 'postContainer',
|
type => 'postContainer',
|
||||||
help => 'formreplay.html',
|
help => 'formreplay.html',
|
||||||
|
test => sub { 1 },
|
||||||
keyTest => qr/^$Regexp::Common::URI::RFC2396::hostname$/,
|
keyTest => qr/^$Regexp::Common::URI::RFC2396::hostname$/,
|
||||||
keyMsgFail => '__badHostname__',
|
keyMsgFail => '__badHostname__',
|
||||||
documentation => 'Virtualhost urls/Datas to post',
|
documentation => 'Virtualhost urls/Datas to post',
|
||||||
|
@ -1234,6 +1242,8 @@ sub attributes {
|
||||||
help => 'authsaml.html#exported_attributes',
|
help => 'authsaml.html#exported_attributes',
|
||||||
keyTest => qr/^[a-zA-Z](?:[a-zA-Z0-9_\-\.]*\w)?$/,
|
keyTest => qr/^[a-zA-Z](?:[a-zA-Z0-9_\-\.]*\w)?$/,
|
||||||
keyMsgFail => 'Bad metadata name',
|
keyMsgFail => 'Bad metadata name',
|
||||||
|
test => qr/\w/,
|
||||||
|
msgFail => '__badValue__',
|
||||||
default => ';;;',
|
default => ';;;',
|
||||||
},
|
},
|
||||||
samlIDPMetaDataXML => {
|
samlIDPMetaDataXML => {
|
||||||
|
@ -1349,6 +1359,8 @@ sub attributes {
|
||||||
help => 'idpsaml.html#exported_attributes',
|
help => 'idpsaml.html#exported_attributes',
|
||||||
keyTest => qr/^[a-zA-Z](?:[a-zA-Z0-9_\-\.]*\w)?$/,
|
keyTest => qr/^[a-zA-Z](?:[a-zA-Z0-9_\-\.]*\w)?$/,
|
||||||
keyMsgFail => 'Bad metadata name',
|
keyMsgFail => 'Bad metadata name',
|
||||||
|
test => qr/\w/,
|
||||||
|
msgFail => '__badValue__',
|
||||||
default => ';;;',
|
default => ';;;',
|
||||||
},
|
},
|
||||||
samlSPMetaDataXML => {
|
samlSPMetaDataXML => {
|
||||||
|
@ -1932,6 +1944,7 @@ m{^(?:ldapi://[^/]*/?|\w[\w\-\.]*(?::\d{1,5})?|ldap(?:s|\+tls)?://\w[\w\-\.]*(?:
|
||||||
type => 'authChoiceContainer',
|
type => 'authChoiceContainer',
|
||||||
keyTest => qr/^(\d*)?[a-zA-Z0-9_]+$/,
|
keyTest => qr/^(\d*)?[a-zA-Z0-9_]+$/,
|
||||||
keyMsgFail => 'Bad choice key',
|
keyMsgFail => 'Bad choice key',
|
||||||
|
test => sub { 1 },
|
||||||
select => [
|
select => [
|
||||||
[
|
[
|
||||||
{ k => 'Apache', v => 'Apache' },
|
{ k => 'Apache', v => 'Apache' },
|
||||||
|
|
|
@ -14,11 +14,11 @@ ok( $types = Lemonldap::NG::Manager::Build::Attributes::types(), 'Get types' );
|
||||||
$count += 2;
|
$count += 2;
|
||||||
|
|
||||||
foreach my $attr ( keys %$attrs ) {
|
foreach my $attr ( keys %$attrs ) {
|
||||||
|
next if($attr=~/^virtualHosts|.*MetaDataNodes|applicationList$/);
|
||||||
ok(
|
ok(
|
||||||
(
|
(
|
||||||
ref( $attrs->{$attr}->{test} )
|
ref( $attrs->{$attr}->{test} )
|
||||||
or ref( $types->{ $attrs->{$attr}->{type} }->{test} )
|
or ref( $types->{ $attrs->{$attr}->{type} }->{test} )
|
||||||
or $attrs->{$attr}->{type} =~ /Container$/
|
|
||||||
),
|
),
|
||||||
"Test exists for $attr"
|
"Test exists for $attr"
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user