Skip to content

Commit 9bad4b0

Browse files
committed
Refactorize HTTP request tests
1 parent b5dfe42 commit 9bad4b0

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

.github/workflows/test.yml

+28-8
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,38 @@ jobs:
5050
sudo /usr/local/nginx/sbin/nginx -c /home/runner/work/ModSecurity-nginx/ModSecurity-nginx/ModSecurity-nginx/.github/nginx/nginx.conf
5151
- name: Run attack test vhost 1
5252
run: |
53-
resp=`curl -I -X GET -H "Host: modsectest1" http://localhost/?q=attack | head -1 | cut -d$' ' -f2`
54-
if [ $resp == "403" ]; then echo "OK"; else echo "FAIL"; exit 1; fi
53+
status=$(curl -sSo /dev/null -w %{http_code} -I -X GET -H "Host: modsectest1" "http://localhost/?q=attack")
54+
if [ "${status}" == "403" ]; then
55+
echo "OK"
56+
else
57+
echo "FAIL"
58+
exit 1
59+
fi
5560
- name: Run non-attack test vhost 1
5661
run: |
57-
resp=`curl -I -X GET -H "Host: modsectest1" http://localhost/?q=1 | head -1 | cut -d$' ' -f2`
58-
if [ $resp == "200" ]; then echo "OK"; else echo "FAIL"; exit 1; fi
62+
status=$(curl -sSo /dev/null -w %{http_code} -I -X GET -H "Host: modsectest1" "http://localhost/?q=1")
63+
if [ "${status}" == "200" ]; then
64+
echo "OK"
65+
else
66+
echo "FAIL"
67+
exit 1
68+
fi
5969
- name: Run attack test vhost 2
6070
run: |
61-
resp=`curl -I -X GET -H "Host: modsectest2" http://localhost/?q=attack | head -1 | cut -d$' ' -f2`
62-
if [ $resp == "403" ]; then echo "OK"; else echo "FAIL"; exit 1; fi
71+
status=$(curl -sSo /dev/null -w %{http_code} -I -X GET -H "Host: modsectest2" "http://localhost/?q=attack")
72+
if [ "${status}" == "403" ]; then
73+
echo "OK"
74+
else
75+
echo "FAIL"
76+
exit 1
77+
fi
6378
- name: Run non-attack test vhost 2
6479
run: |
65-
resp=`curl -I -X GET -H "Host: modsectest2" http://localhost/?q=1 | head -1 | cut -d$' ' -f2`
66-
if [ $resp == "200" ]; then echo "OK"; else echo "FAIL"; exit 1; fi
80+
status=$(curl -sSo /dev/null -w %{http_code} -I -X GET -H "Host: modsectest2" "http://localhost/?q=1")
81+
if [ "${status}" == "200" ]; then
82+
echo "OK"
83+
else
84+
echo "FAIL"
85+
exit 1
86+
fi
6787

0 commit comments

Comments
 (0)