-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_admin.py
More file actions
66 lines (56 loc) · 2.02 KB
/
test_admin.py
File metadata and controls
66 lines (56 loc) · 2.02 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
#!/usr/bin/env python3
"""
Test with existing admin credentials
"""
import requests
import json
import sys
from urllib3.exceptions import InsecureRequestWarning
# Suppress TLS warnings
requests.packages.urllib3.disable_warnings(category=InsecureRequestWarning)
def test_existing_credentials():
"""Test login with existing admin user"""
print("Testing with existing admin credentials...")
# Try with admin user
login_data = {"username": "admin", "password": "admin123"}
response = requests.post(
"http://localhost:8082/login",
json=login_data,
timeout=5
)
print(f"Login response status: {response.status_code}")
print(f"Login response: {response.text}")
if response.status_code == 200:
token_data = response.json()
token = token_data.get("token")
print("✅ Successfully authenticated with admin credentials")
# Test API with token
headers = {"Authorization": f"Bearer {token}"}
chat_data = {
"model": "gpt-3.5-turbo",
"messages": [{"role": "user", "content": "Hello from authenticated test!"}],
"max_tokens": 50
}
response = requests.post(
"https://localhost:8443/v1/chat/completions",
json=chat_data,
headers=headers,
verify=False,
timeout=10
)
if response.status_code == 200:
result = response.json()
message = result.get('choices', [{}])[0].get('message', {}).get('content', 'No content')
print(f"✅ Authenticated API working: {message}")
return True
else:
print(f"❌ API call failed: {response.status_code} - {response.text}")
return False
else:
print(f"❌ Authentication failed")
return False
if __name__ == "__main__":
if test_existing_credentials():
print("\n🎉 Platform is fully operational!")
else:
print("\n❌ Authentication issues detected")