| 1 |
use Test::More tests => 6; |
|---|
| 2 |
use XML::LibXML; |
|---|
| 3 |
use XML::LibXML::XPathContext; |
|---|
| 4 |
use testconfig; |
|---|
| 5 |
use apiclient; |
|---|
| 6 |
|
|---|
| 7 |
use strict; |
|---|
| 8 |
my $xp = XML::LibXML->new(); |
|---|
| 9 |
my $xpc = XML::LibXML::XPathContext->new(); |
|---|
| 10 |
|
|---|
| 11 |
ok(start_noit("003", { modules => $all_noit_modules }), 'starting noit'); |
|---|
| 12 |
sleep(1); |
|---|
| 13 |
my $c = apiclient->new('localhost', $NOIT_API_PORT); |
|---|
| 14 |
my @r = $c->get("/checks/show/f7cea020-f19d-11dd-85a6-cb6d3a2207dc"); |
|---|
| 15 |
is($r[0], 404, 'get checks'); |
|---|
| 16 |
|
|---|
| 17 |
@r = $c->put("/checks/set/f7cea020-f19d-11dd-85a6-cb6d3a2207dc", |
|---|
| 18 |
qq{<?xml version="1.0" encoding="utf8"?> |
|---|
| 19 |
<check><attributes><target>127.0.0.1</target><period>5000</period><timeout>1000</timeout><name>selfcheck</name><filterset/><module>selfcheck</module></attributes><config/></check>}); |
|---|
| 20 |
|
|---|
| 21 |
is($r[0], 200, 'add selfcheck'); |
|---|
| 22 |
my $doc = $xp->parse_string($r[1]); |
|---|
| 23 |
is($xpc->findvalue('/check/attributes/uuid', $doc), 'f7cea020-f19d-11dd-85a6-cb6d3a2207dc', 'saved'); |
|---|
| 24 |
|
|---|
| 25 |
sleep(1); |
|---|
| 26 |
$c = apiclient->new('localhost', $NOIT_API_PORT); |
|---|
| 27 |
@r = $c->get("/checks/show/f7cea020-f19d-11dd-85a6-cb6d3a2207dc"); |
|---|
| 28 |
is($r[0], 200, 'get checks'); |
|---|
| 29 |
$doc = $xp->parse_string($r[1]); |
|---|
| 30 |
is($xpc->findvalue('/check/state/state', $doc), 'good', 'results'); |
|---|
| 31 |
|
|---|
| 32 |
1; |
|---|