Fix information lost when renaming partner (closes: #1042)

This commit is contained in:
Xavier Guimard 2016-06-14 05:26:24 +00:00
parent 9cca6ae712
commit dfffbd1742
2 changed files with 26 additions and 6 deletions

View File

@ -199,6 +199,12 @@ sub _scanNodes {
# Check hostname/partner name changes (id points to the old name)
$newNames{$host} = $leaf->{title};
if ( $newNames{$host} ne $host and $host !~ /^new__/ ) {
hdebug(" $host becomes $newNames{$host}");
$self->confChanged(1);
push @{ $self->changes },
{ key => $base, old => $host, new => $newNames{$host} };
}
$self->_scanNodes($subNodes);
next;
@ -281,7 +287,8 @@ sub _scanNodes {
}
}
elsif ( $target =~ /^$virtualHostKeys$/o ) {
$self->set( 'vhostOptions', $key, $target, $leaf->{data} );
$self->set( 'vhostOptions', [ $oldName, $key ],
$target, $leaf->{data} );
}
else {
push @{ $self->errors },
@ -317,7 +324,8 @@ sub _scanNodes {
}
elsif ( $target =~ /^saml(?:S|ID)PMetaDataXML$/ ) {
hdebug(" $target");
$self->set( $target, $key, $target, $leaf->{data} );
$self->set( $target, [ $oldName, $key ],
$target, $leaf->{data} );
}
elsif ( $target =~ /^saml(?:ID|S)PMetaDataOptions/ ) {
my $optKey = $&;
@ -326,7 +334,10 @@ sub _scanNodes {
/^(?:$samlIDPMetaDataNodeKeys|$samlSPMetaDataNodeKeys)/o
)
{
$self->set( $optKey, $key, $target, $leaf->{data} );
$self->set(
$optKey, [ $oldName, $key ],
$target, $leaf->{data}
);
}
else {
push @{ $self->errors },
@ -394,7 +405,10 @@ sub _scanNodes {
/^(?:$oidcOPMetaDataNodeKeys|$oidcRPMetaDataNodeKeys)/o
)
{
$self->set( $optKey, $key, $target, $leaf->{data} );
$self->set(
$optKey, [ $oldName, $key ],
$target, $leaf->{data}
);
}
else {
push @{ $self->errors },
@ -813,8 +827,9 @@ sub set {
my $tmp = shift;
push @path, $tmp;
foreach my $i ( 0, 1 ) {
$confs[$i]->{$tmp} //= {};
$confs[$i] = $confs[$i]->{$tmp};
my $v = ref($tmp) ? $tmp->[$i] : $tmp;
$confs[$i]->{$v} //= {};
$confs[$i] = $confs[$i]->{$v};
}
}
my $target = shift;

View File

@ -172,6 +172,11 @@ sub changes {
'key' => 'locationRules',
'new' => 'test.ex.com'
},
{
'key' => 'virtualHosts',
'new' => 'test3.example.com',
'old' => 'test2.example.com'
},
{
'key' => 'virtualHosts',
'old' => 'test2.example.com'