| 1 |
# Verify that an unmodified configuration is rejected |
| 2 |
|
| 3 |
use warnings; |
| 4 |
use Data::Dumper; |
| 5 |
use Test::More; |
| 6 |
use strict; |
| 7 |
use JSON; |
| 8 |
require 't/test-lib.pm'; |
| 9 |
|
| 10 |
my @struct = |
| 11 |
qw[t/jsonfiles/01-base-tree.json t/jsonfiles/02-base-tree-all-nodes-opened.json]; |
| 12 |
my @desc = ( 'Unopened conf', 'Unchanged conf with all nodes opened' ); |
| 13 |
my $confFiles = |
| 14 |
[ "$main::tmpdir/conf/lmConf-1.json", "$main::tmpdir/conf/lmConf-2.json" ]; |
| 15 |
|
| 16 |
# Try to save an unmodified conf |
| 17 |
for my $filename (@struct) { |
| 18 |
my ( $len, $body ) = substitute_io_handle($filename); |
| 19 |
my $desc = shift @desc; |
| 20 |
my ( $res, $resBody ); |
| 21 |
ok( |
| 22 |
$res = &client->_post( |
| 23 |
'/confs/', 'cfgNum=1', $body, 'application/json', $len |
| 24 |
), |
| 25 |
"$desc: positive result" |
| 26 |
); |
| 27 |
ok( $res->[0] == 200, "$desc: result code is 200" ) |
| 28 |
or print STDERR Dumper($res); |
| 29 |
ok( |
| 30 |
$resBody = from_json( $res->[2]->[0] ), |
| 31 |
"$desc: result body contains JSON text" |
| 32 |
); |
| 33 |
|
| 34 |
#print STDERR Dumper($resBody); |
| 35 |
ok( $resBody->{result} == 0, "$desc: JSON response contains \"result:0\"" ); |
| 36 |
ok( $resBody->{message} eq '__confNotChanged__', |
| 37 |
"$desc: conf was not changed" ) |
| 38 |
or print STDERR Dumper($resBody); |
| 39 |
ok( !-e $confFiles->[1], "$desc: file isn't created" ); |
| 40 |
|
| 41 |
#print STDERR Dumper($resBody); |
| 42 |
count(6); |
| 43 |
} |
| 44 |
eval { unlink $confFiles->[1]; rmdir $main::tmpdir; }; |
| 45 |
|
| 46 |
done_testing( count() ); |