Add check for http status code in integration tests

Co-authored-by: Reimar <mail@reim.ar>
This commit is contained in:
Alexandertp 2024-08-14 12:39:39 +02:00
parent 21f7a16d98
commit c6f2fc10f1

View File

@ -5,6 +5,13 @@ HTTP_STATUS=`echo -n "$RESPONSE" | tail -n 1`
USER_ID=`echo "$RESPONSE" | head -n -1` USER_ID=`echo "$RESPONSE" | head -n -1`
echo "POST /api/Users - $HTTP_STATUS" echo "POST /api/Users - $HTTP_STATUS"
if [ $HTTP_STATUS -ne 200 ]
then
echo $RESPONSE
exit
fi
echo -e " User ID: $USER_ID\n" echo -e " User ID: $USER_ID\n"
RESPONSE=`curl -sSLX POST http://localhost:5287/api/Users/login -d '{"Email":"hej@example.com","Password":"Gamer123!"}' -H 'Content-Type: application/json' -H 'Accept: */*' -w '\n%{http_code}' --output -` RESPONSE=`curl -sSLX POST http://localhost:5287/api/Users/login -d '{"Email":"hej@example.com","Password":"Gamer123!"}' -H 'Content-Type: application/json' -H 'Accept: */*' -w '\n%{http_code}' --output -`
@ -12,6 +19,13 @@ HTTP_STATUS=`echo -n "$RESPONSE" | tail -n 1`
TOKEN=`echo "$RESPONSE" | head -n -1` TOKEN=`echo "$RESPONSE" | head -n -1`
echo "POST /api/Users/login - $HTTP_STATUS" echo "POST /api/Users/login - $HTTP_STATUS"
if [ $HTTP_STATUS -ne 200 ]
then
echo $RESPONSE
exit
fi
echo -e " Received token: $TOKEN\n" echo -e " Received token: $TOKEN\n"
RESPONSE=`curl -sSL http://localhost:5287/api/Users/$USER_ID -w '\n%{http_code}' -H 'Accept: */*' --output -` RESPONSE=`curl -sSL http://localhost:5287/api/Users/$USER_ID -w '\n%{http_code}' -H 'Accept: */*' --output -`
@ -19,8 +33,23 @@ HTTP_STATUS=`echo -n "$RESPONSE" | tail -n 1`
USER_DATA=`echo "$RESPONSE" | head -n -1` USER_DATA=`echo "$RESPONSE" | head -n -1`
echo "GET /api/Users/$USER_ID - $HTTP_STATUS" echo "GET /api/Users/$USER_ID - $HTTP_STATUS"
if [ $HTTP_STATUS -ne 200 ]
then
echo $RESPONSE
exit
fi
echo -e " User data: $USER_DATA\n" echo -e " User data: $USER_DATA\n"
HTTP_STATUS=`curl -sSLX DELETE http://localhost:5287/api/Users/$USER_ID --location-trusted -w '%{http_code}' -H "Authorization: Bearer $TOKEN" -H 'Accept: */*'` RESPONSE=`curl -sSLX DELETE http://localhost:5287/api/Users/$USER_ID --location-trusted -w '%{http_code}' -H "Authorization: Bearer $TOKEN" -H 'Accept: */*' --output -`
HTTP_STATUS=`echo -n "$RESPONSE" | tail -n 1`
echo "DELETE /api/Users/$USER_ID - $HTTP_STATUS" echo "DELETE /api/Users/$USER_ID - $HTTP_STATUS"
if [ $HTTP_STATUS -ne 200 ]
then
echo $RESPONSE
exit
fi