mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
Adds unit test to the JSON parser
Unit test to test whenever the JSON parser is enabled
This commit is contained in:
parent
a95f37196e
commit
52bef20ce5
39
tests/regression/rule/15-json.t
Normal file
39
tests/regression/rule/15-json.t
Normal file
@ -0,0 +1,39 @@
|
||||
### Test for JSON parser
|
||||
|
||||
###
|
||||
# OK
|
||||
{
|
||||
type => "rule",
|
||||
comment => "json parser",
|
||||
conf => qq(
|
||||
SecRuleEngine On
|
||||
SecRequestBodyAccess On
|
||||
SecDebugLog $ENV{DEBUG_LOG}
|
||||
SecDebugLogLevel 9
|
||||
SecRule REQUEST_HEADERS:Content-Type "application/json" \\
|
||||
"id:'200001',phase:1,t:none,t:lowercase,pass,nolog,ctl:requestBodyProcessor=JSON"
|
||||
SecRule ARGS:foo "bar" "id:'200441',phase:3,log"
|
||||
),
|
||||
match_log => {
|
||||
error => [ qr/ModSecurity: Warning. Pattern match "bar" at ARGS:foo.|ModSecurity: JSON support was not enabled/s, 1 ],
|
||||
debug => [ qr/Adding JSON argument 'foo' with value 'bar'|JSON support was not enabled/, 1 ],
|
||||
},
|
||||
match_response => {
|
||||
status => qr/^200$/,
|
||||
},
|
||||
request => new HTTP::Request(
|
||||
POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt",
|
||||
[
|
||||
"Content-Type" => "application/json",
|
||||
],
|
||||
normalize_raw_request_data(
|
||||
q(
|
||||
{
|
||||
"foo":"bar",
|
||||
"mod":"sec"
|
||||
}
|
||||
),
|
||||
),
|
||||
),
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user