Skip to content

Commit 92fc924

Browse files
committed
Rework auto tests
1 parent effe865 commit 92fc924

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

test.sh

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,19 @@ DID_FAIL=0
66

77
checkUrl() {
88
set +e
9-
curl -# --fail -I "${1}"
9+
if [ "$2" = "form" ]; then
10+
curl -# --cookie-jar /tmp/test.cookie-jar -b /tmp/test.cookie-jar --fail \
11+
-H 'Content-Type: application/x-www-form-urlencoded' \
12+
-L \
13+
--data-raw "${3}" \
14+
"$1"
15+
else
16+
curl -# --cookie-jar /tmp/test.cookie-jar -b /tmp/test.cookie-jar --fail \
17+
${2:-} \
18+
-H 'Content-Type: application/x-www-form-urlencoded' \
19+
"$1"
20+
fi
21+
1022
if [ $? -gt 0 ]; then
1123
DID_FAIL=1
1224
echo "ERR: for URL ${1}"
@@ -16,14 +28,14 @@ checkUrl() {
1628

1729
echo "Running tests..."
1830

19-
checkUrl "http://${TEST_ADDR}/"
20-
checkUrl "http://${TEST_ADDR}/.nginx/status"
21-
checkUrl "http://${TEST_ADDR}/.phpfpm/status"
22-
checkUrl "http://${TEST_ADDR}/index.php"
23-
checkUrl "http://${TEST_ADDR}/robots.txt"
31+
checkUrl "http://${TEST_ADDR}/" -I
32+
checkUrl "http://${TEST_ADDR}/.nginx/status" -I
33+
checkUrl "http://${TEST_ADDR}/.phpfpm/status" -I
34+
checkUrl "http://${TEST_ADDR}/index.php" -I
35+
checkUrl "http://${TEST_ADDR}/robots.txt" -I
2436

25-
curl "http://${TEST_ADDR}/index.php" -L
26-
curl "http://${TEST_ADDR}/htdocs/cmd.php?cmd=login_form&server_id=1" -L
37+
checkUrl "http://${TEST_ADDR}/index.php" -L | grep -q -F "1.2.6.4"
38+
checkUrl "http://${TEST_ADDR}/htdocs/cmd.php" "form" "cmd=login&server_id=1&nodecode%5Blogin_pass%5D=1&login=cn%3Dadmin%2Cdc%3Dexample%2Cdc%3Dorg&login_pass=ldapadminpass&submit=Authenticate" | grep -q -F "Successfully logged into server."
2739

2840
if [ $DID_FAIL -gt 0 ]; then
2941
echo "Some URLs failed"

0 commit comments

Comments
 (0)