Some checks failed
AITBC CI/CD Pipeline / lint-and-test (3.11) (push) Has been cancelled
AITBC CI/CD Pipeline / lint-and-test (3.12) (push) Has been cancelled
AITBC CI/CD Pipeline / lint-and-test (3.13) (push) Has been cancelled
AITBC CI/CD Pipeline / test-cli (push) Has been cancelled
AITBC CI/CD Pipeline / test-services (push) Has been cancelled
AITBC CI/CD Pipeline / test-production-services (push) Has been cancelled
AITBC CI/CD Pipeline / security-scan (push) Has been cancelled
AITBC CI/CD Pipeline / build (push) Has been cancelled
AITBC CI/CD Pipeline / deploy-staging (push) Has been cancelled
AITBC CI/CD Pipeline / deploy-production (push) Has been cancelled
AITBC CI/CD Pipeline / performance-test (push) Has been cancelled
AITBC CI/CD Pipeline / docs (push) Has been cancelled
AITBC CI/CD Pipeline / release (push) Has been cancelled
AITBC CI/CD Pipeline / notify (push) Has been cancelled
Security Scanning / Bandit Security Scan (apps/coordinator-api/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (cli/aitbc_cli) (push) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-core/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-crypto/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-sdk/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (tests) (push) Has been cancelled
Security Scanning / CodeQL Security Analysis (javascript) (push) Has been cancelled
Security Scanning / CodeQL Security Analysis (python) (push) Has been cancelled
Security Scanning / Dependency Security Scan (push) Has been cancelled
Security Scanning / Container Security Scan (push) Has been cancelled
Security Scanning / OSSF Scorecard (push) Has been cancelled
Security Scanning / Security Summary Report (push) Has been cancelled
- Add conn.commit() to agent registration in agent-registry - Remove unused integration_layer.py and coordinator.py from agent-services - Fix blockchain RPC endpoint from /rpc/sync to /rpc/syncStatus - Replace Annotated[Session, Depends(get_session)] with Session = Depends(get_session) for cleaner dependency injection syntax across marketplace routers
93 lines
3.5 KiB
Python
Executable File
93 lines
3.5 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
Simple API Structure Validation for AITBC
|
|
Confirms that core endpoints are accessible and responding
|
|
"""
|
|
|
|
import requests
|
|
import sys
|
|
import json
|
|
|
|
def test_api_structure(base_url: str = "http://localhost:8000"):
|
|
"""Validate that the API structure is accessible"""
|
|
print("🔍 Validating AITBC API Structure...")
|
|
print("=" * 50)
|
|
|
|
# Test 1: Basic health endpoint
|
|
print("\n1. Checking basic health endpoint...")
|
|
try:
|
|
resp = requests.get(f"{base_url}/health", timeout=10)
|
|
if resp.status_code == 200:
|
|
print(" ✓ Coordinator API health endpoint accessible")
|
|
health_data = resp.json()
|
|
print(f" Environment: {health_data.get('env', 'unknown')}")
|
|
else:
|
|
print(f" ✗ Health check failed: {resp.status_code}")
|
|
return False
|
|
except Exception as e:
|
|
print(f" ✗ Health check error: {e}")
|
|
return False
|
|
|
|
# Test 2: API key authentication
|
|
print("\n2. Testing API key authentication...")
|
|
try:
|
|
headers = {"X-Api-Key": "test-key"}
|
|
resp = requests.get(f"{base_url}/v1/marketplace/gpu/list",
|
|
headers=headers, timeout=10)
|
|
if resp.status_code == 200:
|
|
print(" ✓ API key authentication working")
|
|
gpu_data = resp.json()
|
|
print(f" Available GPUs: {len(gpu_data) if isinstance(gpu_data, list) else 'unknown'}")
|
|
else:
|
|
print(f" ✗ API key auth failed: {resp.status_code}")
|
|
# Don't return False here as this might be expected if no GPUs
|
|
except Exception as e:
|
|
print(f" ✗ API key auth error: {e}")
|
|
return False
|
|
|
|
# Test 3: Check if we can reach the users area (even if specific endpoints fail)
|
|
print("\n3. Checking users endpoint accessibility...")
|
|
try:
|
|
headers = {"X-Api-Key": "test-key"}
|
|
# Try a known working pattern - the /me endpoint with fake token
|
|
resp = requests.get(f"{base_url}/v1/users/me?token=test",
|
|
headers=headers, timeout=10)
|
|
# We expect either 401 (bad token) or 422 (validation error) - NOT 404
|
|
if resp.status_code in [401, 422]:
|
|
print(" ✓ Users endpoint accessible (authentication required)")
|
|
print(f" Response status: {resp.status_code} (expected auth/validation error)")
|
|
elif resp.status_code == 404:
|
|
print(" ✗ Users endpoint not found (404)")
|
|
return False
|
|
else:
|
|
print(f" ⚠ Unexpected status: {resp.status_code}")
|
|
except Exception as e:
|
|
print(f" ✗ Users endpoint error: {e}")
|
|
return False
|
|
|
|
print("\n" + "=" * 50)
|
|
print("✅ API Structure Validation Complete")
|
|
print("📝 Summary:")
|
|
print(" - Core API is accessible")
|
|
print(" - Authentication mechanisms are in place")
|
|
print(" - Endpoint routing is functional")
|
|
print(" - Ready for end-to-end testing when user service is operational")
|
|
return True
|
|
|
|
def main():
|
|
import argparse
|
|
parser = argparse.ArgumentParser(description='Validate AITBC API Structure')
|
|
parser.add_argument('--url', default='http://localhost:8000',
|
|
help='Base URL for AITBC services')
|
|
args = parser.parse_args()
|
|
|
|
try:
|
|
success = test_api_structure(args.url)
|
|
sys.exit(0 if success else 1)
|
|
except Exception as e:
|
|
print(f"Unexpected error: {e}")
|
|
sys.exit(1)
|
|
|
|
if __name__ == "__main__":
|
|
main()
|