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:
97
test_upload_simple.py
Normal file
97
test_upload_simple.py
Normal file
@@ -0,0 +1,97 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
import requests
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).parent))
|
||||
sys.path.insert(0, str(Path(__file__).parent / "agent_v0"))
|
||||
|
||||
def test_upload():
|
||||
print("=== Test upload avec chiffrement ===")
|
||||
|
||||
# Charger config
|
||||
with open(".env.local", 'r') as f:
|
||||
env_vars = {}
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if line and not line.startswith('#') and '=' in line:
|
||||
key, value = line.split('=', 1)
|
||||
env_vars[key.strip()] = value.strip()
|
||||
|
||||
server_url = env_vars.get("RPA_SERVER_URL")
|
||||
auth_token = env_vars.get("RPA_TOKEN_ADMIN")
|
||||
|
||||
print(f"Server URL: {server_url}")
|
||||
print(f"Auth token: {auth_token[:16]}...")
|
||||
|
||||
# Créer session
|
||||
from agent_v0.raw_session import RawSession
|
||||
from agent_v0.storage_encrypted import create_session_zip_with_encryption
|
||||
from agent_v0.user_config import load_user_config
|
||||
|
||||
agent_config = load_user_config()
|
||||
encryption_password = agent_config.get("encryption_password")
|
||||
|
||||
print(f"Agent encryption password: {encryption_password[:16]}..." if encryption_password else "Agent encryption password: None")
|
||||
|
||||
test_session = RawSession.create(
|
||||
user_id="test_upload",
|
||||
platform="linux",
|
||||
hostname="test_host",
|
||||
screen_resolution=[1920, 1080]
|
||||
)
|
||||
|
||||
# Ajouter un événement de clic
|
||||
test_session.add_mouse_click_event(
|
||||
button="left",
|
||||
pos=[100, 200],
|
||||
window_title="Test Window",
|
||||
app_name="TestApp",
|
||||
screenshot_id=None
|
||||
)
|
||||
|
||||
test_session.close()
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
test_session.save_json(tmpdir)
|
||||
|
||||
# Pass password correctly as keyword argument
|
||||
encrypted_path = create_session_zip_with_encryption(
|
||||
session=test_session,
|
||||
base_dir=tmpdir,
|
||||
enable_encryption=True,
|
||||
password=encryption_password
|
||||
)
|
||||
|
||||
print(f"Fichier chiffré: {encrypted_path}")
|
||||
print(f"Taille: {os.path.getsize(encrypted_path)} bytes")
|
||||
|
||||
# Upload
|
||||
with open(encrypted_path, "rb") as f:
|
||||
files = {"file": (os.path.basename(encrypted_path), f, "application/octet-stream")}
|
||||
data = {"session_id": test_session.session_id}
|
||||
headers = {"Authorization": f"Bearer {auth_token}"}
|
||||
|
||||
response = requests.post(server_url, files=files, data=data, headers=headers, timeout=30)
|
||||
|
||||
print(f"Status HTTP: {response.status_code}")
|
||||
|
||||
if response.status_code == 200:
|
||||
print("✅ Upload réussi!")
|
||||
try:
|
||||
response_data = response.json()
|
||||
print(f"Événements reçus: {response_data.get('events_count')}")
|
||||
print(f"Session ID: {response_data.get('session_id')}")
|
||||
except:
|
||||
pass
|
||||
return True
|
||||
else:
|
||||
print(f"❌ Erreur HTTP {response.status_code}")
|
||||
print(f"Réponse: {response.text[:500]}")
|
||||
return False
|
||||
|
||||
if __name__ == "__main__":
|
||||
success = test_upload()
|
||||
sys.exit(0 if success else 1)
|
||||
Reference in New Issue
Block a user