fail when >=400

This commit is contained in:
array-in-a-matrix 2024-08-01 19:58:40 -04:00
parent a218c85635
commit 78b12d7626

View file

@ -35,7 +35,7 @@ ENDPOINT="/api/v1/newUser"
printf "\n%bTest: $ENDPOINT%b\n" "$BLD" "$CLR"
curl --show-error --fail-early --request POST http://"$BINDADDR":"$PORT""$ENDPOINT" \
curl --show-error --fail-with-body --request POST http://"$BINDADDR":"$PORT""$ENDPOINT" \
-d "username=testUser" -d "password=$PASSWORD" \
-d "email=test@example.xyz"
@ -47,9 +47,9 @@ fi; printf "%b\n" "$CLR";
ENDPOINT="/api/v1/newSession"
printf "\n%bTest: $ENDPOINT%b\n" "$BLD" "$CLR"
TOKEN=$(curl --show-error --fail-early --request POST http://"$BINDADDR":"$PORT""/api/v1/newUser" -d "username=testUser1" -d "password=$PASSWORD" -d "email=test@example.xyz" | jq ".[0].token" | tr -d '"')
TOKEN=$(curl --show-error --fail-with-body --request POST http://"$BINDADDR":"$PORT""/api/v1/newUser" -d "username=testUser1" -d "password=$PASSWORD" -d "email=test@example.xyz" | jq ".[0].token" | tr -d '"')
curl --show-error --fail-early --request GET http://"$BINDADDR":"$PORT""$ENDPOINT" \
curl --show-error --fail-with-body --request GET http://"$BINDADDR":"$PORT""$ENDPOINT" \
-H "Authorization: $TOKEN"
if test $? -eq 0; then printf "%bTest: Success - $ENDPOINT" "$YAY";
@ -60,9 +60,9 @@ fi; printf "%b\n" "$CLR";
ENDPOINT="/api/v1/newFile"
printf "\n%bTest: $ENDPOINT%b\n" "$BLD" "$CLR"
TOKEN=$(curl --show-error --fail-early --request POST http://"$BINDADDR":"$PORT""/api/v1/newUser" -d "username=testUser2" -d "password=$PASSWORD" -d "email=test@example.xyz" | jq ".[0].token" | tr -d '"')
TOKEN=$(curl --show-error --fail-with-body --request POST http://"$BINDADDR":"$PORT""/api/v1/newUser" -d "username=testUser2" -d "password=$PASSWORD" -d "email=test@example.xyz" | jq ".[0].token" | tr -d '"')
curl --show-error --fail-early --request POST http://"$BINDADDR":"$PORT""$ENDPOINT" \
curl --show-error --fail-with-body --request POST http://"$BINDADDR":"$PORT""$ENDPOINT" \
-H "Authorization: $TOKEN" -F "file=@image.png"
if test $? -eq 0; then printf "%bTest: Success - $ENDPOINT" "$YAY";
@ -72,9 +72,9 @@ fi; printf "%b\n" "$CLR";
printf "\n%bTest: $ENDPOINT%b\n" "$BLD" "$CLR"
TOKEN=$(curl --show-error --fail-early --request POST http://"$BINDADDR":"$PORT""/api/v1/newUser" -d "username=testUser2" -d "password=$PASSWORD" -d "email=test@example.xyz" | jq ".[0].token" | tr -d '"')
TOKEN=$(curl --show-error --fail-with-body --request POST http://"$BINDADDR":"$PORT""/api/v1/newUser" -d "username=testUser2" -d "password=$PASSWORD" -d "email=test@example.xyz" | jq ".[0].token" | tr -d '"')
curl --show-error --fail-early --request POST http://"$BINDADDR":"$PORT""$ENDPOINT" \
curl --show-error --fail-with-body --request POST http://"$BINDADDR":"$PORT""$ENDPOINT" \
-H "Authorization: $TOKEN" -F "file=@image2.jpg" -F 'tags=["4k HDR", "Fruit", "Yummy"]'
if test $? -eq 0; then printf "%bTest: Success - $ENDPOINT 2" "$YAY";
@ -86,7 +86,7 @@ fi; printf "%b\n" "$CLR";
ENDPOINT="/api/v1/newFileName"
printf "\n%bTest: $ENDPOINT%b\n" "$BLD" "$CLR"
curl --show-error --fail-early --request PUT http://"$BINDADDR":"$PORT""$ENDPOINT" \
curl --show-error --fail-with-body --request PUT http://"$BINDADDR":"$PORT""$ENDPOINT" \
-H "Authorization: $TOKEN" -H "Old name: image.png" -H "New name: kitty.png"
if test $? -eq 0; then printf "%bTest: Success - $ENDPOINT" "$YAY";
@ -98,7 +98,7 @@ fi; printf "%b\n" "$CLR";
ENDPOINT="/api/v1/fileByName"
printf "\n%bTest: $ENDPOINT%b\n" "$BLD" "$CLR"
curl --show-error --fail-early --request GET http://"$BINDADDR":"$PORT""$ENDPOINT" \
curl --show-error --fail-with-body --request GET http://"$BINDADDR":"$PORT""$ENDPOINT" \
-H "Authorization: $TOKEN" -H "Name: kitty.png" --output downloaded.png
if test $? -eq 0; then printf "%bTest: Success - $ENDPOINT" "$YAY";
@ -111,7 +111,7 @@ rm downloaded.png
ENDPOINT="/api/v1/listOfAllFiles"
printf "\n%bTest: $ENDPOINT%b\n" "$BLD" "$CLR"
curl --show-error --fail-early --request GET http://"$BINDADDR":"$PORT""$ENDPOINT" \
curl --show-error --fail-with-body --request GET http://"$BINDADDR":"$PORT""$ENDPOINT" \
-H "Authorization: $TOKEN"
if test $? -eq 0; then printf "%bTest: Success - $ENDPOINT" "$YAY";
@ -123,7 +123,7 @@ fi; printf "%b\n" "$CLR";
# ENDPOINT="/api/v1/file"
# printf "\n%bTest: $ENDPOINT%b\n" "$BLD" "$CLR"
# curl --show-error --fail-early --request DELETE http://"$BINDADDR":"$PORT""$ENDPOINT" \
# curl --show-error --fail-with-body --request DELETE http://"$BINDADDR":"$PORT""$ENDPOINT" \
# -H "Authorization: $TOKEN" -H "Name: image2.jpg"
# if test $? -eq 0; then printf "%bTest: Success - $ENDPOINT" "$YAY";
@ -135,7 +135,7 @@ fi; printf "%b\n" "$CLR";
ENDPOINT="/api/v1/files"
printf "\n%bTest: $ENDPOINT%b\n" "$BLD" "$CLR"
curl --show-error --fail-early --request DELETE http://"$BINDADDR":"$PORT""$ENDPOINT" \
curl --show-error --fail-with-body --request DELETE http://"$BINDADDR":"$PORT""$ENDPOINT" \
-H "Authorization: $TOKEN"
if test $? -eq 0; then printf "%bTest: Success - $ENDPOINT" "$YAY";
@ -147,7 +147,7 @@ fi; printf "%b\n" "$CLR";
ENDPOINT="/api/v1/user"
printf "\n%bTest: $ENDPOINT%b\n" "$BLD" "$CLR"
curl --show-error --fail-early --request DELETE http://"$BINDADDR":"$PORT""$ENDPOINT" \
curl --show-error --fail-with-body --request DELETE http://"$BINDADDR":"$PORT""$ENDPOINT" \
-H "Authorization: $TOKEN"
if test $? -eq 0; then printf "%bTest: Success - $ENDPOINT" "$YAY";
@ -159,7 +159,7 @@ fi; printf "%b\n" "$CLR";
ENDPOINT="/api/v1/userCompletely"
printf "\n%bTest: $ENDPOINT%b\n" "$BLD" "$CLR"
curl --show-error --fail-early --request DELETE http://"$BINDADDR":"$PORT""$ENDPOINT" \
curl --show-error --fail-with-body --request DELETE http://"$BINDADDR":"$PORT""$ENDPOINT" \
-H "Authorization: $TOKEN"
if test $? -eq 0; then printf "%bTest: Success - $ENDPOINT" "$YAY";