Skip to content

Commit b9d7d27

Browse files
defanatorzimmerle
authored andcommitted
Tests: fix block action to match expected behavior
1 parent b51e555 commit b9d7d27

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

tests/modsecurity-proxy.t

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ http {
4747
modsecurity on;
4848
modsecurity_rules '
4949
SecRuleEngine On
50+
SecDefaultAction "phase:1,log,deny,status:403"
5051
SecRule ARGS "@streq redirect301" "id:1,phase:1,status:301,redirect:http://www.modsecurity.org"
5152
SecRule ARGS "@streq redirect302" "id:2,phase:1,status:302,redirect:http://www.modsecurity.org"
5253
SecRule ARGS "@streq block401" "id:3,phase:1,status:401,block"
@@ -59,6 +60,7 @@ http {
5960
modsecurity on;
6061
modsecurity_rules '
6162
SecRuleEngine On
63+
SecDefaultAction "phase:2,log,deny,status:403"
6264
SecRule ARGS "@streq redirect301" "id:1,phase:2,status:301,redirect:http://www.modsecurity.org"
6365
SecRule ARGS "@streq redirect302" "id:2,phase:2,status:302,redirect:http://www.modsecurity.org"
6466
SecRule ARGS "@streq block401" "id:3,phase:2,status:401,block"
@@ -71,6 +73,7 @@ http {
7173
modsecurity on;
7274
modsecurity_rules '
7375
SecRuleEngine On
76+
SecDefaultAction "phase:3,log,deny,status:403"
7477
SecRule ARGS "@streq redirect301" "id:1,phase:3,status:301,redirect:http://www.modsecurity.org"
7578
SecRule ARGS "@streq redirect302" "id:2,phase:3,status:302,redirect:http://www.modsecurity.org"
7679
SecRule ARGS "@streq block401" "id:3,phase:3,status:401,block"
@@ -83,6 +86,7 @@ http {
8386
modsecurity on;
8487
modsecurity_rules '
8588
SecRuleEngine On
89+
SecDefaultAction "phase:4,log,deny,status:403"
8690
SecRule ARGS "@streq redirect301" "id:1,phase:4,status:301,redirect:http://www.modsecurity.org"
8791
SecRule ARGS "@streq redirect302" "id:2,phase:4,status:302,redirect:http://www.modsecurity.org"
8892
SecRule ARGS "@streq block401" "id:3,phase:4,status:401,block"
@@ -122,15 +126,15 @@ is(http_get('/phase4?what=redirect301'), '', 'redirect 301 - phase 4');
122126

123127
# Block (401)
124128
like(http_get('/phase1?what=block401'), qr/401 Unauthorized/, 'block 401 - phase 1');
125-
like(http_get('/phase2?what=block401'), qr/401 Unauthorized/, 'block 401 - phase 2');
126-
like(http_get('/phase3?what=block401'), qr/401 Unauthorized/, 'block 401 - phase 3');
127-
is(http_get('/phase4?what=block401'), '', 'block 401 - phase 4');
129+
like(http_get('/phase2?what=block401'), qr/401 Unauthorized/, 'block 401 - phase 2');
130+
like(http_get('/phase3?what=block401'), qr/401 Unauthorized/, 'block 401 - phase 3');
131+
is(http_get('/phase4?what=block401'), '', 'block 401 - phase 4');
128132

129133
# Block (403)
130134
like(http_get('/phase1?what=block403'), qr/403 Forbidden/, 'block 403 - phase 1');
131-
like(http_get('/phase2?what=block403'), qr/403 Forbidden/, 'block 403- phase 2');
132-
like(http_get('/phase3?what=block403'), qr/403 Forbidden/, 'block 403 - phase 3');
133-
is(http_get('/phase4?what=block403'), '', 'block 403 - phase 4');
135+
like(http_get('/phase2?what=block403'), qr/403 Forbidden/, 'block 403 - phase 2');
136+
like(http_get('/phase3?what=block403'), qr/403 Forbidden/, 'block 403 - phase 3');
137+
is(http_get('/phase4?what=block403'), '', 'block 403 - phase 4');
134138

135139
# Nothing to detect
136140
like(http_get('/phase1?what=nothing'), qr/phase1\?what=nothing\' not found/, 'nothing phase 1');

tests/modsecurity.t

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ http {
6464
modsecurity on;
6565
modsecurity_rules '
6666
SecRuleEngine On
67+
SecDefaultAction "phase:1,log,deny,status:403"
6768
SecRule ARGS "@streq redirect301" "id:1,phase:1,status:301,redirect:http://www.modsecurity.org"
6869
SecRule ARGS "@streq redirect302" "id:2,phase:1,status:302,redirect:http://www.modsecurity.org"
6970
SecRule ARGS "@streq block401" "id:3,phase:1,status:401,block"
@@ -74,6 +75,7 @@ http {
7475
modsecurity on;
7576
modsecurity_rules '
7677
SecRuleEngine On
78+
SecDefaultAction "phase:2,log,deny,status:403"
7779
SecRule ARGS "@streq redirect301" "id:1,phase:2,status:301,redirect:http://www.modsecurity.org"
7880
SecRule ARGS "@streq redirect302" "id:2,phase:2,status:302,redirect:http://www.modsecurity.org"
7981
SecRule ARGS "@streq block401" "id:3,phase:2,status:401,block"
@@ -84,6 +86,7 @@ http {
8486
modsecurity on;
8587
modsecurity_rules '
8688
SecRuleEngine On
89+
SecDefaultAction "phase:3,log,deny,status:403"
8790
SecRule ARGS "@streq redirect301" "id:1,phase:3,status:301,redirect:http://www.modsecurity.org"
8891
SecRule ARGS "@streq redirect302" "id:2,phase:3,status:302,redirect:http://www.modsecurity.org"
8992
SecRule ARGS "@streq block401" "id:3,phase:3,status:401,block"
@@ -94,6 +97,7 @@ http {
9497
modsecurity on;
9598
modsecurity_rules '
9699
SecRuleEngine On
100+
SecDefaultAction "phase:4,log,deny,status:403"
97101
SecRule ARGS "@streq redirect301" "id:1,phase:4,status:301,redirect:http://www.modsecurity.org"
98102
SecRule ARGS "@streq redirect302" "id:2,phase:4,status:302,redirect:http://www.modsecurity.org"
99103
SecRule ARGS "@streq block401" "id:3,phase:4,status:401,block"
@@ -129,15 +133,15 @@ is(http_get('/phase4?what=redirect301'), '', 'redirect 301 - phase 4');
129133

130134
# Block (401)
131135
like(http_get('/phase1?what=block401'), qr/401 Unauthorized/, 'block 401 - phase 1');
132-
like(http_get('/phase2?what=block401'), qr/401 Unauthorized/, 'block 401 - phase 2');
133-
like(http_get('/phase3?what=block401'), qr/401 Unauthorized/, 'block 401 - phase 3');
134-
is(http_get('/phase4?what=block401'), '', 'block 401 - phase 4');
136+
like(http_get('/phase2?what=block401'), qr/401 Unauthorized/, 'block 401 - phase 2');
137+
like(http_get('/phase3?what=block401'), qr/401 Unauthorized/, 'block 401 - phase 3');
138+
is(http_get('/phase4?what=block401'), '', 'block 401 - phase 4');
135139

136140
# Block (403)
137141
like(http_get('/phase1?what=block403'), qr/403 Forbidden/, 'block 403 - phase 1');
138-
like(http_get('/phase2?what=block403'), qr/403 Forbidden/, 'block 403- phase 2');
139-
like(http_get('/phase3?what=block403'), qr/403 Forbidden/, 'block 403 - phase 3');
140-
is(http_get('/phase4?what=block403'), '', 'block 403 - phase 4');
142+
like(http_get('/phase2?what=block403'), qr/403 Forbidden/, 'block 403 - phase 2');
143+
like(http_get('/phase3?what=block403'), qr/403 Forbidden/, 'block 403 - phase 3');
144+
is(http_get('/phase4?what=block403'), '', 'block 403 - phase 4');
141145

142146
# Nothing to detect
143147
like(http_get('/phase1?what=nothing'), qr/should be moved\/blocked before this./, 'nothing phase 1');

0 commit comments

Comments
 (0)