Check for removed apps (#907)

Not completly verified
environments/ppa-mbqj77/deployments/1
Xavier Guimard 9 years ago
parent 1c93769e1b
commit b50e985ee6
  1. 12
      lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Conf/Parser.pm
  2. 21
      lemonldap-ng-manager/t/12-save-changed-conf.t

@ -432,8 +432,18 @@ sub _scanNodes {
if ( ref $subNodes ) {
$self->_scanNodes($subNodes) or return 0;
}
my @listCatRef = keys %{ $cmp->{$app} };
my @listCatNew = keys %{ $cn->{$s} };
# TODO: check for deleted
# Check for deleted
unless ( @listCatRef == @listCatNew ) {
$self->confChanged(1);
push @{ $self->changes },
{
key => join( ', ', 'applicationList', @path ),
new => 'New cat(s)/app(s)',
};
}
}
# Create new apps

@ -23,20 +23,29 @@ my ( $res, $resBody );
ok( $res = &client->_post( '/confs/', 'cfgNum=1', &body, 'application/json' ),
"Request succeed" );
ok( $res->[0] == 200, "Result code is 200" );
ok( $resBody = from_json( $res->[2]->[0] ),
"Result body contains JSON text" );
ok( $resBody = from_json( $res->[2]->[0] ), "Result body contains JSON text" );
ok( $resBody->{result} == 1, "JSON response contains \"result:1\"" )
or print STDERR Dumper($resBody);
ok( -f $confFiles->[1], 'File is created' );
my @changes = @{&changes};
my @cmsg = @{ $resBody->{details}->{__changes__} };
ok( @changes == @cmsg, 'Same changes count' );
my $bug;
ok( @changes == @cmsg, 'Same changes count' ) or $bug = 1;
while ( my $c = shift @{ $resBody->{details}->{__changes__} } ) {
my $cmp1 = @changes;
my $cmp2 = @cmsg;
@changes = grep { $_->{key} ne $c->{key} } @changes;
@cmsg = grep { $_->{key} ne $c->{key} } @cmsg;
ok( ( $cmp1 - @changes ) == ( $cmp2 - @cmsg ), "$c->{key} found" );
count(1);
}
ok( !@changes, 'All changes detected' ) or $bug = 1;
if ($bug) {
print STDERR Dumper( \@changes, \@cmsg );
}
ok( !@changes, 'All changes detected' );
#print STDERR Dumper(\@changes,\@cmsg);
@ -67,6 +76,10 @@ sub changes {
'new' => 'Application Test 3',
'key' => 'applicationList, Sample applications'
},
{
'key' => 'applicationList',
'new' => 'New cat(s)/app(s)'
},
{
'key' => 'userDB',
'new' => 'LDAP',

Loading…
Cancel
Save