Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit52bef20

Browse files
author
Felipe Zimmerle
committed
Adds unit test to the JSON parser
Unit test to test whenever the JSON parser is enabled
1 parenta95f371 commit52bef20

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

‎tests/regression/rule/15-json.t‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
SecDebugLogLevel9
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. Patternmatch"bar" at ARGS:foo.|ModSecurity: JSON support wasnot enabled/s,1 ],
19+
debug=> [ qr/Adding JSON argument'foo'withvalue'bar'|JSON support wasnot 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+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp