[TEST] Add MVP endpoints test script and update ISSUE-003 status
- Created test_mvp_endpoints.sh to test all protected endpoints after backend restart - Updated ISSUE-003 status to 'pending_test' (ready to test with valid token) - Note: Backend must be restarted for ISSUE-001/002 fixes to take effect
This commit is contained in:
parent
8ab65c43b1
commit
ec202b2064
2 changed files with 188 additions and 8 deletions
|
|
@ -182,24 +182,25 @@
|
||||||
"title": "Créer un track nécessite une authentification",
|
"title": "Créer un track nécessite une authentification",
|
||||||
"priority": "P1",
|
"priority": "P1",
|
||||||
"priority_rank": 3,
|
"priority_rank": 3,
|
||||||
"status": "open",
|
"status": "pending_test",
|
||||||
"blocking": false,
|
"blocking": false,
|
||||||
"endpoint": "POST /api/v1/tracks",
|
"endpoint": "POST /api/v1/tracks",
|
||||||
"test_command": "curl -X POST 'http://localhost:8080/api/v1/tracks' -H 'Content-Type: application/json' -d '{\"title\":\"Test Track\",\"genre\":\"Electronic\"}'",
|
"test_command": "curl -X POST 'http://localhost:8080/api/v1/tracks' -H 'Authorization: Bearer $TOKEN' -H 'Content-Type: application/json' -d '{\"title\":\"Test Track\",\"genre\":\"Electronic\"}'",
|
||||||
"expected_result": "HTTP 201 avec track créé OU HTTP 401 si comportement attendu",
|
"expected_result": "HTTP 201 avec track créé",
|
||||||
"actual_result": "HTTP 401 - Authorization header required",
|
"actual_result": "HTTP 401 - Authorization header required (testé sans token)",
|
||||||
"error_message": "Authorization header required",
|
"error_message": "Authorization header required",
|
||||||
"error_code": 1000,
|
"error_code": 1000,
|
||||||
"http_code": 401,
|
"http_code": 401,
|
||||||
"user_impact": "Impossible de créer un track sans être authentifié (comportement attendu, mais bloque les tests car login échoue).",
|
"user_impact": "Endpoint protégé - comportement normal. Nécessite un token valide pour fonctionner.",
|
||||||
"tested_at": "2025-12-26T15:18:33Z",
|
"tested_at": "2025-12-26T15:18:33Z",
|
||||||
"root_cause": "Endpoint protégé, nécessite authentification. Ne peut pas être testé car login échoue (ISSUE-001)",
|
"root_cause": "Endpoint protégé, nécessite authentification. Prêt à être testé avec token valide après redémarrage backend.",
|
||||||
"fix_suggestion": "Une fois ISSUE-001 et ISSUE-002 fixés, réexécuter ce test avec un token valide",
|
"fix_suggestion": "Tester avec token valide après redémarrage backend. Script de test créé: test_mvp_endpoints.sh",
|
||||||
"files_to_check": [
|
"files_to_check": [
|
||||||
"veza-backend-api/internal/handlers/track_handlers.go"
|
"veza-backend-api/internal/handlers/track_handlers.go"
|
||||||
],
|
],
|
||||||
"estimated_hours": 0.5,
|
"estimated_hours": 0.5,
|
||||||
"depends_on": ["ISSUE-001", "ISSUE-002"]
|
"depends_on": ["ISSUE-001", "ISSUE-002"],
|
||||||
|
"note": "Corrections ISSUE-001 et ISSUE-002 faites. Backend doit être redémarré pour tester."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "ISSUE-004",
|
"id": "ISSUE-004",
|
||||||
|
|
|
||||||
179
test_mvp_endpoints.sh
Executable file
179
test_mvp_endpoints.sh
Executable file
|
|
@ -0,0 +1,179 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Script de test MVP - À exécuter après redémarrage du backend
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "=== MVP ENDPOINTS TEST ==="
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# 1. Register
|
||||||
|
TIMESTAMP=$(date +%s)
|
||||||
|
echo "1. Testing Register..."
|
||||||
|
REGISTER=$(curl -s -X POST "http://localhost:8080/api/v1/auth/register" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{\"email\":\"mvp${TIMESTAMP}@test.com\",\"username\":\"mvp${TIMESTAMP}\",\"password\":\"Test123!Password\",\"password_confirm\":\"Test123!Password\"}")
|
||||||
|
|
||||||
|
HTTP_CODE=$(echo "$REGISTER" | jq -r '.success // false')
|
||||||
|
TOKEN=$(echo "$REGISTER" | jq -r '.data.token.access_token // .data.access_token // .access_token // empty')
|
||||||
|
|
||||||
|
if [ "$HTTP_CODE" = "true" ] && [ -n "$TOKEN" ] && [ "$TOKEN" != "null" ] && [ "$TOKEN" != "" ]; then
|
||||||
|
echo "✅ Register: Token reçu"
|
||||||
|
ACCESS_TOKEN="$TOKEN"
|
||||||
|
else
|
||||||
|
echo "❌ Register: Échec"
|
||||||
|
echo "$REGISTER" | jq .
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 2. Login
|
||||||
|
echo ""
|
||||||
|
echo "2. Testing Login..."
|
||||||
|
LOGIN=$(curl -s -X POST "http://localhost:8080/api/v1/auth/login" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{\"email\":\"mvp${TIMESTAMP}@test.com\",\"password\":\"Test123!Password\"}")
|
||||||
|
|
||||||
|
LOGIN_HTTP=$(echo "$LOGIN" | jq -r '.success // false')
|
||||||
|
LOGIN_TOKEN=$(echo "$LOGIN" | jq -r '.data.token.access_token // .data.access_token // .access_token // empty')
|
||||||
|
|
||||||
|
if [ "$LOGIN_HTTP" = "true" ] && [ -n "$LOGIN_TOKEN" ] && [ "$LOGIN_TOKEN" != "null" ]; then
|
||||||
|
echo "✅ Login: OK"
|
||||||
|
ACCESS_TOKEN="$LOGIN_TOKEN"
|
||||||
|
else
|
||||||
|
echo "❌ Login: Échec"
|
||||||
|
echo "$LOGIN" | jq .
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 3. Get Me
|
||||||
|
echo ""
|
||||||
|
echo "3. Testing Get Me..."
|
||||||
|
ME=$(curl -s -X GET "http://localhost:8080/api/v1/auth/me" \
|
||||||
|
-H "Authorization: Bearer $ACCESS_TOKEN")
|
||||||
|
|
||||||
|
ME_SUCCESS=$(echo "$ME" | jq -r '.success // false')
|
||||||
|
if [ "$ME_SUCCESS" = "true" ]; then
|
||||||
|
echo "✅ Get Me: OK"
|
||||||
|
else
|
||||||
|
echo "❌ Get Me: Échec"
|
||||||
|
echo "$ME" | jq .
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 4. Create Track (ISSUE-003)
|
||||||
|
echo ""
|
||||||
|
echo "4. Testing Create Track (ISSUE-003)..."
|
||||||
|
TRACK=$(curl -s -w "\nHTTP_CODE:%{http_code}" -X POST "http://localhost:8080/api/v1/tracks" \
|
||||||
|
-H "Authorization: Bearer $ACCESS_TOKEN" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{"title":"MVP Test Track","genre":"Electronic","artist":"Test Artist"}')
|
||||||
|
|
||||||
|
HTTP_CODE=$(echo "$TRACK" | grep "HTTP_CODE" | cut -d: -f2)
|
||||||
|
TRACK_BODY=$(echo "$TRACK" | grep -v "HTTP_CODE")
|
||||||
|
TRACK_SUCCESS=$(echo "$TRACK_BODY" | jq -r '.success // false')
|
||||||
|
|
||||||
|
if [ "$HTTP_CODE" = "201" ] || [ "$HTTP_CODE" = "200" ]; then
|
||||||
|
if [ "$TRACK_SUCCESS" = "true" ]; then
|
||||||
|
echo "✅ Create Track: OK"
|
||||||
|
TRACK_ID=$(echo "$TRACK_BODY" | jq -r '.data.track.id // .data.id // empty')
|
||||||
|
echo " Track ID: $TRACK_ID"
|
||||||
|
else
|
||||||
|
echo "⚠️ Create Track: HTTP $HTTP_CODE mais success=false"
|
||||||
|
echo "$TRACK_BODY" | jq .
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "❌ Create Track: Échec (HTTP $HTTP_CODE)"
|
||||||
|
echo "$TRACK_BODY" | jq .
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 5. Create Playlist (ISSUE-005)
|
||||||
|
echo ""
|
||||||
|
echo "5. Testing Create Playlist (ISSUE-005)..."
|
||||||
|
PLAYLIST=$(curl -s -w "\nHTTP_CODE:%{http_code}" -X POST "http://localhost:8080/api/v1/playlists" \
|
||||||
|
-H "Authorization: Bearer $ACCESS_TOKEN" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{"name":"MVP Test Playlist","description":"Test","visibility":"private"}')
|
||||||
|
|
||||||
|
HTTP_CODE=$(echo "$PLAYLIST" | grep "HTTP_CODE" | cut -d: -f2)
|
||||||
|
PLAYLIST_BODY=$(echo "$PLAYLIST" | grep -v "HTTP_CODE")
|
||||||
|
PLAYLIST_SUCCESS=$(echo "$PLAYLIST_BODY" | jq -r '.success // false')
|
||||||
|
|
||||||
|
if [ "$HTTP_CODE" = "201" ] || [ "$HTTP_CODE" = "200" ]; then
|
||||||
|
if [ "$PLAYLIST_SUCCESS" = "true" ]; then
|
||||||
|
echo "✅ Create Playlist: OK"
|
||||||
|
else
|
||||||
|
echo "⚠️ Create Playlist: HTTP $HTTP_CODE mais success=false"
|
||||||
|
echo "$PLAYLIST_BODY" | jq .
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "❌ Create Playlist: Échec (HTTP $HTTP_CODE)"
|
||||||
|
echo "$PLAYLIST_BODY" | jq .
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 6. List Playlists (ISSUE-004)
|
||||||
|
echo ""
|
||||||
|
echo "6. Testing List Playlists (ISSUE-004)..."
|
||||||
|
PLAYLISTS=$(curl -s -w "\nHTTP_CODE:%{http_code}" -X GET "http://localhost:8080/api/v1/playlists" \
|
||||||
|
-H "Authorization: Bearer $ACCESS_TOKEN")
|
||||||
|
|
||||||
|
HTTP_CODE=$(echo "$PLAYLISTS" | grep "HTTP_CODE" | cut -d: -f2)
|
||||||
|
PLAYLISTS_BODY=$(echo "$PLAYLISTS" | grep -v "HTTP_CODE")
|
||||||
|
PLAYLISTS_SUCCESS=$(echo "$PLAYLISTS_BODY" | jq -r '.success // false')
|
||||||
|
|
||||||
|
if [ "$HTTP_CODE" = "200" ]; then
|
||||||
|
if [ "$PLAYLISTS_SUCCESS" = "true" ]; then
|
||||||
|
echo "✅ List Playlists: OK"
|
||||||
|
else
|
||||||
|
echo "⚠️ List Playlists: HTTP $HTTP_CODE mais success=false"
|
||||||
|
echo "$PLAYLISTS_BODY" | jq .
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "❌ List Playlists: Échec (HTTP $HTTP_CODE)"
|
||||||
|
echo "$PLAYLISTS_BODY" | jq .
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 7. Search Playlists (ISSUE-006)
|
||||||
|
echo ""
|
||||||
|
echo "7. Testing Search Playlists (ISSUE-006)..."
|
||||||
|
SEARCH=$(curl -s -w "\nHTTP_CODE:%{http_code}" -X GET "http://localhost:8080/api/v1/playlists/search?q=test" \
|
||||||
|
-H "Authorization: Bearer $ACCESS_TOKEN")
|
||||||
|
|
||||||
|
HTTP_CODE=$(echo "$SEARCH" | grep "HTTP_CODE" | cut -d: -f2)
|
||||||
|
SEARCH_BODY=$(echo "$SEARCH" | grep -v "HTTP_CODE")
|
||||||
|
SEARCH_SUCCESS=$(echo "$SEARCH_BODY" | jq -r '.success // false')
|
||||||
|
|
||||||
|
if [ "$HTTP_CODE" = "200" ]; then
|
||||||
|
if [ "$SEARCH_SUCCESS" = "true" ]; then
|
||||||
|
echo "✅ Search Playlists: OK"
|
||||||
|
else
|
||||||
|
echo "⚠️ Search Playlists: HTTP $HTTP_CODE mais success=false"
|
||||||
|
echo "$SEARCH_BODY" | jq .
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "❌ Search Playlists: Échec (HTTP $HTTP_CODE)"
|
||||||
|
echo "$SEARCH_BODY" | jq .
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 8. Logout
|
||||||
|
echo ""
|
||||||
|
echo "8. Testing Logout..."
|
||||||
|
REFRESH_TOKEN=$(echo "$LOGIN" | jq -r '.data.token.refresh_token // .data.refresh_token // .refresh_token // empty')
|
||||||
|
if [ -n "$REFRESH_TOKEN" ] && [ "$REFRESH_TOKEN" != "null" ]; then
|
||||||
|
LOGOUT=$(curl -s -X POST "http://localhost:8080/api/v1/auth/logout" \
|
||||||
|
-H "Authorization: Bearer $ACCESS_TOKEN" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{\"refresh_token\":\"$REFRESH_TOKEN\"}")
|
||||||
|
|
||||||
|
LOGOUT_SUCCESS=$(echo "$LOGOUT" | jq -r '.success // false')
|
||||||
|
if [ "$LOGOUT_SUCCESS" = "true" ]; then
|
||||||
|
echo "✅ Logout: OK"
|
||||||
|
else
|
||||||
|
echo "⚠️ Logout: Échec"
|
||||||
|
echo "$LOGOUT" | jq .
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "⏭️ Logout: Skip (pas de refresh token)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "=== MVP TEST COMPLETE ==="
|
||||||
|
|
||||||
Loading…
Reference in a new issue