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:
110
test_real_upload_scenario.py
Normal file
110
test_real_upload_scenario.py
Normal file
@@ -0,0 +1,110 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Test the real upload scenario to reproduce the "Padding invalide: 64" error.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
import requests
|
||||
from pathlib import Path
|
||||
|
||||
# Add paths for imports
|
||||
sys.path.insert(0, str(Path(__file__).parent / "agent_v0"))
|
||||
sys.path.insert(0, str(Path(__file__).parent))
|
||||
|
||||
def test_real_upload_scenario():
|
||||
"""Test the actual upload scenario that's failing."""
|
||||
|
||||
# Load environment variables like the agent does
|
||||
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()
|
||||
|
||||
# Import after setting environment
|
||||
from agent_v0.storage_encrypted import create_session_zip_with_encryption
|
||||
from agent_v0.raw_session import RawSession
|
||||
from agent_v0.user_config import load_user_config
|
||||
|
||||
print("=== Testing Real Upload Scenario ===")
|
||||
|
||||
# Load agent config (like the real agent does)
|
||||
config = load_user_config()
|
||||
print(f"Agent config encryption_password: {config.get('encryption_password')}")
|
||||
print(f"Agent config enable_encryption: {config.get('enable_encryption')}")
|
||||
|
||||
# Create test session
|
||||
test_session = RawSession.create(
|
||||
user_id="test_real_upload",
|
||||
platform="linux",
|
||||
hostname="test_host",
|
||||
screen_resolution=[1920, 1080]
|
||||
)
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
# Save the session (like the real agent does)
|
||||
test_session.save_json(tmpdir)
|
||||
|
||||
# Create encrypted ZIP exactly like the agent does
|
||||
try:
|
||||
zip_path = create_session_zip_with_encryption(
|
||||
test_session,
|
||||
base_dir=tmpdir,
|
||||
enable_encryption=config.get("enable_encryption", True),
|
||||
password=config.get("encryption_password")
|
||||
)
|
||||
print(f"Agent created encrypted file: {zip_path}")
|
||||
|
||||
# Check file size and content
|
||||
file_size = os.path.getsize(zip_path)
|
||||
print(f"File size: {file_size} bytes")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Agent encryption failed: {e}")
|
||||
return False
|
||||
|
||||
# Now test server-side decryption
|
||||
server_password = os.getenv("ENCRYPTION_PASSWORD", "rpa_vision_v3_default_key")
|
||||
print(f"Server password: {server_password[:20]}...")
|
||||
|
||||
try:
|
||||
from server.storage_encrypted import decrypt_session_file
|
||||
|
||||
decrypted_path = decrypt_session_file(
|
||||
zip_path,
|
||||
server_password,
|
||||
os.path.join(tmpdir, "server_decrypted.zip")
|
||||
)
|
||||
print(f"Server decryption successful: {decrypted_path}")
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
print(f"Server decryption failed: {e}")
|
||||
|
||||
# Try with the session-based password that agent actually uses
|
||||
session_based_password = f"rpa_vision_v3_{test_session.session_id}"
|
||||
print(f"Trying with session-based password: {session_based_password[:20]}...")
|
||||
|
||||
try:
|
||||
decrypted_path = decrypt_session_file(
|
||||
zip_path,
|
||||
session_based_password,
|
||||
os.path.join(tmpdir, "session_decrypted.zip")
|
||||
)
|
||||
print(f"Decryption with session password works: {decrypted_path}")
|
||||
print("This confirms the agent uses session-based password!")
|
||||
return False # Still a mismatch
|
||||
|
||||
except Exception as e2:
|
||||
print(f"Session password also failed: {e2}")
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("Testing real upload scenario...")
|
||||
test_real_upload_scenario()
|
||||
Reference in New Issue
Block a user