add tests

This commit is contained in:
gitGnome
2026-04-01 10:58:07 +02:00
parent 055bc5dcf2
commit 75c23c151f
7 changed files with 157 additions and 4 deletions
+52
View File
@@ -0,0 +1,52 @@
#!/bin/bash
# Get groups for both users
source "$(dirname "$0")/config.sh"
TOKEN1=$(load_state "TOKEN1")
TOKEN2=$(load_state "TOKEN2")
if [[ -z "$TOKEN1" || -z "$TOKEN2" ]]; then
echo "ERROR: Missing tokens. Run 02_login.sh first."
exit 1
fi
echo "=== Getting groups for user1 ==="
RESP=$(curl -s -w "\n%{http_code}" -X POST "$BASE_URL/get/groups" \
-d "token=$TOKEN1")
BODY=$(echo "$RESP" | head -1)
CODE=$(echo "$RESP" | tail -1)
echo "Response: $BODY (HTTP $CODE)"
if [[ "$CODE" != "202" ]]; then
echo "FAIL: Expected HTTP 202, got $CODE"
exit 1
fi
echo ""
echo "=== Getting groups for user2 ==="
RESP=$(curl -s -w "\n%{http_code}" -X POST "$BASE_URL/get/groups" \
-d "token=$TOKEN2")
BODY=$(echo "$RESP" | head -1)
CODE=$(echo "$RESP" | tail -1)
echo "Response: $BODY (HTTP $CODE)"
if [[ "$CODE" != "202" ]]; then
echo "FAIL: Expected HTTP 202, got $CODE"
exit 1
fi
echo ""
echo "=== Getting groups with invalid token ==="
RESP=$(curl -s -w "\n%{http_code}" -X POST "$BASE_URL/get/groups" \
-d "token=invalid_token")
BODY=$(echo "$RESP" | head -1)
CODE=$(echo "$RESP" | tail -1)
echo "Response: $BODY (HTTP $CODE)"
if [[ "$CODE" != "401" ]]; then
echo "FAIL: Expected HTTP 401, got $CODE"
exit 1
fi
echo ""
echo "ALL PASSED"