Skip to content

Commit 77c8f78

Browse files
committed
Tests; Changed module to AUX_FILTER
1 parent 150c2cb commit 77c8f78

File tree

4 files changed

+84
-2
lines changed

4 files changed

+84
-2
lines changed

.travis.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
language: c
2+
compiler:
3+
- clang
4+
- gcc
5+
env:
6+
matrix:
7+
- NGINX_VERSION=1.16.0
8+
- NGINX_VERSION=1.17.2 -
9+
addons:
10+
apt:
11+
packages:
12+
- libpcre3-dev
13+
- libssl-dev
14+
- perl
15+
- cpanminus
16+
cache:
17+
ccache: true
18+
directories:
19+
- $HOME/perl5
20+
before_install:
21+
- test $TRAVIS_BRANCH != coverity_scan -o ${TRAVIS_JOB_NUMBER##*.} = 1 || exit 0
22+
- cpanm --notest --local-lib=$HOME/perl5 Test::Nginx
23+
install:
24+
- test $TRAVIS_BRANCH != coverity_scan || exit 0
25+
- wget -O - http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz | tar -xzf -
26+
- cd nginx-${NGINX_VERSION}
27+
- ./configure --with-debug --add-module=..
28+
- make -j2
29+
- export PATH=$(pwd)/objs:$PATH
30+
- cd ..
31+
script:
32+
- test $TRAVIS_BRANCH != coverity_scan || exit 0
33+
- PERL5LIB=$HOME/perl5/lib/perl5 TEST_NGINX_VERBOSE=true prove -v
34+
after_failure:
35+
- cat t/servroot/conf/nginx.conf
36+
- cat t/servroot/access.log
37+
- cat t/servroot/error.log

config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
ngx_addon_name=ngx_http_security_headers_module
22

33
if test -n "$ngx_module_link"; then
4-
ngx_module_type=HTTP_FILTER
4+
ngx_module_type=HTTP_AUX_FILTER
55
ngx_module_name=ngx_http_security_headers_module
66
ngx_module_srcs="$ngx_addon_dir/src/ngx_http_security_headers_module.c"
77

88
. auto/module
99
else
10-
HTTP_MODULES="$HTTP_MODULES ngx_http_security_headers_module"
10+
HTTP_AUX_FILTER_MODULES="$HTTP_AUX_FILTER_MODULES ngx_http_security_headers_module"
1111
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/src/ngx_http_security_headers_module.c"
1212
fi

t/config.t

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
use Test::Nginx::Socket 'no_plan';
2+
3+
run_tests();
4+
5+
__DATA__
6+
7+
=== TEST 1: dying on bad config
8+
--- http_config
9+
security_headers bad;
10+
--- config
11+
--- must_die
12+
--- error_log
13+
invalid value "bad" in "security_headers" directive, it must be "on" or "off"

t/headers.t

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
use Test::Nginx::Socket 'no_plan';
2+
3+
run_tests();
4+
5+
__DATA__
6+
7+
=== TEST 1: server is hidden
8+
--- config
9+
security_headers on;
10+
location = /hello {
11+
return 200 "hello world\n";
12+
}
13+
--- request
14+
GET /hello
15+
--- response_body
16+
hello world
17+
--- response_headers
18+
!Server
19+
20+
21+
=== TEST 2: x-xss-protection added
22+
--- config
23+
security_headers on;
24+
location = /hello {
25+
return 200 "hello world\n";
26+
}
27+
--- request
28+
GET /hello
29+
--- response_body
30+
hello world
31+
--- response_headers
32+
X-XSS-Protection: 1; mode=block

0 commit comments

Comments
 (0)