- 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.
56 lines
2.0 KiB
Python
56 lines
2.0 KiB
Python
import requests
|
|
import json
|
|
|
|
# Configuration
|
|
BASE_URL = "https://dev-api.oneskyit.com/v3/crud"
|
|
ACCOUNT_ID = "nqOzejLCDXM" # Legacy Header Fallback
|
|
|
|
def get_headers(include_account=True):
|
|
headers = {
|
|
"Content-Type": "application/json"
|
|
}
|
|
if include_account:
|
|
headers["X-Account-ID"] = ACCOUNT_ID
|
|
return headers
|
|
|
|
def test_endpoint(path, description, include_account=True):
|
|
print(f"--- Testing: {description} ---")
|
|
url = f"{BASE_URL}{path}"
|
|
try:
|
|
response = requests.get(url, headers=get_headers(include_account))
|
|
print(f"URL: {response.url}")
|
|
print(f"Status Code: {response.status_code}")
|
|
|
|
data = response.json()
|
|
result_data = data.get('data')
|
|
|
|
if isinstance(result_data, list):
|
|
print(f"Result Count: {len(result_data)}")
|
|
if len(result_data) > 0:
|
|
print(f"First Item: {json.dumps(result_data[0], indent=2)[:300]}...")
|
|
else:
|
|
print(f"Result Data: {json.dumps(result_data, indent=2)}")
|
|
|
|
if response.status_code != 200:
|
|
print(f"Error Message: {data.get('status_message')}")
|
|
|
|
except Exception as e:
|
|
print(f"Error during test: {e}")
|
|
print("-" * 40 + "\n")
|
|
|
|
if __name__ == "__main__":
|
|
# Test Users
|
|
test_endpoint("/user/", "List Users (Default filter)")
|
|
test_endpoint("/user/?enabled=all&hidden=all", "List Users (Bypass filter)")
|
|
|
|
# Test Sites
|
|
test_endpoint(f"/account/{ACCOUNT_ID}/site/", "List Sites (Account Filter)")
|
|
|
|
# Test Site Domains
|
|
test_endpoint("/site_domain/", "List Site Domains (Default filter)")
|
|
test_endpoint("/site_domain/?enabled=all&hidden=all", "List Site Domains (Bypass filter)")
|
|
|
|
# Test Legacy Site Domain Lookup (Initial frontend request)
|
|
# This route is in api_crud.py (v1) and needs to work without an account ID header
|
|
test_endpoint("/../../crud/site/domain/scott.localhost:5173?use_alt_table=true&use_alt_base=true", "Legacy Site Domain Lookup", include_account=False)
|