92 lines
2.7 KiB
Python
Executable file
92 lines
2.7 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
"""
|
|
Test Connections - Verify DAM, Box, and Database connectivity
|
|
Supports both OAuth2 (default) and mTLS (--auth-pfx) authentication
|
|
"""
|
|
|
|
import sys
|
|
import os
|
|
import argparse
|
|
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
|
|
|
|
from shared.config_loader import load_config
|
|
from shared.dam_client import DAMClient
|
|
from shared.box_client import BoxClient
|
|
from shared.database import Database
|
|
|
|
def main():
|
|
# Parse arguments
|
|
parser = argparse.ArgumentParser(description='Test Ferrero Automation Connections')
|
|
parser.add_argument('--auth-pfx', action='store_true',
|
|
help='Use mTLS certificate authentication instead of OAuth2')
|
|
args = parser.parse_args()
|
|
|
|
print("=" * 60)
|
|
print("Testing Ferrero Automation Connections")
|
|
if args.auth_pfx:
|
|
print("Authentication: mTLS Certificate (--auth-pfx)")
|
|
else:
|
|
print("Authentication: OAuth2 (default)")
|
|
print("=" * 60)
|
|
print("")
|
|
|
|
# Load config
|
|
try:
|
|
config = load_config('config/config.yaml')
|
|
print("✓ Configuration loaded")
|
|
except Exception as e:
|
|
print("✗ Configuration failed: {}".format(e))
|
|
sys.exit(1)
|
|
|
|
# Test DAM
|
|
print("")
|
|
print("Testing DAM connection...")
|
|
try:
|
|
dam = DAMClient(config, use_mtls=args.auth_pfx)
|
|
if dam.test_connection():
|
|
print("✓ DAM connection OK")
|
|
print(" URL: {}".format(config['dam']['base_url']))
|
|
if args.auth_pfx:
|
|
print(" Auth: mTLS Certificate")
|
|
else:
|
|
print(" Auth: OAuth2")
|
|
else:
|
|
print("✗ DAM connection failed")
|
|
except Exception as e:
|
|
print("✗ DAM error: {}".format(e))
|
|
|
|
# Test Box
|
|
print("")
|
|
print("Testing Box connection...")
|
|
try:
|
|
box = BoxClient(config)
|
|
if box.test_connection():
|
|
print("✓ Box connection OK")
|
|
print(" Enterprise ID: {}".format(config['box']['enterprise_id']))
|
|
else:
|
|
print("✗ Box connection failed")
|
|
except Exception as e:
|
|
print("✗ Box error: {}".format(e))
|
|
|
|
# Test Database
|
|
print("")
|
|
print("Testing Database connection...")
|
|
try:
|
|
db = Database(config)
|
|
if db.test_connection():
|
|
print("✓ Database connection OK")
|
|
print(" Host: {}:{}".format(config['database']['host'], config['database']['port']))
|
|
else:
|
|
print("✗ Database connection failed")
|
|
db.close()
|
|
except Exception as e:
|
|
print("✗ Database error: {}".format(e))
|
|
|
|
print("")
|
|
print("=" * 60)
|
|
print("Testing complete!")
|
|
print("=" * 60)
|
|
|
|
if __name__ == '__main__':
|
|
main()
|