69 lines
1.5 KiB
Bash
Executable File
69 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
#######################################
|
|
#
|
|
# A simple curl test on a deployed app
|
|
#
|
|
#######################################
|
|
|
|
URL=${SIMPLE_AUTH_URL}
|
|
if [ -z ${URL} ]
|
|
then
|
|
echo "[WARN]: SIMPLE_AUTH_URL is empty, set to http://localhost:5555"
|
|
URL="http://localhost:5555"
|
|
fi
|
|
|
|
for i in {0..10}
|
|
do
|
|
http_response=$(curl -s -o response.txt -w "%{http_code}" ${URL}/get/ -d '{"username":"toto", "password":"tutu"}')
|
|
if [ $http_response != "400" ]
|
|
then
|
|
echo "bad http status code : ${http_response}, expect 400"
|
|
exit 1
|
|
fi
|
|
|
|
if [ "$(cat response.txt | jq -r '.error')" != "bad request" ]
|
|
then
|
|
echo "bad data returned, expect : bad request"
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
for i in {0..10}
|
|
do
|
|
http_response=$(curl -s -o response.txt -w "%{http_code}" ${URL}/get/ -d '{"email":"toto", "password":"tutu"}')
|
|
if [ $http_response != "403" ]
|
|
then
|
|
echo "bad http status code : ${http_response}, expect 403"
|
|
exit 1
|
|
fi
|
|
|
|
if [ "$(cat response.txt | jq -r '.error')" != "url forbidden" ]
|
|
then
|
|
echo "bad data returned, expect : url forbidden"
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
|
|
for i in {0..10}
|
|
do
|
|
http_response=$(curl -s -o response.txt -w "%{http_code}" ${URL}/ge/ -d '{"username":"toto", "password":"tutu"}')
|
|
if [ $http_response != "404" ]
|
|
then
|
|
echo "bad http status code : ${http_response}, expect 404"
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
|
|
for i in {0..10}
|
|
do
|
|
http_response=$(curl -s -o response.txt -w "%{http_code}" ${URL}/pubkey/)
|
|
if [ $http_response != "200" ]
|
|
then
|
|
echo "bad http status code : ${http_response}, expect 200"
|
|
exit 1
|
|
fi
|
|
done
|