import requests import sys import json BASE_URL = "http://localhost:8000" LOGIN_URL = f"{BASE_URL}/de/login" CONFIG_URL = f"{BASE_URL}/admin/config" def test_config_editor(): s = requests.Session() # 1. Login as Admin print("🔑 Logging in as Admin...") res = s.post(LOGIN_URL, data={ "email": "admin@crumb.local", "password": "admin123" }) # 2. Access Config Editor print(f"🛠️ Checking Config Editor ({CONFIG_URL})...") res = s.get(CONFIG_URL) if res.status_code != 200: print(f"❌ Failed to access editor: {res.status_code}") # if 403, role check failed sys.exit(1) if "crumbforest_config.json" in res.text: print("✅ Editor UI loaded") else: print("❌ Editor UI missing title") print(res.text[:500]) # 3. Check for JSON content # Look for a known role like "Eule" inside the textarea content if "Professor Eule" in res.text: print("✅ Config JSON loaded (Found 'Professor Eule')") else: print("❌ Config JSON content missing") print("✨ Admin Config Editor Verified.") if __name__ == "__main__": test_config_editor()