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 7s
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Meson (push) Failing after 8s
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 7s
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Meson (push) Failing after 8s
This commit is contained in:
1 parent
a7aa7392bc
commit
ca3af011a3
1 file changed
+133
-31
@@ -13,9 +13,13 @@ sleep 0.1
|
||||
success=0
|
||||
errors=0
|
||||
|
||||
# test /api/token
|
||||
# test POST /api/token
|
||||
printf "==> ${BLUE}Testing${CYAN} POST${BWHITE} /api/token${RESET} "
|
||||
curl --silent -X POST -d '{"username":"tola","password":"2808"}' localhost:8222/api/token &> api_token_test.log
|
||||
curl \
|
||||
--silent \
|
||||
-X POST \
|
||||
-d '{"username":"tola","password":"2808"}' \
|
||||
localhost:8222/api/token &> api_token_test.log
|
||||
sleep 0.1
|
||||
res=$(cat api_token_test.log)
|
||||
if [[ "$res" == *"token"* ]]; then
|
||||
@@ -26,9 +30,30 @@ else
|
||||
errors=$(($errors+1))
|
||||
fi
|
||||
|
||||
# test /api/token/verify
|
||||
# test POST /api/token with wrong data
|
||||
printf "==> ${BLUE}Testing${CYAN} POST${BWHITE} /api/token with wrong data${RESET} "
|
||||
curl \
|
||||
--silent \
|
||||
-X POST \
|
||||
-d '{"username":"tola","password":"2808"}' \
|
||||
localhost:8222/api/token &> api_token_test.log
|
||||
sleep 0.1
|
||||
res=$(cat api_token_test.log)
|
||||
if [[ "$res" == *"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
|
||||
printf "==> ${BLUE}Testing${CYAN} POST${BWHITE} /api/token/verify${RESET} "
|
||||
curl --silent -X POST -d '{"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IDEsInVzZXJuYW1lIjogInRvbGEiLCJlbWFpbCI6ICJtYWlsQGV4YW1wbGUuY29tIiwiZ3JvdXAiOiAicm9vdCIsImlzX3N1cGVydXNlciI6IHRydWV9.QGUnCWPmp5hWAtGFTGDMw2SugZqLsYfMboeFU4UQLXQ"}' localhost:8222/api/token/verify &> api_token_verify_test.log
|
||||
curl \
|
||||
--silent \
|
||||
-X POST \
|
||||
-d $(cat api_token_test.log) \
|
||||
localhost:8222/api/token/verify &> api_token_verify_test.log
|
||||
sleep 0.1
|
||||
res=$(cat api_token_verify_test.log)
|
||||
if [[ "$res" == *'{"valid":"true"}'* ]]; then
|
||||
@@ -39,9 +64,13 @@ else
|
||||
errors=$(($errors+1))
|
||||
fi
|
||||
|
||||
# test /api/users
|
||||
# test POST /api/users
|
||||
printf "==> ${BLUE}Testing${CYAN} POST${BWHITE} /api/users${RESET} "
|
||||
curl --silent -X POST -d '{"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IDEsInVzZXJuYW1lIjogInRvbGEiLCJlbWFpbCI6ICJtYWlsQGV4YW1wbGUuY29tIiwiZ3JvdXAiOiAicm9vdCIsImlzX3N1cGVydXNlciI6IHRydWV9.QGUnCWPmp5hWAtGFTGDMw2SugZqLsYfMboeFU4UQLXQ"}' localhost:8222/api/users &> api_users_test.log
|
||||
curl \
|
||||
--silent \
|
||||
-X POST \
|
||||
-d $(cat api_token_test.log) \
|
||||
localhost:8222/api/users &> api_users_test.log
|
||||
sleep 0.1
|
||||
res=$(cat api_users_test.log)
|
||||
if [[ "$res" == *'username'* ]]; then
|
||||
@@ -52,9 +81,13 @@ else
|
||||
errors=$(($errors+1))
|
||||
fi
|
||||
|
||||
# test /api/users/user
|
||||
# test POST /api/users/user
|
||||
printf "==> ${BLUE}Testing${CYAN} POST${BWHITE} /api/users/user${RESET} "
|
||||
curl --silent -X POST -d '{"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IDEsInVzZXJuYW1lIjogInRvbGEiLCJlbWFpbCI6ICJtYWlsQGV4YW1wbGUuY29tIiwiZ3JvdXAiOiAicm9vdCIsImlzX3N1cGVydXNlciI6IHRydWV9.QGUnCWPmp5hWAtGFTGDMw2SugZqLsYfMboeFU4UQLXQ"}' localhost:8222/api/users/user &> api_users_user_test.log
|
||||
curl \
|
||||
--silent \
|
||||
-X POST \
|
||||
-d $(cat api_token_test.log) \
|
||||
localhost:8222/api/users/user &> api_users_user_test.log
|
||||
sleep 0.1
|
||||
res=$(cat api_users_user_test.log)
|
||||
if [[ "$res" == *'username'* ]]; then
|
||||
@@ -65,35 +98,20 @@ else
|
||||
errors=$(($errors+1))
|
||||
fi
|
||||
|
||||
# test /api/register
|
||||
printf "==> ${BLUE}Testing${CYAN} POST${BWHITE} /api/register${RESET} "
|
||||
curl --silent -X POST -d '{
|
||||
"username":"asdf",
|
||||
"email":"asdf@asdf.com",
|
||||
"password":"asdf",
|
||||
"group":"users",
|
||||
"is_superuser":false
|
||||
}' localhost:8222/api/register &> api_register_test.log
|
||||
sleep 0.1
|
||||
res=$(cat api_register_test.log)
|
||||
if [[ "$res" == *'username'* ]]; 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 /api/users/add
|
||||
# test POST /api/users/add
|
||||
printf "==> ${BLUE}Testing${CYAN} POST${BWHITE} /api/users/add${RESET} "
|
||||
curl --silent -X POST -d '{
|
||||
curl \
|
||||
--silent \
|
||||
-X POST \
|
||||
-d '{
|
||||
"username":"asdff",
|
||||
"email":"asdf@asdff.com",
|
||||
"password":"asdf",
|
||||
"group":"users",
|
||||
"is_superuser":false,
|
||||
"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IDEsInVzZXJuYW1lIjogInRvbGEiLCJlbWFpbCI6ICJtYWlsQGV4YW1wbGUuY29tIiwiZ3JvdXAiOiAicm9vdCIsImlzX3N1cGVydXNlciI6IHRydWV9.QGUnCWPmp5hWAtGFTGDMw2SugZqLsYfMboeFU4UQLXQ"
|
||||
}' localhost:8222/api/users/add &> api_users_add_test.log
|
||||
}' \
|
||||
localhost:8222/api/users/add &> api_users_add_test.log
|
||||
sleep 0.1
|
||||
res=$(cat api_users_add_test.log)
|
||||
if [[ "$res" == *'username'* ]]; then
|
||||
@@ -104,7 +122,91 @@ else
|
||||
errors=$(($errors+1))
|
||||
fi
|
||||
|
||||
# test
|
||||
# test DELETE /api/users
|
||||
printf "==> ${BLUE}Testing${RED} DELETE${BWHITE} /api/users${RESET} "
|
||||
reqdata=$(curl \
|
||||
--silent \
|
||||
-X POST \
|
||||
-d '{"username":"asdff","password":"asdf"}' \
|
||||
localhost:8222/api/token)
|
||||
curl \
|
||||
--silent \
|
||||
-X DELETE \
|
||||
-d $reqdata \
|
||||
localhost:8222/api/users &> delete_api_users_test.log
|
||||
sleep 0.1
|
||||
res=$(cat delete_api_users_test.log)
|
||||
if [[ "$res" == *'{"success": true}'* ]]; 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/password
|
||||
printf "==> ${BLUE}Testing${CYAN} POST${BWHITE} /api/users/password${RESET} "
|
||||
reqtoken=$(cat api_token_test.log | sed -e "s/{//g" | sed -e "s/}//g")
|
||||
curl \
|
||||
--silent \
|
||||
-X POST \
|
||||
-d "{\"old_password\":\"2808\",\"new_password\":\"1234\",$reqtoken}" \
|
||||
localhost:8222/api/users/password &> api_users_password_test.log
|
||||
sleep 0.1
|
||||
res=$(cat api_users_password_test.log)
|
||||
if [[ "$res" == *'{"success": true}'* ]]; 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 PUT /api/users
|
||||
printf "==> ${BLUE}Testing${YELLOW} PUT${BWHITE} /api/users${RESET} "
|
||||
reqtoken=$(cat api_token_test.log | sed -e "s/{//g" | sed -e "s/}//g")
|
||||
curl \
|
||||
--silent \
|
||||
-X PUT \
|
||||
-d "{
|
||||
\"username\":\"tola\",
|
||||
\"email\":\"tola@tola.tola\",
|
||||
\"group\":\"admin\",
|
||||
\"is_superuser\":true,
|
||||
$reqtoken}" \
|
||||
localhost:8222/api/users &> put_api_users_test.log
|
||||
sleep 0.1
|
||||
res=$(cat put_api_users_test.log)
|
||||
if [[ "$res" == *'username'* ]]; 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/register
|
||||
printf "==> ${BLUE}Testing${CYAN} POST${BWHITE} /api/register${RESET} "
|
||||
curl \
|
||||
--silent \
|
||||
-X POST \
|
||||
-d '{
|
||||
"username":"asdf",
|
||||
"email":"asdf@asdf.com",
|
||||
"password":"asdf",
|
||||
"group":"users",
|
||||
"is_superuser":false
|
||||
}' \
|
||||
localhost:8222/api/register &> api_register_test.log
|
||||
sleep 0.1
|
||||
res=$(cat api_register_test.log)
|
||||
if [[ "$res" == *'username'* ]]; 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
|
||||
|
||||
killall auth_service
|
||||
printf "==> ${GREEN}Success: ${RESET}${success}\n==>${RED} Errors: ${RESET}${errors}\n"
|
||||
|
||||
Reference in new issue
Block a user