Dateien
Hetzner-Backup/test_client_version_check.py
UserIsMH ffc6aa744a Fix version check endpoint authentication
Changed version check endpoints to use X-API-Key authentication instead of Bearer token authentication. This makes them consistent with all other license server endpoints.

Changes:
- Updated /api/version/check to use validate_api_key dependency
- Updated /api/version/latest to use validate_api_key dependency
- Both endpoints now expect X-API-Key header instead of Authorization Bearer
- Fixes HTTP 403 errors reported by client applications

This resolves the issue where session heartbeat worked but version check failed with 403 Forbidden.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-02 21:37:58 +00:00

117 Zeilen
3.7 KiB
Python

#!/usr/bin/env python3
"""
Test version check as a real client would do it
"""
import requests
import json
from datetime import datetime
# API configuration
API_URL = "https://api-software-undso.intelsight.de"
API_KEY = "AF-2025-8E57CA6A97E257C5FA3E7778B8B44413"
def test_client_workflow():
"""Test the complete client workflow: heartbeat + version check"""
print("=" * 60)
print("Client Version Check Workflow Test")
print("=" * 60)
# Simulate a real license key (you'll need to provide a real one for full testing)
license_key = "DEMO-2025-ABCD-EFGH-IJKL"
session_token = "test-session-123"
# 1. Test session heartbeat (simulating what works)
print(f"\n[{datetime.now()}] 1. Testing session heartbeat...")
headers = {
"X-API-Key": API_KEY,
"Content-Type": "application/json"
}
heartbeat_data = {
"session_token": session_token
}
try:
response = requests.post(
f"{API_URL}/api/license/session/heartbeat",
headers=headers,
json=heartbeat_data,
timeout=10
)
print(f"Heartbeat Status: {response.status_code}")
if response.status_code == 200:
print("SUCCESS: Heartbeat works")
else:
print(f"Response: {response.text}")
except Exception as e:
print(f"ERROR: {str(e)}")
# 2. Test version check (what was failing before)
print(f"\n[{datetime.now()}] 2. Testing version check...")
version_data = {
"license_key": license_key,
"current_version": "1.0.0"
}
try:
response = requests.post(
f"{API_URL}/api/version/check",
headers=headers,
json=version_data,
timeout=10
)
print(f"Version Check Status: {response.status_code}")
if response.status_code == 200:
print("SUCCESS: Version check now works with same authentication!")
result = response.json()
print(f"Update Available: {result.get('update_available', False)}")
print(f"Current Version: {result.get('current_version')}")
print(f"Latest Version: {result.get('latest_version')}")
if result.get('update_available'):
print(f"Download URL: {result.get('download_url')}")
print(f"Release Notes: {result.get('release_notes')}")
else:
print(f"Response: {response.text}")
except Exception as e:
print(f"ERROR: {str(e)}")
# 3. Test with different versions to check update detection
print(f"\n[{datetime.now()}] 3. Testing with older version...")
old_version_data = {
"license_key": license_key,
"current_version": "0.9.0"
}
try:
response = requests.post(
f"{API_URL}/api/version/check",
headers=headers,
json=old_version_data,
timeout=10
)
print(f"Old Version Check Status: {response.status_code}")
if response.status_code == 200:
result = response.json()
print(f"Update Available: {result.get('update_available', False)}")
print(f"Is Mandatory: {result.get('is_mandatory', False)}")
print(f"Current: {result.get('current_version')} -> Latest: {result.get('latest_version')}")
else:
print(f"Response: {response.text}")
except Exception as e:
print(f"ERROR: {str(e)}")
print("\n" + "=" * 60)
print("Summary: Version check endpoint now uses X-API-Key authentication")
print(" and is consistent with other license endpoints!")
print("=" * 60)
if __name__ == "__main__":
test_client_workflow()