File: 03-Report_Type_Nagios.t

package info (click to toggle)
libwebinject-perl 1.86-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 428 kB
  • ctags: 197
  • sloc: perl: 4,101; xml: 257; makefile: 7
file content (84 lines) | stat: -rw-r--r-- 2,268 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env perl

##################################################

use strict;
use Test::More;
use Data::Dumper;
use FindBin qw($Bin);
use lib 't';


if($ENV{TEST_AUTHOR}) {
    eval "use HTTP::Server::Simple::CGI";
    if($@) {
        plan skip_all => 'HTTP::Server::Simple::CGI required';
    }
    else{
        plan tests => 6;
    }
}
else{
    plan skip_all => 'Author test. Set $ENV{TEST_AUTHOR} to a true value to run.';
}


use_ok('Webinject');

my $webinject = Webinject->new();
isa_ok($webinject, "Webinject", 'Object is a Webinject');

require TestWebServer;
TestWebServer->start_webserver();

##################################################
# start our test cases
test_case_01();
test_case_02();
test_case_03();
test_case_04();


##################################################
# SUBs
##################################################

##################################################
# Test File 01
sub test_case_01 {
    @ARGV = ('-r', 'nagios', $Bin."/data/01-response_codes.xml");
    my $webinject = Webinject->new();
    $webinject->{'config'}->{'baseurl'} = 'http://localhost:58080';
    my $rc = $webinject->engine();
    is($rc, 2, '01-response_codes.xml - return code');
}

##################################################
# Test File 02
sub test_case_02 {
    @ARGV = ('-r', 'nagios', $Bin."/data/02-string_verification.xml");
    my $webinject = Webinject->new();
    $webinject->{'config'}->{'baseurl'} = 'http://localhost:58080';
    my $rc = $webinject->engine();
    is($rc, 0, '02-string_verification - return code');
}

##################################################
# Test File 03
sub test_case_03 {
    @ARGV = ('-r', 'nagios', $Bin."/data/03-parse_response.xml");
    my $webinject = Webinject->new();
    $webinject->{'config'}->{'baseurl'} = 'http://localhost:58080';
    my $rc = $webinject->engine();
    is($rc, 0, '03-parse_response.xml - return code');
}

##################################################
# Test File 04
sub test_case_04 {
    @ARGV = ('-r', 'nagios', $Bin."/data/04-repeated_tests.xml");
    my $webinject = Webinject->new();
    $webinject->{'config'}->{'baseurl'} = 'http://localhost:58080';
    my $rc = $webinject->engine();
    is($rc, 2, '04-repeated_tests.xml - return code');
}