-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_auth_flow.py
More file actions
75 lines (59 loc) · 2 KB
/
test_auth_flow.py
File metadata and controls
75 lines (59 loc) · 2 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
#!/usr/bin/env python3
"""
Test script to debug the authentication flow.
"""
import os
import sys
import requests
# Add the project root to Python path
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
def test_auth_flow():
"""Test the authentication flow step by step."""
print("=== Testing Authentication Flow ===")
# Test environment API key
env_key = "test-key-1234567890123456"
print(f"Testing environment API key: {env_key}")
try:
response = requests.get(
"http://localhost:5000/trackers",
headers={"Authorization": f"Bearer {env_key}"},
timeout=5,
)
print(f"Status: {response.status_code}")
print(f"Response: {response.text}")
except requests.exceptions.ConnectionError:
print("Could not connect to server")
except Exception as e:
print(f"Error: {e}")
# Test user API key
user_key = "uk_3PvRjtRYLS67eqFD4Avm8Uhhk7OnGmrQMsQ1yFnLiss"
print(f"\nTesting user API key: {user_key}")
try:
response = requests.get(
"http://localhost:5000/trackers",
headers={"Authorization": f"Bearer {user_key}"},
timeout=5,
)
print(f"Status: {response.status_code}")
print(f"Response: {response.text}")
except requests.exceptions.ConnectionError:
print("Could not connect to server")
except Exception as e:
print(f"Error: {e}")
# Test invalid key
invalid_key = "invalid-key"
print(f"\nTesting invalid API key: {invalid_key}")
try:
response = requests.get(
"http://localhost:5000/trackers",
headers={"Authorization": f"Bearer {invalid_key}"},
timeout=5,
)
print(f"Status: {response.status_code}")
print(f"Response: {response.text}")
except requests.exceptions.ConnectionError:
print("Could not connect to server")
except Exception as e:
print(f"Error: {e}")
if __name__ == "__main__":
test_auth_flow()