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