1### Test for JSON parser
2
3###
4# OK
5{
6	type => "rule",
7	comment => "json parser",
8	conf => qq(
9		SecRuleEngine On
10		SecRequestBodyAccess On
11		SecDebugLog $ENV{DEBUG_LOG}
12		SecDebugLogLevel 9
13		SecRule REQUEST_HEADERS:Content-Type "application/json" \\
14		     "id:'200001',phase:1,t:none,t:lowercase,pass,nolog,ctl:requestBodyProcessor=JSON"
15		SecRule ARGS:foo "bar" "id:'200441',phase:3,log"
16	),
17	match_log => {
18		error => [ qr/ModSecurity: Warning. Pattern match "bar" at ARGS:foo.|ModSecurity: JSON support was not enabled/s, 1 ],
19		debug => [ qr/Adding JSON argument 'foo' with value 'bar'|JSON support was not enabled/, 1 ],
20	},
21	match_response => {
22		status => qr/^200$/,
23	},
24	request => new HTTP::Request(
25		POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt",
26		[
27			"Content-Type" => "application/json",
28		],
29		normalize_raw_request_data(
30			q(
31				{
32					"foo":"bar",
33					"mod":"sec"
34				}
35			),
36		),
37	),
38}
39
40