Files
innotexBoard/test_disks.sh
2026-01-16 18:40:39 +01:00

41 lines
1.2 KiB
Bash

#!/bin/bash
# Test de l'endpoint disques
# Assurez-vous que le serveur FastAPI est en cours d'exécution sur http://localhost:8000
# Couleurs
GREEN='\033[0;32m'
BLUE='\033[0;34m'
NC='\033[0m'
echo -e "${BLUE}Test de l'endpoint /api/system/disks${NC}"
echo "========================================"
# Vous devez d'abord obtenir un token d'authentification
echo -e "${BLUE}1. Connexion...${NC}"
LOGIN_RESPONSE=$(curl -s -X POST http://localhost:8000/api/auth/login \
-H "Content-Type: application/json" \
-d '{"username": "admin", "password": "admin"}')
TOKEN=$(echo $LOGIN_RESPONSE | grep -o '"access_token":"[^"]*' | cut -d'"' -f4)
if [ -z "$TOKEN" ]; then
echo "Erreur: impossible de se connecter. Réponse:"
echo $LOGIN_RESPONSE
exit 1
fi
echo -e "${GREEN}✓ Connecté avec succès${NC}"
echo "Token: ${TOKEN:0:20}..."
# Test de l'endpoint disques
echo -e "\n${BLUE}2. Récupération des informations sur les disques...${NC}"
DISKS_RESPONSE=$(curl -s -X GET http://localhost:8000/api/system/disks \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json")
echo -e "${GREEN}✓ Réponse reçue:${NC}"
echo $DISKS_RESPONSE | jq '.' 2>/dev/null || echo $DISKS_RESPONSE
echo -e "\n${GREEN}Test terminé!${NC}"