-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_supabase_auth.py
More file actions
76 lines (62 loc) · 2.36 KB
/
test_supabase_auth.py
File metadata and controls
76 lines (62 loc) · 2.36 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env python3
"""
Test script for Supabase JWT Authentication
Run this script to test the Supabase authentication integration.
"""
import os
import sys
import requests
from pathlib import Path
# Add the app directory to Python path
sys.path.insert(0, str(Path(__file__).parent / "app"))
def test_supabase_auth():
"""Test Supabase authentication endpoints"""
base_url = "http://localhost:8000"
print("🧪 Testing Supabase Authentication Integration")
print("=" * 50)
# Test 1: Check if server is running
try:
response = requests.get(f"{base_url}/health")
if response.status_code == 200:
print("✅ Server is running")
else:
print("❌ Server is not responding properly")
return
except requests.exceptions.ConnectionError:
print("❌ Cannot connect to server. Make sure the server is running on port 8000")
return
# Test 2: Check if Supabase endpoints are available
try:
response = requests.get(f"{base_url}/auth/supabase/me")
# Should return 401 Unauthorized without token
if response.status_code == 401:
print("✅ Supabase auth endpoints are properly protected")
else:
print(f"⚠️ Unexpected response: {response.status_code}")
except Exception as e:
print(f"❌ Error testing Supabase endpoints: {e}")
# Test 3: Check configuration
from app.config import settings
required_vars = [
"SUPABASE_JWT_SECRET",
"SUPABASE_URL",
"SUPABASE_ANON_KEY"
]
print("\n🔧 Configuration Check:")
for var in required_vars:
value = getattr(settings, var, None)
if value:
print(f"✅ {var}: Configured")
else:
print(f"❌ {var}: Not configured")
if not settings.SUPABASE_JWT_SECRET:
print("\n⚠️ SUPABASE_JWT_SECRET is required for JWT verification")
print(" Add it to your .env file or environment variables")
print("\n📝 Next Steps:")
print("1. Configure Supabase environment variables")
print("2. Test with a real Supabase JWT token")
print("3. Update frontend to use Supabase Auth SDK")
print("4. Remove old manual OAuth endpoints if desired")
print("\n📖 See SUPABASE_AUTH_INTEGRATION.md for detailed documentation")
if __name__ == "__main__":
test_supabase_auth()