Spaces:
Paused

File size: 1,634 Bytes
3143c25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42

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())