Harden bootstrap_db_config to prioritize .env settings for core infrastructure (DB/SMTP) and only use DB values if placeholders are detected or values have explicitly changed. Added test_e2e_email_send.py for functional SMTP verification.
49 lines
1.7 KiB
Python
49 lines
1.7 KiB
Python
import requests
|
|
import json
|
|
import time
|
|
|
|
# --- Configuration ---
|
|
API_BASE = "https://dev-api.oneskyit.com/util/email"
|
|
API_KEY = "PMM4n50teUCaOMMTN8qOJA" # Agent API Key
|
|
ACCOUNT_ID = "_XY7DXtc9MY" # Standard Test Account
|
|
|
|
def test_email_send_live():
|
|
"""
|
|
End-to-End test for the email send utility.
|
|
Verifies that the API can successfully authenticate with SMTP and dispatch an email.
|
|
"""
|
|
print("\n--- Testing Live Email Send via API ---")
|
|
print(f"Target: {API_BASE}/send")
|
|
|
|
payload = {
|
|
"from_email": "noreply@oneskyit.com",
|
|
"from_name": "Aether API Monitor",
|
|
"to_email": "scott.idem+devtest@oneskyit.com",
|
|
"to_name": "Scott Idem (Dev Test)",
|
|
"subject": f"Aether E2E Test: {time.strftime('%Y-%m-%d %H:%M:%S')}",
|
|
"body_html": "<h3>Aether API Status Check</h3><p>This email confirms that the SMTP subsystem is operational and prioritizing correctly.</p><p>Environment: <b>Development</b></p>",
|
|
"body_text": "Aether API Status Check: SMTP subsystem is operational."
|
|
}
|
|
|
|
headers = {
|
|
"Content-Type": "application/json",
|
|
"X-Aether-API-Key": API_KEY,
|
|
"x-account-id": ACCOUNT_ID
|
|
}
|
|
|
|
start_time = time.time()
|
|
resp = requests.post(f"{API_BASE}/send", headers=headers, json=payload)
|
|
duration = time.time() - start_time
|
|
|
|
print(f"Status Code: {resp.status_code}")
|
|
print(f"Response: {resp.text}")
|
|
print(f"Duration: {duration:.2f}s")
|
|
|
|
if resp.status_code == 200:
|
|
print("[✅ PASS] Email successfully dispatched.")
|
|
else:
|
|
print("[❌ FAIL] Email failed to send. Check FastAPI logs for SMTP errors.")
|
|
|
|
if __name__ == "__main__":
|
|
test_email_send_live()
|