File: 615cgierror.t

package info (click to toggle)
nagios4 4.4.6-4.1
  • links: PTS
  • area: main
  • in suites: sid, trixie
  • size: 22,336 kB
  • sloc: ansic: 97,631; sh: 12,619; javascript: 5,483; perl: 2,624; makefile: 1,265; php: 381; ruby: 95
file content (36 lines) | stat: -rw-r--r-- 1,141 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/perl
# 
# Check that you get an appropriate error when the CGI config file does not exist

use warnings;
use strict;
use Test::More;
use FindBin qw($Bin);

chdir $Bin or die "Cannot chdir";

my $topdir = "$Bin/..";
my $cgi_dir = "$topdir/cgi";

opendir(DIR, $cgi_dir) or die "Cannot opendir $cgi_dir: $!";
my %cgis = map { ( $_ => 1 ) } grep /\.cgi$/, readdir DIR;
closedir DIR;

# Remove these two because the output is different
my @todos = qw(statuswml.cgi statuswrl.cgi archivejson.cgi statusjson.cgi objectjson.cgi);

TODO: {
	local $TODO = "Output is different for these CGIs";
	foreach my $cgi (@todos) {
		delete $cgis{$cgi};
#		my $output = `NAGIOS_CGI_CONFIG=etc/cgi.nonexistent REQUEST_METHOD=GET $cgi_dir/$cgi`;
#		like( $output, "/Error: Could not open CGI config file 'etc/cgi.nonexistent' for reading/", "Found error for $cgi" );
	}
}
plan tests => scalar keys %cgis;

foreach my $cgi (sort keys %cgis) {
	my $output = `NAGIOS_CGI_CONFIG=etc/cgi.nonexistent REQUEST_METHOD=GET $cgi_dir/$cgi`;
	like( $output, "/Error: Could not open CGI config file 'etc/cgi.nonexistent' for reading/", "Found error for $cgi" );
}