It appears that the repository has undergone several changes and renamings:
This commit is contained in:
69
tests/test_admin_live.py
Normal file
69
tests/test_admin_live.py
Normal file
@@ -0,0 +1,69 @@
|
||||
#!/usr/bin/env python3.11
|
||||
"""
|
||||
Live-Test für das Admin-Dashboard über HTTP
|
||||
"""
|
||||
|
||||
import requests
|
||||
import sys
|
||||
|
||||
def test_admin_dashboard():
|
||||
"""Testet das Admin-Dashboard über HTTP"""
|
||||
|
||||
base_url = "http://127.0.0.1:5000"
|
||||
|
||||
print("=== LIVE ADMIN DASHBOARD TEST ===")
|
||||
|
||||
# Session für Cookies
|
||||
session = requests.Session()
|
||||
|
||||
try:
|
||||
# 1. Test ohne Login
|
||||
print("\n1. Test ohne Login:")
|
||||
response = session.get(f"{base_url}/admin/")
|
||||
print(f" Status: {response.status_code}")
|
||||
if response.status_code == 302:
|
||||
print(f" Redirect zu: {response.headers.get('Location', 'Unknown')}")
|
||||
|
||||
# 2. Login versuchen
|
||||
print("\n2. Login-Versuch:")
|
||||
login_data = {
|
||||
'username': 'admin',
|
||||
'password': 'admin123'
|
||||
}
|
||||
|
||||
# Erst Login-Seite aufrufen für CSRF-Token
|
||||
login_page = session.get(f"{base_url}/auth/login")
|
||||
print(f" Login-Seite Status: {login_page.status_code}")
|
||||
|
||||
# Login durchführen
|
||||
login_response = session.post(f"{base_url}/auth/login", data=login_data)
|
||||
print(f" Login Status: {login_response.status_code}")
|
||||
|
||||
if login_response.status_code == 302:
|
||||
print(f" Login Redirect: {login_response.headers.get('Location', 'Unknown')}")
|
||||
|
||||
# 3. Admin-Dashboard nach Login
|
||||
print("\n3. Admin-Dashboard nach Login:")
|
||||
admin_response = session.get(f"{base_url}/admin/")
|
||||
print(f" Status: {admin_response.status_code}")
|
||||
|
||||
if admin_response.status_code == 200:
|
||||
print(" ✅ SUCCESS: Admin-Dashboard lädt erfolgreich!")
|
||||
print(f" Content-Length: {len(admin_response.text)} Zeichen")
|
||||
elif admin_response.status_code == 302:
|
||||
print(f" Redirect zu: {admin_response.headers.get('Location', 'Unknown')}")
|
||||
elif admin_response.status_code == 500:
|
||||
print(" ❌ ERROR: 500 Internal Server Error")
|
||||
print(f" Response: {admin_response.text[:500]}...")
|
||||
else:
|
||||
print(f" Unerwarteter Status: {admin_response.status_code}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"\n❌ FEHLER: {e}")
|
||||
return False
|
||||
|
||||
return admin_response.status_code == 200
|
||||
|
||||
if __name__ == "__main__":
|
||||
success = test_admin_dashboard()
|
||||
sys.exit(0 if success else 1)
|
Reference in New Issue
Block a user