Skip to content

Commit 205a9ce

Browse files
committed
more tests
1 parent b01ad8a commit 205a9ce

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

t/headers.t

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ x-frame-options: SAMEORIGIN
146146
x-xss-protection: 0
147147
referrer-policy: origin
148148
149+
150+
149151
=== TEST 8: X-Frame-Options should not be sent for CSS (even when encoding specified)
150152
--- config
151153
security_headers on;
@@ -162,3 +164,64 @@ hello world
162164
--- response_headers
163165
content-type: text/css; charset=utf-8
164166
!x-frame-options
167+
168+
169+
170+
=== TEST 9: hides common powered-by headers
171+
--- config
172+
location = /hello {
173+
security_headers on;
174+
175+
add_header X-Powered-By "PHP/8.2";
176+
add_header X-Generator "WordPress 6.5";
177+
add_header X-Jenkins "2.440";
178+
add_header X-Something-Custom "Visible";
179+
return 200 "hello world\n";
180+
}
181+
--- request
182+
GET /hello
183+
--- response_body
184+
hello world
185+
--- response_headers
186+
!x-powered-by
187+
!x-generator
188+
!x-jenkins
189+
x-something-custom: Visible
190+
191+
192+
193+
=== TEST 10: headers are visible when security_headers is off
194+
--- config
195+
location = /hello {
196+
# security_headers off (по умолчанию)
197+
add_header X-Powered-By "PHP/8.2";
198+
add_header X-Generator "WordPress";
199+
return 200 "hello world\n";
200+
}
201+
--- request
202+
GET /hello
203+
--- response_body
204+
hello world
205+
--- response_headers
206+
x-powered-by: PHP/8.2
207+
x-generator: WordPress
208+
209+
210+
211+
=== TEST 11: only hide server header
212+
--- config
213+
hide_server_tokens on;
214+
location = /hello {
215+
add_header Server "nginx";
216+
add_header X-Powered-By "PHP";
217+
add_header X-Generator "Drupal";
218+
return 200 "hello world\n";
219+
}
220+
--- request
221+
GET /hello
222+
--- response_body
223+
hello world
224+
--- response_headers
225+
!server
226+
x-powered-by: PHP
227+
x-generator: Drupal

0 commit comments

Comments
 (0)