2024-08-14 10:47:04 +01:00
|
|
|
#!/bin/sh
|
2024-08-14 11:36:05 +01:00
|
|
|
|
2024-08-15 10:03:11 +01:00
|
|
|
RESPONSE=`curl -sSLX POST http://localhost:5287/api/Users -d '{"Email":"hej@example.com","Username":"Gamer","Password":"Gamer123!"}' -H 'Content-Type: application/json' -H 'Accept: */*' -w '\n%{http_code}'`
|
2024-08-14 10:47:04 +01:00
|
|
|
HTTP_STATUS=`echo -n "$RESPONSE" | tail -n 1`
|
|
|
|
USER_ID=`echo "$RESPONSE" | head -n -1`
|
2024-08-14 09:59:53 +01:00
|
|
|
|
2024-08-14 10:47:04 +01:00
|
|
|
echo "POST /api/Users - $HTTP_STATUS"
|
2024-08-14 11:39:39 +01:00
|
|
|
|
|
|
|
if [ $HTTP_STATUS -ne 200 ]
|
|
|
|
then
|
|
|
|
echo $RESPONSE
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2024-08-14 10:47:04 +01:00
|
|
|
echo -e " User ID: $USER_ID\n"
|
2024-08-14 09:59:53 +01:00
|
|
|
|
2024-08-15 10:03:11 +01:00
|
|
|
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}'`
|
2024-08-14 10:47:04 +01:00
|
|
|
HTTP_STATUS=`echo -n "$RESPONSE" | tail -n 1`
|
|
|
|
TOKEN=`echo "$RESPONSE" | head -n -1`
|
2024-08-14 09:59:53 +01:00
|
|
|
|
2024-08-14 10:47:04 +01:00
|
|
|
echo "POST /api/Users/login - $HTTP_STATUS"
|
2024-08-14 11:39:39 +01:00
|
|
|
|
|
|
|
if [ $HTTP_STATUS -ne 200 ]
|
|
|
|
then
|
|
|
|
echo $RESPONSE
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2024-08-14 10:47:04 +01:00
|
|
|
echo -e " Received token: $TOKEN\n"
|
|
|
|
|
2024-08-15 10:03:11 +01:00
|
|
|
RESPONSE=`curl -sSL http://localhost:5287/api/Users/$USER_ID -w '\n%{http_code}' -H 'Accept: */*'`
|
2024-08-14 10:47:04 +01:00
|
|
|
HTTP_STATUS=`echo -n "$RESPONSE" | tail -n 1`
|
|
|
|
USER_DATA=`echo "$RESPONSE" | head -n -1`
|
|
|
|
|
|
|
|
echo "GET /api/Users/$USER_ID - $HTTP_STATUS"
|
2024-08-14 11:39:39 +01:00
|
|
|
|
|
|
|
if [ $HTTP_STATUS -ne 200 ]
|
|
|
|
then
|
|
|
|
echo $RESPONSE
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2024-08-14 10:47:04 +01:00
|
|
|
echo -e " User data: $USER_DATA\n"
|
|
|
|
|
2024-08-15 10:03:11 +01:00
|
|
|
RESPONSE=`curl -sSLX DELETE http://localhost:5287/api/Users/$USER_ID --location-trusted -w '%{http_code}' -H "Authorization: Bearer $TOKEN" -H 'Accept: */*'`
|
2024-08-14 11:39:39 +01:00
|
|
|
HTTP_STATUS=`echo -n "$RESPONSE" | tail -n 1`
|
|
|
|
|
2024-08-14 10:47:04 +01:00
|
|
|
echo "DELETE /api/Users/$USER_ID - $HTTP_STATUS"
|
2024-08-14 09:59:53 +01:00
|
|
|
|
2024-08-14 11:39:39 +01:00
|
|
|
if [ $HTTP_STATUS -ne 200 ]
|
|
|
|
then
|
|
|
|
echo $RESPONSE
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|