Files
OSIT-AE-API-FastAPI/tests/test_site_lookup.py
Scott Idem d321b94395 chore(tests): organize test scripts and beautify account creation email
- Moved scattered Python test scripts from root and 'admin/development/' to 'tests/'.
- Beautified the HTML email body for account creation links in 'app/methods/person_methods.py' with a modern responsive design.
2026-01-15 14:38:00 -05:00

48 lines
1.5 KiB
Python

import requests
import json
import sys
# Configuration
BASE_URL = "https://dev-api.oneskyit.com/v3/crud"
FQDN_TO_TEST = "dev-app.oneskyit.com" # Example domain that should exist
def test_site_domain_lookup():
print(f"--- Testing Public Site Domain Lookup: {FQDN_TO_TEST} ---")
url = f"{BASE_URL}/site_domain/search"
# Payload: Search for FQDN, explicitly WITHOUT authentication
# The frontend typically sends this to bootstrap
query = {
"and": [{"field": "fqdn", "op": "eq", "value": FQDN_TO_TEST}]
}
# NO AUTH HEADERS (Simulating unauthenticated bootstrapping)
headers = {
"Content-Type": "application/json"
}
try:
response = requests.post(url, headers=headers, json=query)
print(f"URL: {response.url}")
print(f"Status Code: {response.status_code}")
data = response.json()
if response.status_code == 200:
result_data = data.get('data')
if isinstance(result_data, list):
print(f"Success! Found {len(result_data)} records.")
if len(result_data) > 0:
print(f"Data: {json.dumps(result_data[0], indent=2)}")
else:
print(f"Unexpected data format: {type(result_data)}")
else:
print(f"Failure (Expected before fix). Message: {data.get('status_message')}")
except Exception as e:
print(f"Error during test: {e}")
print("-" * 40 + "\n")
if __name__ == "__main__":
test_site_domain_lookup()