Files
ai-gateway/test_supabase.py

48 lines
1.8 KiB
Python

import httpx
BASE_URL = "http://127.0.0.1:8000"
USERNAME = "admin"
PASSWORD = "Spear0yale!"
def test_supabase_integration():
client = httpx.Client(timeout=30.0)
print("1. Logging into Admin Panel...")
login_data = {"username": USERNAME, "password": PASSWORD}
response = client.post(f"{BASE_URL}/auth/login", data=login_data)
if response.status_code != 200:
print(f"Login failed: {response.status_code} - {response.text}")
return
token = response.json()["access_token"]
headers = {"Authorization": f"Bearer {token}"}
print("Login successful.")
print("\n2. Creating a module...")
module_name = "Supabase_Integration_Live"
response = client.post(
f"{BASE_URL}/internal/admin/modules",
json={"name": "Supabase_Integration_Live"},
headers=headers
)
if response.status_code == 400 and "already exists" in response.text:
print("Module already exists, testing rotation...")
# Get modules to find the ID
get_res = client.get(f"{BASE_URL}/internal/admin/modules", headers=headers)
modules = get_res.json()
target = next(m for m in modules if m["name"] == "Supabase_Integration_Live")
rotate_res = client.post(f"{BASE_URL}/internal/admin/modules/{target['id']}/rotate", headers=headers)
print(f"Rotation status: {rotate_res.status_code}")
print(f"New Key Sample: {rotate_res.json()['secret_key'][:10]}...")
elif response.status_code == 201 or response.status_code == 200:
print("Module created successfully on Supabase!")
print(f"Key: {response.json()['secret_key']}")
else:
print(f"Failed to create module: {response.status_code} - {response.text}")
if __name__ == "__main__":
test_supabase_integration()