This repository has been archived on 2024-11-06. You can view files and clone it, but cannot push or open issues or pull requests.
python-api-server/tests.sh

45 lines
1.2 KiB
Bash
Raw Normal View History

2023-04-13 14:21:20 +02:00
#!/bin/bash
# führe Script nach Fehlern weiter aus
set +e
RED="\e[31m"
GREEN="\e[32m"
ENDCOLOR="\e[0m"
export TOKEN=myuploadtoken
export URL="http://docker10.grote.lan:5040"
mkdir -p tests
echo -e ${GREEN}Test: normaler Upload${ENDCOLOR}
2023-04-13 15:10:52 +02:00
echo content > tests/file
2023-04-13 14:30:18 +02:00
curl -X POST -H "token: $TOKEN" -F "file=@tests/file" $URL/upload | jq
2023-04-13 14:21:20 +02:00
echo -e ${GREEN}Test: leerer Upload${ENDCOLOR}
2023-04-13 14:33:14 +02:00
curl -X POST -H "token: $TOKEN" $URL/upload | jq
2023-04-13 14:21:20 +02:00
echo -e ${GREEN}Test: fehlerhafter Dateiname Upload${ENDCOLOR}
2023-04-13 14:30:18 +02:00
touch ./tests/'hallo\welt.txt'
2023-04-13 14:33:14 +02:00
curl -X POST -H "token: $TOKEN" -F "file=@tests/hallo\welt.txt" $URL/upload | jq
2023-04-13 14:21:20 +02:00
echo -e ${GREEN}Test: List Files${ENDCOLOR}
2023-04-13 14:30:18 +02:00
curl -H "token: $TOKEN" $URL/list | jq
2023-04-13 14:21:20 +02:00
echo -e ${GREEN}Test: download Datei${ENDCOLOR}
wget $URL/download/file -o ./tests/file
2023-04-13 14:30:18 +02:00
ls -lah ./tests/file
2023-04-13 14:21:20 +02:00
echo -e ${GREEN}Test: download nicht vorhandene Datei${ENDCOLOR}
wget $URL/download/file2
echo -e ${GREEN}Test: lösche Datei${ENDCOLOR}
2023-04-13 14:30:18 +02:00
curl -X DELETE -H "token: $TOKEN" $URL/delete/file | jq
2023-04-13 14:21:20 +02:00
echo -e ${GREEN}Test: lösche nicht vorhandene Datei${ENDCOLOR}
2023-04-13 14:30:18 +02:00
curl -X DELETE -H "token: $TOKEN" $URL/delete/file2 | jq
2023-04-13 14:21:20 +02:00
2023-04-14 12:20:04 +02:00
echo -e ${GREEN}Test: check health${ENDCOLOR}
curl $URL/health
2023-04-13 14:21:20 +02:00
rm -rf tests