|
Packit Service |
392537 |
# Copyright (c) 2014-2016 Carbonite, Inc. All Rights Reserved.
|
|
Packit Service |
392537 |
#
|
|
Packit Service |
392537 |
# This program is free software; you can redistribute it and/or
|
|
Packit Service |
392537 |
# modify it under the terms of the GNU General Public License
|
|
Packit Service |
392537 |
# as published by the Free Software Foundation; either version 2
|
|
Packit Service |
392537 |
# of the License, or (at your option) any later version.
|
|
Packit Service |
392537 |
#
|
|
Packit Service |
392537 |
# This program is distributed in the hope that it will be useful, but
|
|
Packit Service |
392537 |
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
Packit Service |
392537 |
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
Packit Service |
392537 |
# for more details.
|
|
Packit Service |
392537 |
#
|
|
Packit Service |
392537 |
# You should have received a copy of the GNU General Public License along
|
|
Packit Service |
392537 |
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
Packit Service |
392537 |
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
Packit Service |
392537 |
#
|
|
Packit Service |
392537 |
# Contact information: Carbonite Inc., 756 N Pastoria Ave
|
|
Packit Service |
392537 |
# Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
use Test::More;
|
|
Packit Service |
392537 |
use File::Path;
|
|
Packit Service |
392537 |
use strict;
|
|
Packit Service |
392537 |
use warnings;
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
use lib '@amperldir@';
|
|
Packit Service |
392537 |
use Installcheck;
|
|
Packit Service |
392537 |
use Installcheck::Dumpcache;
|
|
Packit Service |
392537 |
use Installcheck::Config;
|
|
Packit Service |
392537 |
use Amanda::Paths;
|
|
Packit Service |
392537 |
use Amanda::Device qw( :constants );
|
|
Packit Service |
392537 |
use Amanda::Debug;
|
|
Packit Service |
392537 |
use Amanda::MainLoop;
|
|
Packit Service |
392537 |
use Amanda::Config qw( :init :getconf config_dir_relative );
|
|
Packit Service |
392537 |
use Amanda::Changer;
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
eval 'use Installcheck::Rest;';
|
|
Packit Service |
392537 |
if ($@) {
|
|
Packit Service |
392537 |
plan skip_all => "Can't load Installcheck::Rest: $@";
|
|
Packit Service |
392537 |
exit 1;
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# set up debugging so debug output doesn't interfere with test results
|
|
Packit Service |
392537 |
Amanda::Debug::dbopen("installcheck");
|
|
Packit Service |
392537 |
Installcheck::log_test_output();
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# and disable Debug's die() and warn() overrides
|
|
Packit Service |
392537 |
Amanda::Debug::disable_die_override();
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
my $rest = Installcheck::Rest->new();
|
|
Packit Service |
392537 |
if ($rest->{'error'}) {
|
|
Packit Service |
392537 |
plan skip_all => "Can't start JSON Rest server: $rest->{'error'}: see " . Amanda::Debug::dbfn();
|
|
Packit Service |
392537 |
exit 1;
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
plan tests => 1;
|
|
Packit Service |
392537 |
my $reply;
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
my $amperldir = $Amanda::Paths::amperldir;
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
#CODE 1550000
|
|
Packit Service |
392537 |
$reply = $rest->get("http://localhost:5001/amanda/v1.0");
|
|
Packit Service |
392537 |
is_deeply (Installcheck::Rest::remove_source_line($reply),
|
|
Packit Service |
392537 |
{ body =>
|
|
Packit Service |
392537 |
[ { 'source_filename' => "$amperldir/Amanda/Rest/Version.pm",
|
|
Packit Service |
392537 |
'BUILT_DATE' => $Amanda::Constants::BUILT_DATE,
|
|
Packit Service |
392537 |
'BUILT_REV' => $Amanda::Constants::BUILT_REV,
|
|
Packit Service |
392537 |
'BUILT_BRANCH' => $Amanda::Constants::BUILT_BRANCH,
|
|
Packit Service |
392537 |
'VERSION' => $Amanda::Constants::VERSION,
|
|
Packit Service |
392537 |
'severity' => $Amanda::Message::SUCCESS,
|
|
Packit Service |
392537 |
'message' => 'The version',
|
|
Packit Service |
392537 |
'process' => 'Amanda::Rest::Version',
|
|
Packit Service |
392537 |
'running_on' => 'amanda-server',
|
|
Packit Service |
392537 |
'component' => 'rest-server',
|
|
Packit Service |
392537 |
'module' => 'amanda',
|
|
Packit Service |
392537 |
'code' => '1550000'
|
|
Packit Service |
392537 |
},
|
|
Packit Service |
392537 |
],
|
|
Packit Service |
392537 |
http_code => 200,
|
|
Packit Service |
392537 |
},
|
|
Packit Service |
392537 |
"get version");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$rest->stop();
|