Lemonldap-NG-Manager
view release on metacpan or search on metacpan
lib/Lemonldap/NG/Manager/Conf/Tests.pm view on Meta::CPAN
push @pb, $vh if ( $vh =~ /:/ );
}
return @pb
? (
0,
'Virtual hosts '
. join( ', ', @pb )
. ' contain a port, this is not allowed'
)
: 1;
},
# Force vhost to be lowercase
vhostUpperCase => sub {
my @pb;
foreach my $vh ( keys %{ $conf->{locationRules} } ) {
push @pb, $vh if ( $vh ne lc $vh );
}
return @pb
? (
0,
'Virtual hosts ' . join( ', ', @pb ) . ' must be in lower case'
)
: 1;
},
vhostNotAnAlias => sub {
my ( @pb, @aliases, @all_aliases );
@aliases =
map { $conf->{vhostOptions}->{$_}->{vhostAliases} }
keys %{ $conf->{vhostOptions} };
foreach my $alias (@aliases) {
push @all_aliases, split( /\s+/, $alias );
}
foreach my $vh ( keys %{ $conf->{locationRules} } ) {
push @pb, $vh if ( grep { lc($_) eq lc($vh) } @all_aliases );
}
return @pb
? ( 0, 'Virtual hosts ' . join( ', ', @pb ) . ' match an alias' )
: 1;
},
# Check if "userDB" and "authentication" are consistent
authAndUserDBConsistency => sub {
foreach
my $type (qw(Facebook Google OpenID OpenIDConnect SAML WebID))
{
return ( 0,
"\"$type\" can not be used as user database without using \"$type\" for authentication"
)
if ( $conf->{userDB} =~ /$type/
and $conf->{authentication} !~ /$type/ );
}
return 1;
},
# Check that OpenID macros exists
checkAttrAndMacros => sub {
my @tmp;
foreach my $k ( keys %$conf ) {
if ( $k =~
/^(?:openIdSreg_(?:(?:(?:full|nick)nam|languag|postcod|timezon)e|country|gender|email|dob)|whatToTrace)$/
)
{
my $v = $conf->{$k};
$v =~ s/^$//;
next if ( $v =~ /^_/ );
push @tmp,
$k
unless (
defined(
$conf->{exportedVars}->{$v}
or defined( $conf->{macros}->{$v} )
)
);
}
}
return (
1,
(
@tmp
? 'Values of parameter(s) "'
. join( ', ', @tmp )
. '" are not defined in exported attributes or macros'
: ''
)
);
},
# Test that variables are exported if Google is used as UserDB
checkUserDBGoogleAXParams => sub {
my @tmp;
if ( $conf->{userDB} =~ /^Google$/ ) {
foreach my $k ( keys %{ $conf->{exportedVars} } ) {
my $v = $conf->{exportedVars}->{$k};
if ( $v !~ Lemonldap::NG::Common::Regexp::GOOGLEAXATTR() ) {
push @tmp, $v;
}
}
}
return (
1,
(
@tmp
? 'Values of parameter(s) "'
. join( ', ', @tmp )
. '" are not exported by Google'
: ''
)
);
},
# Test that variables are exported if OpenID is used as UserDB
checkUserDBOpenIDParams => sub {
my @tmp;
if ( $conf->{userDB} =~ /^OpenID$/ ) {
foreach my $k ( keys %{ $conf->{exportedVars} } ) {
my $v = $conf->{exportedVars}->{$k};
( run in 1.597 second using v1.01-cache-2.11-cpan-39bf76dae61 )