Verify that node titles are not attribute names
This commit is contained in:
parent
8c4a26d0fe
commit
7e79007a2b
|
@ -7,8 +7,14 @@ use strict;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
|
|
||||||
my $knownExceptions = qr/^(?:remoteCookieName)$/;
|
# CONSTANTS
|
||||||
|
|
||||||
|
# Node names used more than one time
|
||||||
|
my $usedMoreThanOneTimeInTree = qr/^(?:
|
||||||
|
remoteCookieName
|
||||||
|
)$/x;
|
||||||
|
|
||||||
|
# Attributes not managed in web interface
|
||||||
my @notManagedAttributes = (
|
my @notManagedAttributes = (
|
||||||
|
|
||||||
# Complex nodes
|
# Complex nodes
|
||||||
|
@ -28,6 +34,17 @@ my @notManagedAttributes = (
|
||||||
'protection',
|
'protection',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
# Words used either as attribute name and node title
|
||||||
|
my $doubleUsage = qr/^(?:
|
||||||
|
samlSPMetaDataOptions|
|
||||||
|
samlIDPMetaDataOptions|
|
||||||
|
oidcRPMetaDataOptions|
|
||||||
|
oidcOPMetaDataOptions|
|
||||||
|
vhostOptions
|
||||||
|
)$/x;
|
||||||
|
|
||||||
|
# TESTS
|
||||||
|
|
||||||
# 1 - Collect attributes
|
# 1 - Collect attributes
|
||||||
|
|
||||||
# Attributes.pm is parsed with open() and not loaded to detect double entries
|
# Attributes.pm is parsed with open() and not loaded to detect double entries
|
||||||
|
@ -120,6 +137,14 @@ sub scanTree {
|
||||||
"Node $name has leafs"
|
"Node $name has leafs"
|
||||||
);
|
);
|
||||||
$count += 4;
|
$count += 4;
|
||||||
|
|
||||||
|
# Nodes must not use attributes name
|
||||||
|
unless ( $name =~ $doubleUsage ) {
|
||||||
|
ok( !exists( $h{$name} ),
|
||||||
|
"Node title ($name) must not be used as attribute name" );
|
||||||
|
$count++;
|
||||||
|
}
|
||||||
|
|
||||||
foreach my $n (qw(nodes nodes_cond group)) {
|
foreach my $n (qw(nodes nodes_cond group)) {
|
||||||
|
|
||||||
# Scan subnodes lists
|
# Scan subnodes lists
|
||||||
|
@ -130,9 +155,9 @@ sub scanTree {
|
||||||
# Case 2: leaf
|
# Case 2: leaf
|
||||||
|
|
||||||
# Sub case 21: normal leaf
|
# Sub case 21: normal leaf
|
||||||
elsif ( $leaf !~ $knownExceptions ) {
|
elsif ( $leaf !~ $usedMoreThanOneTimeInTree ) {
|
||||||
|
|
||||||
# Check that leaf corresponds to an attribute name
|
# Check that leaf is a string
|
||||||
ok( $leaf =~ /^\*?\w+/, "Leaf is an attribute name ($leaf)" );
|
ok( $leaf =~ /^\*?\w+/, "Leaf is an attribute name ($leaf)" );
|
||||||
$h2{$leaf}++;
|
$h2{$leaf}++;
|
||||||
|
|
||||||
|
@ -141,8 +166,8 @@ sub scanTree {
|
||||||
$count += 2;
|
$count += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Sub case 22: $knownExceptions contains leaf used more than one time
|
# Sub case 22: $usedMoreThanOneTimeInTree contains leaf used more than
|
||||||
# in tree
|
# one time in tree
|
||||||
else {
|
else {
|
||||||
$h2{$leaf}++;
|
$h2{$leaf}++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user