From e366c3b6e6c1bf198854733710517148e422768d Mon Sep 17 00:00:00 2001 From: array-in-a-matrix Date: Wed, 24 Jul 2024 19:16:32 -0400 Subject: [PATCH] add 1 endpoint --- tests/test_1.sh | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/tests/test_1.sh b/tests/test_1.sh index 4e07f73..e827b5a 100755 --- a/tests/test_1.sh +++ b/tests/test_1.sh @@ -31,7 +31,7 @@ ENDPOINT="/api/v1/newUser" printf "\n%bTest: $ENDPOINT%b\n" "$BLD" "$CLR" -curl -S --fail-early -X POST http://"$BINDADDR":"$PORT""$ENDPOINT" \ +curl --show-error --fail-early --request POST http://"$BINDADDR":"$PORT""$ENDPOINT" \ -d "username=testUser" -d "password=$PASSWORD" \ -d "email=test@example.xyz" @@ -43,9 +43,9 @@ fi; printf "%b\n" "$CLR"; ENDPOINT="/api/v1/newSession" printf "\n%bTest: $ENDPOINT%b\n" "$BLD" "$CLR" -TOKEN=$(curl -S --fail-early -X 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-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 '"') -curl -S --fail-early -X GET http://"$BINDADDR":"$PORT""$ENDPOINT" \ +curl --show-error --fail-early --request GET http://"$BINDADDR":"$PORT""$ENDPOINT" \ -H "Authorization: $TOKEN" if test $? -eq 0; then printf "%bTest: Success - $ENDPOINT" "$YAY"; @@ -56,9 +56,9 @@ fi; printf "%b\n" "$CLR"; ENDPOINT="/api/v1/newFile" printf "\n%bTest: $ENDPOINT%b\n" "$BLD" "$CLR" -TOKEN=$(curl -S --fail-early -X 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-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 '"') -curl -S --fail-early -X POST http://"$BINDADDR":"$PORT""$ENDPOINT" \ +curl --show-error --fail-early --request POST http://"$BINDADDR":"$PORT""$ENDPOINT" \ -H "Authorization: $TOKEN" -F "file=@image.png" if test $? -eq 0; then printf "%bTest: Success - $ENDPOINT" "$YAY"; @@ -66,4 +66,17 @@ else printf "%bTest: Fail - $ENDPOINT" "$NAY"; ((ERROR++)); 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" \ + -H "Authorization: $TOKEN" -H "Old name: image.png" -H "New name: kitty.png" + +if test $? -eq 0; then printf "%bTest: Success - $ENDPOINT" "$YAY"; +else printf "%bTest: Fail - $ENDPOINT" "$NAY"; ((ERROR++)); +fi; printf "%b\n" "$CLR"; + + + exit $ERROR; \ No newline at end of file