updated tests
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Make (push) Failing after 10s
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-CMake (push) Failing after 8s
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Meson (push) Failing after 8s

This commit is contained in:
wt committed 2025-08-26 11:37:38 +07:00
1 parent ca3af011a3
commit 86739af751
1 file changed
+108 -6
+108 -6
View File
@@ -30,16 +30,67 @@ else
errors=$(($errors+1))
fi
# test POST /api/token with wrong data
printf "==> ${BLUE}Testing${CYAN} POST${BWHITE} /api/token with wrong data${RESET} "
# test POST /api/token with wrong password
printf "==> ${BLUE}Testing${CYAN} POST${BWHITE} /api/token with wrong password${RESET} "
curl \
--silent \
-X POST \
-d '{"username":"tola","password":"2808"}' \
localhost:8222/api/token &> api_token_test.log
-d '{"username":"tola","password":"288"}' \
localhost:8222/api/token &> api_token_wrong_password_test.log
sleep 0.1
res=$(cat api_token_test.log)
if [[ "$res" == *"token"* ]]; then
res=$(cat api_token_wrong_password_test.log)
if [[ "$res" == *"{\"error\":\"wrong password\"}"* ]]; then
printf "[$GREEN OK $RESET]\n"
success=$(($success+1))
else
printf "[$RED ERR $RESET]\n==> ${BLUE}Response: $RESET$(echo $res)\n"
errors=$(($errors+1))
fi
# test POST /api/token with wrong username
printf "==> ${BLUE}Testing${CYAN} POST${BWHITE} /api/token with wrong username${RESET} "
curl \
--silent \
-X POST \
-d '{"username":"toa","password":"2808"}' \
localhost:8222/api/token &> api_token_wrong_username_test.log
sleep 0.1
res=$(cat api_token_wrong_username_test.log)
if [[ "$res" == *"{\"error\":\"couldn't find user\"}"* ]]; then
printf "[$GREEN OK $RESET]\n"
success=$(($success+1))
else
printf "[$RED ERR $RESET]\n==> ${BLUE}Response: $RESET$(echo $res)\n"
errors=$(($errors+1))
fi
# test POST /api/token without post data
printf "==> ${BLUE}Testing${CYAN} POST${BWHITE} /api/token without post data${RESET} "
curl \
--silent \
-X POST \
-d '' \
localhost:8222/api/token &> api_token_no_data_test.log
sleep 0.1
res=$(cat api_token_no_data_test.log)
if [[ "$res" == *"{\"error\":\"must have username and password\"}"* ]]; then
printf "[$GREEN OK $RESET]\n"
success=$(($success+1))
else
printf "[$RED ERR $RESET]\n==> ${BLUE}Response: $RESET$(echo $res)\n"
errors=$(($errors+1))
fi
# test POST /api/token with not valid json
printf "==> ${BLUE}Testing${CYAN} POST${BWHITE} /api/token with not valid json${RESET} "
curl \
--silent \
-X POST \
-d '{{asdf}}}asdfasdfasdf""asdf' \
localhost:8222/api/token &> api_token_not_valid_json_test.log
sleep 0.1
res=$(cat api_token_not_valid_json_test.log)
if [[ "$res" == *"error"* ]]; then
printf "[$GREEN OK $RESET]\n"
success=$(($success+1))
else
@@ -64,6 +115,57 @@ else
errors=$(($errors+1))
fi
# test POST /api/token/verify without post data
printf "==> ${BLUE}Testing${CYAN} POST${BWHITE} /api/token/verify without post data${RESET} "
curl \
--silent \
-X POST \
-d '' \
localhost:8222/api/token/verify &> api_token_verify_no_data_test.log
sleep 0.1
res=$(cat api_token_verify_no_data_test.log)
if [[ "$res" == *'{"error":"must have token"}'* ]]; then
printf "[$GREEN OK $RESET]\n"
success=$(($success+1))
else
printf "[$RED ERR $RESET]\n==> ${BLUE}Response: $RESET$(echo $res)\n"
errors=$(($errors+1))
fi
# test POST /api/token/verify with wrong token
printf "==> ${BLUE}Testing${CYAN} POST${BWHITE} /api/token/verify with wrong token${RESET} "
curl \
--silent \
-X POST \
-d '{"token":"asdf"}' \
localhost:8222/api/token/verify &> api_token_verify_wrong_token_test.log
sleep 0.1
res=$(cat api_token_verify_wrong_token_test.log)
if [[ "$res" == *'{"error":"invalid token"}'* ]]; then
printf "[$GREEN OK $RESET]\n"
success=$(($success+1))
else
printf "[$RED ERR $RESET]\n==> ${BLUE}Response: $RESET$(echo $res)\n"
errors=$(($errors+1))
fi
# test POST /api/token/verify with wrong json
printf "==> ${BLUE}Testing${CYAN} POST${BWHITE} /api/token/verify with wrong json${RESET} "
curl \
--silent \
-X POST \
-d 'asdf[apsdfqopwjf[9qfm93qq89n]]' \
localhost:8222/api/token/verify &> api_token_verify_wrong_json_test.log
sleep 0.1
res=$(cat api_token_verify_wrong_json_test.log)
if [[ "$res" == *'error'* ]]; then
printf "[$GREEN OK $RESET]\n"
success=$(($success+1))
else
printf "[$RED ERR $RESET]\n==> ${BLUE}Response: $RESET$(echo $res)\n"
errors=$(($errors+1))
fi
# test POST /api/users
printf "==> ${BLUE}Testing${CYAN} POST${BWHITE} /api/users${RESET} "
curl \