-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathreproduce_signup_fix.py
More file actions
42 lines (35 loc) · 1.42 KB
/
Copy pathreproduce_signup_fix.py
File metadata and controls
42 lines (35 loc) · 1.42 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
import requests
import json
BASE_URL = "http://localhost:8000"
def signup_with_invalid_token(email, password, username, endpoint):
url = f"{BASE_URL}{endpoint}"
data = {
"email": email,
"password": password,
"name": username # Changed from 'username' to 'name' to match view expectation
}
# Simulate the issue: sending an invalid token
headers = {
"Authorization": "Bearer invalid_token_string"
}
print(f"Signing up user: {email} at {endpoint} with INVALID TOKEN")
try:
response = requests.post(url, json=data, headers=headers)
print(f"Signup Response: {response.status_code}")
if response.status_code in [200, 201]:
print("✅ SUCCESS: Registration succeeded despite invalid token!")
print("Response Body:", response.text)
else:
print("❌ FAILED: Registration failed.")
print("Response Body:", response.text)
except Exception as e:
print(f"Signup failed: {e}")
if __name__ == "__main__":
# Use a unique email to avoid "already exists" error if possible, or just check status
import time
timestamp = int(time.time())
email = f"testuser_{timestamp}@example.com"
password = "password123"
username = f"Test User {timestamp}"
# Test the registration endpoint
signup_with_invalid_token(email, password, username, "/api/auth/register/")