-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_test_user.py
More file actions
65 lines (54 loc) · 1.81 KB
/
Copy pathcreate_test_user.py
File metadata and controls
65 lines (54 loc) · 1.81 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
#!/usr/bin/env python3
"""
Create a test user for UI testing
"""
import sys
import os
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
from app.core.database import get_db_session
from app.core.auth import user_manager
from app.core.tenant import tenant_registry
def create_test_user():
"""Create a test user for UI testing"""
tenant_id = "test_tenant_phase5"
print(f"👤 Creating test user for tenant: {tenant_id}")
try:
# Create user
user_data = {
"username": "admin",
"email": "admin@test.com",
"password": "admin123",
"roles": [
"admin",
"products:read",
"products:write",
"categories:read",
"categories:write",
"orders:read",
"orders:write",
"customers:read",
"customers:write",
],
}
user = user_manager.create_tenant_user(tenant_id, user_data)
print(f"✅ User created successfully: {user}")
if isinstance(user, dict):
print(f" Username: {user.get('username')}")
print(f" Email: {user.get('email')}")
print(f" Roles: {user.get('roles')}")
else:
print(f" Username: {user.username}")
print(f" Email: {user.email}")
print(f" Roles: {user.roles}")
# Test login
print("\n🔐 Testing login...")
auth_user = user_manager.authenticate_tenant_user(tenant_id, "admin", "admin123")
if auth_user:
print("✅ Login test successful!")
else:
print("❌ Login test failed!")
except Exception as e:
print(f"❌ Error creating user: {e}")
raise
if __name__ == "__main__":
create_test_user()