mirror of
https://github.com/glimpse-app/server.git
synced 2025-04-02 10:52:45 -04:00
unit tests for 3 endpoints
This commit is contained in:
parent
2dc785fb44
commit
168e6592b1
2 changed files with 31 additions and 3 deletions
BIN
tests/test-image.png
Normal file
BIN
tests/test-image.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 201 KiB |
|
@ -30,9 +30,37 @@ ENDPOINT="/api/v1/newUser"
|
|||
|
||||
printf "\n%bTest: $ENDPOINT%b\n" "$BLD" "$CLR"
|
||||
|
||||
curl -s -X POST http://"$BINDADDR":"$PORT""$ENDPOINT" -d "username=testUser"
|
||||
-d "password=$PASSWORD" -d "email=test@example.xyz"
|
||||
curl -X POST http://"$BINDADDR":"$PORT""$ENDPOINT" \
|
||||
-d "username=testUser" -d "password=$PASSWORD" \
|
||||
-d "email=test@example.xyz" | jq -M
|
||||
|
||||
if test $? -eq 0; then printf "%bTest: Success - $ENDPOINT" "$YAY";
|
||||
else printf "%bTest: Fail - $ENDPOINT" "$NAY"; exit 1;
|
||||
else printf "%bTest: Fail - $ENDPOINT" "$NAY";
|
||||
fi; printf "%b\n" "$CLR";
|
||||
|
||||
|
||||
|
||||
ENDPOINT="/api/v1/newSession"
|
||||
printf "\n%bTest: $ENDPOINT%b\n" "$BLD" "$CLR"
|
||||
TOKEN=$(curl -s -X POST http://"$BINDADDR":"$PORT""/api/v1/newUser" -d "username=testUser1" -d "password=$PASSWORD" -d "email=test@example.xyz" | jq -M ".[0].token" | tr -d '"')
|
||||
|
||||
curl -X GET http://"$BINDADDR":"$PORT""$ENDPOINT" \
|
||||
-H "Authorization: $TOKEN" | jq -M
|
||||
|
||||
if test $? -eq 0; then printf "%bTest: Success - $ENDPOINT" "$YAY";
|
||||
else printf "%bTest: Fail - $ENDPOINT" "$NAY";
|
||||
fi; printf "%b\n" "$CLR";
|
||||
|
||||
|
||||
|
||||
ENDPOINT="/api/v1/newFile"
|
||||
printf "\n%bTest: $ENDPOINT%b\n" "$BLD" "$CLR"
|
||||
TOKEN=$(curl -s -X POST http://"$BINDADDR":"$PORT""/api/v1/newUser" -d "username=testUser2" -d "password=$PASSWORD" -d "email=test@example.xyz" | jq -M ".[0].token" | tr -d '"')
|
||||
|
||||
curl -X POST http://"$BINDADDR":"$PORT""$ENDPOINT" \
|
||||
-H "Authorization: $TOKEN" -F "file=@test-image.png"
|
||||
|
||||
if test $? -eq 0; then printf "%bTest: Success - $ENDPOINT" "$YAY";
|
||||
else printf "%bTest: Fail - $ENDPOINT" "$NAY";
|
||||
fi; printf "%b\n" "$CLR";
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue