File: 10-append-prepend.t

package info (click to toggle)
modsecurity-apache 2.9.11-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 10,436 kB
  • sloc: ansic: 53,590; sh: 5,249; perl: 2,340; cpp: 1,930; makefile: 618; xml: 6
file content (49 lines) | stat: -rw-r--r-- 1,158 bytes parent folder | download | duplicates (10)
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
# TODO: Need more tests here

### append
{
	type => "action",
	comment => "append content",
	conf => qq(
		SecRuleEngine On
        SecContentInjection On
		SecDebugLog "$ENV{DEBUG_LOG}"
		SecDebugLogLevel 9
		SecAction "phase:1,setvar:tx.test=test,id:500002"
		SecAction "phase:2,append:'APPEND: \%{tx.test}',id:500003"
	),
	match_log => {
        debug => [ "Added content to bottom: APPEND: test", 1 ],
	},
	match_response => {
		status => qr/^200$/,
		content => qr/APPEND: test$/,
	},
	request => new HTTP::Request(
		GET => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt",
	),
},

### prepend
{
	type => "action",
	comment => "prepend content",
	conf => qq(
		SecRuleEngine On
        SecContentInjection On
		SecDebugLog "$ENV{DEBUG_LOG}"
		SecDebugLogLevel 9
		SecAction "phase:1,setvar:tx.test=test,id:500004"
		SecAction "phase:2,prepend:'PREPEND: \%{tx.test}',id:500005"
	),
	match_log => {
        debug => [ "Added content to top: PREPEND: test", 1 ],
	},
	match_response => {
		status => qr/^200$/,
		content => qr/^PREPEND: test/,
	},
	request => new HTTP::Request(
		GET => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt",
	),
},