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:
113
test_complete_upload_flow.py
Normal file
113
test_complete_upload_flow.py
Normal file
@@ -0,0 +1,113 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Test the complete upload flow: create session, encrypt, upload to server.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
import requests
|
||||
import json
|
||||
from pathlib import Path
|
||||
from datetime import datetime
|
||||
|
||||
# Add agent_v0 to path
|
||||
sys.path.insert(0, str(Path(__file__).parent / "agent_v0"))
|
||||
|
||||
def test_complete_upload_flow():
|
||||
"""Test creating a session, encrypting it, and uploading to server."""
|
||||
|
||||
print("=== Testing Complete Upload Flow ===")
|
||||
|
||||
# Load environment
|
||||
env_local_path = Path(".env.local")
|
||||
if env_local_path.exists():
|
||||
with open(env_local_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()
|
||||
|
||||
password = os.getenv("ENCRYPTION_PASSWORD")
|
||||
server_url = os.getenv("RPA_SERVER_URL")
|
||||
admin_token = os.getenv("RPA_TOKEN_ADMIN")
|
||||
|
||||
print(f"Password: {password[:16]}...")
|
||||
print(f"Server URL: {server_url}")
|
||||
print(f"Admin token: {admin_token[:16]}...")
|
||||
|
||||
# Import agent modules
|
||||
from raw_session import RawSession
|
||||
from storage_encrypted import create_session_zip_encrypted
|
||||
|
||||
# Create a test session
|
||||
session = RawSession.create(
|
||||
user_id="test_upload_flow",
|
||||
platform="linux",
|
||||
hostname="test_host",
|
||||
screen_resolution=[1920, 1080]
|
||||
)
|
||||
|
||||
# Add some test data
|
||||
session.add_mouse_click_event("left", [100, 200], "Test Window", "Test App", None)
|
||||
session.add_mouse_click_event("left", [300, 400], "Test Window", "Test App", None)
|
||||
|
||||
print(f"Created session: {session.session_id}")
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
# Save session
|
||||
session.save_json(tmpdir)
|
||||
|
||||
# Encrypt
|
||||
encrypted_path = create_session_zip_encrypted(
|
||||
session,
|
||||
password,
|
||||
tmpdir,
|
||||
delete_unencrypted=False
|
||||
)
|
||||
|
||||
print(f"Encrypted file: {encrypted_path}")
|
||||
print(f"File size: {os.path.getsize(encrypted_path)} bytes")
|
||||
|
||||
# Test upload to server
|
||||
print("Testing upload to server...")
|
||||
|
||||
try:
|
||||
with open(encrypted_path, 'rb') as f:
|
||||
files = {'file': (f'{session.session_id}.enc', f, 'application/octet-stream')}
|
||||
data = {'session_id': session.session_id}
|
||||
headers = {'Authorization': f'Bearer {admin_token}'}
|
||||
|
||||
response = requests.post(
|
||||
server_url,
|
||||
files=files,
|
||||
data=data,
|
||||
headers=headers,
|
||||
timeout=30
|
||||
)
|
||||
|
||||
print(f"Upload response: {response.status_code}")
|
||||
print(f"Response body: {response.text}")
|
||||
|
||||
if response.status_code == 200:
|
||||
print("Upload successful!")
|
||||
return True
|
||||
else:
|
||||
print(f"Upload failed with status {response.status_code}")
|
||||
return False
|
||||
|
||||
except Exception as e:
|
||||
print(f"Upload error: {e}")
|
||||
return False
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
success = test_complete_upload_flow()
|
||||
print(f"Test result: {'SUCCESS' if success else 'FAILED'}")
|
||||
sys.exit(0 if success else 1)
|
||||
except Exception as e:
|
||||
print(f"Test exception: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
sys.exit(1)
|
||||
Reference in New Issue
Block a user