Spaces:
Paused
Paused
Download scratch/final_check.py from 3SCError404/nexus: direct link, hf CLI and curl.
- Browser
- Download file 1.63 kB
-
https://huggingface.co/spaces/3SCError404/nexus/resolve/main/scratch/final_check.py
- Command line
-
hf download hf://spaces/3SCError404/nexus/scratch/final_check.py
-
curl -L -o final_check.py https://huggingface.co/spaces/3SCError404/nexus/resolve/main/scratch/final_check.py
1.63 kB
| import asyncio | |
| import httpx | |
| BASE_URL = "http://localhost:8000/api/v1" | |
| async def final_check(): | |
| async with httpx.AsyncClient(timeout=10.0) as client: | |
| # 1. Login as Admin A | |
| print("Logging in as Admin A...") | |
| r = await client.post(f"{BASE_URL}/auth/login/", data={"username": "admin@a.com", "password": "password123"}) | |
| if r.status_code != 200: | |
| print(f"Login failed: {r.text}") | |
| return | |
| token = r.json()["access_token"] | |
| headers = {"Authorization": f"Bearer {token}"} | |
| # 2. Check User Visibility | |
| print("Checking user visibility for Admin A...") | |
| r2 = await client.get(f"{BASE_URL}/users/", headers=headers) | |
| emails = [u["email"] for u in r2.json()] | |
| print(f"Visible Users: {emails}") | |
| # Super Admin should NOT be visible | |
| if "admin@3sc.com" in emails or "admin@nexus.ai" in emails: | |
| print("❌ SECURITY BREACH: Super Admin visible to Local Admin!") | |
| else: | |
| print("✅ SUCCESS: Super Admin is hidden from Local Admin.") | |
| # 3. Check Workspace Switch | |
| print("Checking workspace switch for Admin A...") | |
| ansell_id = "00078389-729d-4355-827c-9411681283c7" | |
| r3 = await client.post(f"{BASE_URL}/auth/switch-workspace/?target_workspace_id={ansell_id}", headers=headers) | |
| if r3.status_code == 403: | |
| print("✅ SUCCESS: Workspace switch blocked.") | |
| else: | |
| print(f"❌ SECURITY BREACH: Workspace switch allowed (Status: {r3.status_code})") | |
| if __name__ == "__main__": | |
| asyncio.run(final_check()) | |