bmc_hub/keepforlater/test_sftp.py
Christian a604a3cc44 Add comprehensive test suite for vTiger integration and ticket module
- Implemented test scripts for vTiger account retrieval, contact data, and modules.
- Created a detailed test suite for the ticket module, covering database schema validation, ticket number generation, prepaid card constraints, and service logic.
- Added tests for vTiger field inspection and various queries related to accounts and sales orders.
- Introduced SQL migration scripts for the ALSO Cloud Billing foundation, including import jobs, lines, and mapping tables with necessary constraints and indices.
- Enhanced workflow columns in the import lines table to support matching and validation timestamps.
2026-06-20 03:29:51 +02:00

71 lines
2.0 KiB
Python

#!/usr/bin/env python3
import paramiko
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
print("🔌 Connecting to SFTP...")
ssh.connect(
hostname='sftp.acdu.dk',
port=9022,
username='sftp_bmccrm',
password='9,Bg_U9,Bg_U9,Bg_U',
timeout=10
)
sftp = ssh.open_sftp()
print("✅ Connected to SFTP\n")
# List current directory
print(f"📁 Current directory: {sftp.getcwd() or '/'}\n")
print("📂 Files in root:")
for item in sftp.listdir():
try:
stat = sftp.stat(item)
is_dir = stat.st_mode & 0o40000
print(f" {'📁' if is_dir else '📄'} {item} ({stat.st_size} bytes)")
except Exception as e:
print(f"{item} (error: {e})")
# Try to list /backups
print("\n📂 Checking /backups:")
try:
files = sftp.listdir('/backups')
print(f" ✅ /backups exists, contains {len(files)} items")
for f in files[:5]:
print(f" - {f}")
except Exception as e:
print(f" ⚠️ /backups: {e}")
# Try to create it
print("\n Trying to create /backups...")
try:
sftp.mkdir('/backups')
print(" ✅ Created /backups")
except Exception as e2:
print(f" ❌ Cannot create: {e2}")
# Try current directory upload
print("\n📤 Testing upload to current directory...")
test_file = "/tmp/test_upload.txt"
with open(test_file, 'w') as f:
f.write("Test upload from BMC Hub")
try:
sftp.put(test_file, 'test_upload.txt')
print(" ✅ Upload to root successful!")
sftp.remove('test_upload.txt')
print(" ✅ Cleanup successful")
except Exception as e:
print(f" ❌ Upload failed: {e}")
sftp.close()
ssh.close()
print("\n✅ Test complete")
except Exception as e:
print(f"❌ Connection failed: {e}")
import traceback
traceback.print_exc()