File: actions.t

package info (click to toggle)
apache2 2.4.66-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 59,500 kB
  • sloc: ansic: 212,331; python: 13,830; perl: 11,307; sh: 7,258; php: 1,320; javascript: 1,314; awk: 749; makefile: 715; lex: 374; yacc: 161; xml: 2
file content (68 lines) | stat: -rw-r--r-- 1,796 bytes parent folder | download | duplicates (4)
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
use strict;
use warnings FATAL => 'all';

use Apache::Test;
use Apache::TestRequest;
use Apache::TestUtil;

## 
## mod_action tests
##
my @tests_action = (
    [ "mod_actions/",				200, 	"nada"],	# Handler for this location

    [ "modules/actions/action/test.xyz",	404],			# No handler for .xyz
    [ "modules/actions/action/test.xyz1",	404],			# Handler for .xyz1, but not virtual
    [ "modules/actions/action/test.xyz22",	404],			# No Handler for .xyz2x (but one for .xyz2)

    [ "modules/actions/action/test.xyz2",	200, 	"nada"],	# Handler for .xyz2, and virtual
);

if (have_min_apache_version('2.4.60')) {
    push(@tests_action, (
        [ "/cgi_mod_actions/action.sh?my-file-type2:/modules/actions/action/dummy", 404],
        [ "/cgi_mod_actions/action.sh?server-status:/dne", 404],
    ));
}

my @tests_script = (
    [ "modules/actions/script/test.x",		404],
    [ "modules/actions/script/test.x?foo=bar",	200,	"foo=bar"],
);

my $r;

plan tests => scalar @tests_action*2 + scalar @tests_script*(2+2+1), need_module('mod_actions');

foreach my $test (@tests_action) {
	$r = GET($test->[0]);
    t_debug "Check $test->[0] for $test->[1]\n";
	ok t_cmp($r->code, $test->[1]);
	if ($test->[1] == 200) {
		ok t_cmp($r->content, $test->[2]);
	}
	else {
		skip "RC=404, no need to check content", 1;
	}
}

foreach my $test (@tests_script) {
	$r = GET($test->[0]);
    t_debug "Check $test->[0] for $test->[1]\n";
	ok t_cmp($r->code, $test->[1]);
	if ($test->[1] == 200) {
		ok t_cmp($r->content, $test->[2]);
	}
	else {
		skip "RC=404, no need to check content", 1;
	}

	$r = POST($test->[0], content => "foo2=bar2");
	ok t_cmp($r->code, 200);
	ok t_cmp($r->content, "POST\nfoo2: bar2\n");

	# Method not allowed
	$r = PUT($test->[0], content => "foo2=bar2");
	ok t_cmp($r->code, 405);
}