v1.0 - Version stable: multi-PC, détection UI-DETR-1, 3 modes exécution
- Frontend v4 accessible sur réseau local (192.168.1.40) - Ports ouverts: 3002 (frontend), 5001 (backend), 5004 (dashboard) - Ollama GPU fonctionnel - Self-healing interactif - Dashboard confiance Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
96
test_upload_auth.py
Normal file
96
test_upload_auth.py
Normal file
@@ -0,0 +1,96 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Test d'upload avec authentification pour vérifier la correction de l'agent v0.
|
||||
"""
|
||||
|
||||
import os
|
||||
import requests
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
def load_env_vars():
|
||||
"""Charge les variables d'environnement depuis .env.local"""
|
||||
env_path = Path(".env.local")
|
||||
if env_path.exists():
|
||||
with open(env_path, 'r') as f:
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if line and not line.startswith('#') and '=' in line:
|
||||
key, value = line.split('=', 1)
|
||||
os.environ[key.strip()] = value.strip()
|
||||
|
||||
def test_server_auth():
|
||||
"""Test l'authentification du serveur."""
|
||||
load_env_vars()
|
||||
|
||||
token = os.environ.get('RPA_TOKEN_ADMIN')
|
||||
if not token:
|
||||
print("❌ Token RPA_TOKEN_ADMIN non trouvé")
|
||||
return False
|
||||
|
||||
print(f"✓ Token chargé: {token[:16]}...")
|
||||
|
||||
# Test différents formats d'authentification
|
||||
headers_formats = [
|
||||
{"Authorization": f"Bearer {token}"},
|
||||
{"Authorization": f"Token {token}"},
|
||||
{"X-API-Key": token},
|
||||
{"RPA-Token": token},
|
||||
]
|
||||
|
||||
for i, headers in enumerate(headers_formats):
|
||||
print(f"\nTest format {i+1}: {list(headers.keys())[0]}")
|
||||
try:
|
||||
response = requests.get(
|
||||
"http://localhost:8000/api/traces/status",
|
||||
headers=headers,
|
||||
timeout=5
|
||||
)
|
||||
print(f" Status: {response.status_code}")
|
||||
if response.status_code == 200:
|
||||
print(f" ✓ Succès avec format: {list(headers.keys())[0]}")
|
||||
print(f" Réponse: {response.json()}")
|
||||
return True
|
||||
else:
|
||||
print(f" ❌ Échec: {response.text}")
|
||||
except Exception as e:
|
||||
print(f" ❌ Erreur: {e}")
|
||||
|
||||
return False
|
||||
|
||||
def test_uploader_config():
|
||||
"""Vérifie la configuration de l'uploader de l'agent v0."""
|
||||
try:
|
||||
import sys
|
||||
sys.path.insert(0, 'agent_v0')
|
||||
from uploader import Uploader
|
||||
from config import Config
|
||||
|
||||
config = Config()
|
||||
uploader = Uploader(config)
|
||||
|
||||
print(f"\nConfiguration uploader:")
|
||||
print(f" URL: {uploader.server_url}")
|
||||
print(f" Token présent: {bool(uploader.auth_token)}")
|
||||
if uploader.auth_token:
|
||||
print(f" Token: {uploader.auth_token[:16]}...")
|
||||
|
||||
return bool(uploader.auth_token)
|
||||
except Exception as e:
|
||||
print(f"❌ Erreur lecture config uploader: {e}")
|
||||
return False
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("=== Test d'authentification serveur ===")
|
||||
|
||||
server_ok = test_server_auth()
|
||||
uploader_ok = test_uploader_config()
|
||||
|
||||
print(f"\n=== Résultats ===")
|
||||
print(f"Serveur accessible: {'✓' if server_ok else '❌'}")
|
||||
print(f"Uploader configuré: {'✓' if uploader_ok else '❌'}")
|
||||
|
||||
if server_ok and uploader_ok:
|
||||
print("✓ Authentification fonctionnelle!")
|
||||
else:
|
||||
print("❌ Problème d'authentification détecté")
|
||||
Reference in New Issue
Block a user