Files
OSIT-AE-API-FastAPI/tests/e2e/test_e2e_site_bootstrap.py
Scott Idem b2384f2869 Tests: Reorganize test suite into functional subdirectories
- Categorized scripts into tests/unit/, tests/integration/, tests/e2e/, and tests/tools/.
- Adopted consistent naming prefixes (test_unit_*, test_int_*, test_e2e_*, tool_*).
- Renamed conftest_mock.py to mock_config_helper.py for clarity.
- Updated test_int_boot_diagnosis.py with sys.path setup for root-level execution.
2026-01-16 10:46:19 -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()