deutsche Zeit statt UTC

Dieser Commit ist enthalten in:
2025-06-08 20:21:58 +02:00
Ursprung f9e5823eeb
Commit f269082115
19 geänderte Dateien mit 1411 neuen und 31 gelöschten Zeilen

Datei anzeigen

@@ -0,0 +1,10 @@
{
"permissions": {
"allow": [
"Bash(python3:*)",
"Bash(pip install:*)",
"Bash(pip3 install:*)"
],
"deny": []
}
}

104
v2_testing/test_audit_raw.py Normale Datei
Datei anzeigen

@@ -0,0 +1,104 @@
#!/usr/bin/env python3
import requests
import urllib3
from datetime import datetime
from zoneinfo import ZoneInfo
from bs4 import BeautifulSoup
import time
# Disable SSL warnings for self-signed certificate
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
# Test configuration
base_url = "https://admin-panel-undso.z5m7q9dk3ah2v1plx6ju.com"
fallback_url = "https://localhost:443"
admin_user = {"username": "rac00n", "password": "1248163264"}
def test_audit_raw():
"""Test audit log timezone by parsing HTML"""
session = requests.Session()
print("Audit Log Raw HTML Test")
print("=" * 50)
# Test connection
try:
test_response = session.get(base_url, verify=True, timeout=5)
verify_ssl = True
base_url_local = base_url
print(f"✓ Using external URL: {base_url}")
except:
base_url_local = fallback_url
verify_ssl = False
print(f" Using fallback URL: {fallback_url}")
# Show current times
utc_now = datetime.now(ZoneInfo("UTC"))
berlin_now = datetime.now(ZoneInfo("Europe/Berlin"))
print(f"\nCurrent times:")
print(f" UTC: {utc_now.strftime('%Y-%m-%d %H:%M:%S')}")
print(f" Berlin: {berlin_now.strftime('%Y-%m-%d %H:%M:%S')}")
# Logout first
session.get(f"{base_url_local}/logout", verify=verify_ssl)
time.sleep(1)
# Login
response = session.get(f"{base_url_local}/login", verify=verify_ssl)
login_data = {
"username": admin_user["username"],
"password": admin_user["password"]
}
response = session.post(f"{base_url_local}/login", data=login_data, verify=verify_ssl, allow_redirects=False)
if response.status_code != 302:
print(f"✗ Login failed")
return
print("✓ Login successful")
# Get audit log
print("\nFetching audit log...")
response = session.get(f"{base_url_local}/audit", verify=verify_ssl)
if response.status_code == 200:
# Save raw HTML for inspection
with open("audit_log_raw.html", "w", encoding="utf-8") as f:
f.write(response.text)
print("✓ Saved raw HTML to audit_log_raw.html")
# Parse with BeautifulSoup
soup = BeautifulSoup(response.text, 'html.parser')
# Find all table rows
rows = soup.find_all('tr')
print(f"✓ Found {len(rows)} table rows")
# Look for LOGIN_SUCCESS in recent entries
for i, row in enumerate(rows[:5]): # Check first 5 rows
cells = row.find_all('td')
if cells and len(cells) > 1:
timestamp_cell = cells[0].text.strip()
action_cell = cells[2].text.strip() if len(cells) > 2 else ""
if i == 0:
print(f"\nFirst row details:")
print(f" Timestamp: {timestamp_cell}")
print(f" Action: {action_cell}")
if "LOGIN_SUCCESS" in action_cell:
print(f"\nFound LOGIN_SUCCESS entry:")
print(f" Timestamp: {timestamp_cell}")
# Check if timestamp contains current Berlin hour
if berlin_now.strftime("%H:") in timestamp_cell:
print(f" ✓ Contains Berlin hour ({berlin_now.strftime('%H:')})")
elif utc_now.strftime("%H:") in timestamp_cell:
print(f" ✗ Contains UTC hour ({utc_now.strftime('%H:')})")
break
else:
print(f"✗ Failed to fetch audit log: {response.status_code}")
if __name__ == "__main__":
test_audit_raw()

Datei anzeigen

@@ -0,0 +1,113 @@
#!/usr/bin/env python3
import requests
import urllib3
from datetime import datetime
from zoneinfo import ZoneInfo
import time
import re
# Disable SSL warnings for self-signed certificate
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
# Test configuration
base_url = "https://admin-panel-undso.z5m7q9dk3ah2v1plx6ju.com"
fallback_url = "https://localhost:443"
admin_user = {"username": "rac00n", "password": "1248163264"}
def test_audit_simple():
"""Simple test to check audit log timestamps"""
session = requests.Session()
print("Audit Log Timezone Check")
print("=" * 50)
# Test connection
try:
test_response = session.get(base_url, verify=True, timeout=5)
verify_ssl = True
base_url_local = base_url
print(f"✓ Using external URL: {base_url}")
except:
base_url_local = fallback_url
verify_ssl = False
print(f" Using fallback URL: {fallback_url}")
# Show current times
utc_now = datetime.now(ZoneInfo("UTC"))
berlin_now = datetime.now(ZoneInfo("Europe/Berlin"))
print(f"\nCurrent times:")
print(f" UTC: {utc_now.strftime('%Y-%m-%d %H:%M:%S')}")
print(f" Berlin: {berlin_now.strftime('%Y-%m-%d %H:%M:%S')}")
print(f" Difference: {(berlin_now.hour - utc_now.hour) % 24} hours")
# Login
response = session.get(f"{base_url_local}/login", verify=verify_ssl)
login_data = {
"username": admin_user["username"],
"password": admin_user["password"]
}
response = session.post(f"{base_url_local}/login", data=login_data, verify=verify_ssl, allow_redirects=False)
if response.status_code != 302:
print(f"✗ Login failed")
return
print("✓ Login successful")
# Create a distinctive action to find in audit log
print("\nCreating a test action...")
# Try to access customers page (this will create an audit entry)
response = session.get(f"{base_url_local}/customers", verify=verify_ssl)
# Now check audit log
print("\nChecking audit log...")
response = session.get(f"{base_url_local}/audit", verify=verify_ssl)
if response.status_code == 200:
# Look for table rows with class="table"
# Extract just the table content
table_match = re.search(r'<table class="table[^>]*>(.*?)</table>', response.text, re.DOTALL)
if table_match:
table_content = table_match.group(1)
# Find all <tr> tags
rows = re.findall(r'<tr[^>]*>(.*?)</tr>', table_content, re.DOTALL)
print(f"✓ Found {len(rows)} audit log entries")
if rows:
# Get the first data row (skip header)
first_row = rows[1] if len(rows) > 1 else rows[0]
# Extract timestamp from first cell
timestamp_match = re.search(r'<td[^>]*>([^<]+)</td>', first_row)
if timestamp_match:
timestamp = timestamp_match.group(1).strip()
print(f"\nMost recent audit entry timestamp: {timestamp}")
# Check if it contains current Berlin hour
berlin_hour = berlin_now.strftime("%H:")
utc_hour = utc_now.strftime("%H:")
if berlin_hour in timestamp:
print(f"✓ Timestamp contains Berlin hour ({berlin_hour})")
print("✓ Audit log is using Berlin timezone!")
elif utc_hour in timestamp:
print(f"✗ Timestamp contains UTC hour ({utc_hour})")
print("✗ Audit log is still using UTC")
print("\nTo fix this:")
print("1. cd ../v2")
print("2. docker-compose down")
print("3. docker-compose build --no-cache")
print("4. docker-compose up -d")
else:
print("⚠ Could not determine timezone from timestamp")
else:
print(f"✗ Failed to fetch audit log: {response.status_code}")
if __name__ == "__main__":
test_audit_simple()

Datei anzeigen

@@ -0,0 +1,123 @@
#!/usr/bin/env python3
import requests
import urllib3
from datetime import datetime
from zoneinfo import ZoneInfo
import time
import re
# Disable SSL warnings for self-signed certificate
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
# Test configuration
base_url = "https://admin-panel-undso.z5m7q9dk3ah2v1plx6ju.com"
fallback_url = "https://localhost:443"
admin_user = {"username": "rac00n", "password": "1248163264"}
def test_audit_timezone():
"""Test audit log timezone specifically"""
session = requests.Session()
print("Audit Log Timezone Test")
print("=" * 50)
# Test connection
try:
test_response = session.get(base_url, verify=True, timeout=5)
verify_ssl = True
base_url_local = base_url
print(f"✓ Using external URL: {base_url}")
except:
base_url_local = fallback_url
verify_ssl = False
print(f" Using fallback URL: {fallback_url}")
# Show current times
utc_now = datetime.now(ZoneInfo("UTC"))
berlin_now = datetime.now(ZoneInfo("Europe/Berlin"))
print(f"\nCurrent times:")
print(f" UTC: {utc_now.strftime('%Y-%m-%d %H:%M:%S')}")
print(f" Berlin: {berlin_now.strftime('%Y-%m-%d %H:%M:%S')}")
print(f" Offset: +{(berlin_now.hour - utc_now.hour) % 24} hours")
# First logout if already logged in
session.get(f"{base_url_local}/logout", verify=verify_ssl)
time.sleep(1)
# Login (this will create a new audit log entry)
print(f"\nPerforming login at {berlin_now.strftime('%H:%M:%S')} Berlin time...")
response = session.get(f"{base_url_local}/login", verify=verify_ssl)
if response.status_code != 200:
print(f"✗ Failed to access login page: {response.status_code}")
return
login_data = {
"username": admin_user["username"],
"password": admin_user["password"]
}
response = session.post(f"{base_url_local}/login", data=login_data, verify=verify_ssl, allow_redirects=False)
if response.status_code != 302:
print(f"✗ Login failed: {response.status_code}")
return
print("✓ Login successful")
# Immediately check audit log
print("\nChecking audit log for fresh LOGIN_SUCCESS entry...")
response = session.get(f"{base_url_local}/audit", verify=verify_ssl)
if response.status_code == 200:
# Look for timestamps in the audit log
# Pattern to find timestamps in format YYYY-MM-DD HH:MM:SS
timestamp_pattern = r'(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})'
# Find all timestamps
timestamps = re.findall(timestamp_pattern, response.text)
if timestamps:
print(f"✓ Found {len(timestamps)} timestamps in audit log")
# Check the most recent timestamp (should be first in list)
if timestamps:
latest_timestamp = timestamps[0]
print(f"\nMost recent timestamp: {latest_timestamp}")
# Extract hour from timestamp
hour_match = re.search(r' (\d{2}):', latest_timestamp)
if hour_match:
log_hour = int(hour_match.group(1))
berlin_hour = berlin_now.hour
utc_hour = utc_now.hour
print(f" Timestamp hour: {log_hour:02d}")
print(f" Berlin hour: {berlin_hour:02d}")
print(f" UTC hour: {utc_hour:02d}")
if log_hour == berlin_hour:
print("\n✓ Audit log is using Berlin time!")
elif log_hour == utc_hour:
print("\n✗ Audit log appears to be using UTC time")
print(" → Docker containers may need to be rebuilt")
else:
print("\n⚠ Could not determine timezone (timestamp doesn't match either timezone)")
else:
print("✗ No timestamps found in audit log")
# Also check for "vor X Minuten" text which might indicate timezone
if "vor 0 Minuten" in response.text or "vor 1 Minute" in response.text:
print("\n✓ Recent entries found (German time format)")
else:
print(f"✗ Failed to access audit log: {response.status_code}")
print("\n" + "=" * 50)
print("If timestamps show UTC instead of Berlin time:")
print("1. Run: docker-compose down")
print("2. Run: docker-compose build --no-cache")
print("3. Run: docker-compose up -d")
if __name__ == "__main__":
test_audit_timezone()

159
v2_testing/test_timezone.py Normale Datei
Datei anzeigen

@@ -0,0 +1,159 @@
#!/usr/bin/env python3
import requests
import urllib3
from datetime import datetime
from zoneinfo import ZoneInfo
import json
import time
# Disable SSL warnings for self-signed certificate
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
# Test configuration
# Use external URL for testing
base_url = "https://admin-panel-undso.z5m7q9dk3ah2v1plx6ju.com"
# Fallback to localhost if external URL is not accessible
fallback_url = "https://localhost:443"
admin_user = {"username": "rac00n", "password": "1248163264"}
def test_timezone_functionality():
"""Test if timestamps are in German timezone (Europe/Berlin)"""
session = requests.Session()
print("Testing Timezone Functionality (Europe/Berlin)")
print("=" * 50)
# Test connection to external URL first
global base_url
try:
test_response = session.get(base_url, verify=True, timeout=5)
print(f"✓ Using external URL: {base_url}")
except:
base_url = fallback_url
print(f" Using fallback URL: {base_url}")
# Get current time in UTC and Berlin
utc_now = datetime.now(ZoneInfo("UTC"))
berlin_now = datetime.now(ZoneInfo("Europe/Berlin"))
print(f"Current UTC time: {utc_now.strftime('%Y-%m-%d %H:%M:%S %Z')}")
print(f"Current Berlin time: {berlin_now.strftime('%Y-%m-%d %H:%M:%S %Z')}")
print(f"Time difference: {(berlin_now.hour - utc_now.hour) % 24} hours")
print()
# Login
verify_ssl = base_url != fallback_url # Verify SSL for external URL only
response = session.get(f"{base_url}/login", verify=verify_ssl)
if response.status_code != 200:
print(f"✗ Failed to access login page: {response.status_code}")
return
login_data = {
"username": admin_user["username"],
"password": admin_user["password"]
}
response = session.post(f"{base_url}/login", data=login_data, verify=verify_ssl, allow_redirects=False)
if response.status_code != 302:
print(f"✗ Login failed: {response.status_code}")
return
print("✓ Login successful")
print()
# Test 1: Create a test license to check created_at timestamp
print("Test 1: Creating test license to check timestamps...")
# First, get a customer ID or create one
license_data = {
"customer_select": "new",
"customer_name": f"Timezone Test Customer {int(time.time())}",
"customer_email": f"timezone-test-{int(time.time())}@example.com",
"license_key": f"AF-{berlin_now.strftime('%Y%m')}T-TEST-TIME-ZONE",
"license_type": "test",
"max_sessions": "1",
"start_date": berlin_now.strftime("%Y-%m-%d"),
"duration": "1",
"duration_unit": "days"
}
response = session.post(f"{base_url}/create", data=license_data, verify=verify_ssl)
if response.status_code == 200:
print("✓ Test license created")
else:
print(f"✗ Failed to create license: {response.status_code}")
# Test 2: Check audit log for timezone
print("\nTest 2: Checking audit log timestamps...")
response = session.get(f"{base_url}/audit", verify=verify_ssl)
if response.status_code == 200:
# Extract the most recent audit log entry timestamp from HTML
if "CREATE" in response.text and license_data["license_key"] in response.text:
print("✓ Audit log entry created")
# Check if timestamps in audit log appear to be in German time
# This is a simple check - in production you'd parse the HTML properly
current_hour = berlin_now.strftime("%H:")
if current_hour in response.text:
print(f"✓ Audit log shows Berlin time (contains {current_hour})")
else:
print(f"⚠ Audit log might show UTC time (doesn't contain {current_hour})")
else:
print(f"✗ Failed to access audit log: {response.status_code}")
# Test 3: Check backup functionality for filename timezone
print("\nTest 3: Testing backup filename timezone...")
response = session.post(f"{base_url}/backup/create", verify=verify_ssl)
if response.status_code == 302: # Redirect after backup
print("✓ Backup created")
# Check backup list
response = session.get(f"{base_url}/backups", verify=verify_ssl)
if response.status_code == 200:
# Check if backup filename contains current Berlin hour
berlin_hour = berlin_now.strftime("%H")
if f"_{berlin_hour}" in response.text:
print(f"✓ Backup filename uses Berlin time (contains hour {berlin_hour})")
else:
utc_hour = utc_now.strftime("%H")
if f"_{utc_hour}" in response.text:
print(f"✗ Backup filename might use UTC time (contains hour {utc_hour})")
else:
print("⚠ Could not determine timezone from backup filename")
else:
print(f"✗ Failed to create backup: {response.status_code}")
# Test 4: Check session timestamps
print("\nTest 4: Checking session timestamps...")
response = session.get(f"{base_url}/sessions", verify=verify_ssl)
if response.status_code == 200:
print("✓ Accessed sessions page")
# Active sessions should show current time
if "Keine aktiven Sessions" not in response.text:
print("✓ Session data available")
else:
print(" No active sessions to check (this is normal)")
else:
print(f"✗ Failed to access sessions: {response.status_code}")
# Test 5: Database timezone check
print("\nTest 5: Summary")
print("-" * 30)
time_diff = (berlin_now.hour - utc_now.hour) % 24
if time_diff == 1:
print("✓ Timezone offset is +1 hour (CET - Central European Time)")
elif time_diff == 2:
print("✓ Timezone offset is +2 hours (CEST - Central European Summer Time)")
else:
print(f"⚠ Unexpected timezone offset: {time_diff} hours")
print("\nNote: All new timestamps should be in Europe/Berlin timezone")
print("Existing data might still show UTC until updated")
if __name__ == "__main__":
test_timezone_functionality()

Datei anzeigen

@@ -0,0 +1,122 @@
#!/usr/bin/env python3
import requests
import urllib3
from datetime import datetime
from zoneinfo import ZoneInfo
import re
# Disable SSL warnings for self-signed certificate
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
# Test configuration
base_url = "https://admin-panel-undso.z5m7q9dk3ah2v1plx6ju.com"
fallback_url = "https://localhost:443"
admin_user = {"username": "rac00n", "password": "1248163264"}
def test_timezone_simple():
"""Simple test to verify timezone is Europe/Berlin"""
session = requests.Session()
print("Timezone Verification Test (Europe/Berlin)")
print("=" * 50)
# Test connection
try:
test_response = session.get(base_url, verify=True, timeout=5)
verify_ssl = True
print(f"✓ Using external URL: {base_url}")
except:
base_url_local = fallback_url
verify_ssl = False
print(f" Using fallback URL: {fallback_url}")
else:
base_url_local = base_url
# Show current times
utc_now = datetime.now(ZoneInfo("UTC"))
berlin_now = datetime.now(ZoneInfo("Europe/Berlin"))
print(f"\nCurrent times:")
print(f" UTC: {utc_now.strftime('%Y-%m-%d %H:%M:%S')}")
print(f" Berlin: {berlin_now.strftime('%Y-%m-%d %H:%M:%S')}")
# Calculate offset
time_diff = (berlin_now.hour - utc_now.hour) % 24
if berlin_now.day != utc_now.day:
# Handle day boundary
if berlin_now.day > utc_now.day:
time_diff = (berlin_now.hour + 24 - utc_now.hour) % 24
else:
time_diff = (berlin_now.hour - utc_now.hour - 24) % 24
print(f" Offset: +{time_diff} hours")
# Login
response = session.get(f"{base_url_local}/login", verify=verify_ssl)
if response.status_code != 200:
print(f"\n✗ Failed to access login page: {response.status_code}")
return
login_data = {
"username": admin_user["username"],
"password": admin_user["password"]
}
response = session.post(f"{base_url_local}/login", data=login_data, verify=verify_ssl, allow_redirects=False)
if response.status_code != 302:
print(f"\n✗ Login failed: {response.status_code}")
return
print(f"\n✓ Login successful")
# Check dashboard for any timestamps
print("\nChecking for timestamps in dashboard...")
response = session.get(f"{base_url_local}/", verify=verify_ssl)
if response.status_code == 200:
# Look for time patterns in dashboard
time_pattern = r'\d{2}:\d{2}:\d{2}'
times_found = re.findall(time_pattern, response.text)
if times_found:
print(f"✓ Found {len(times_found)} timestamps in dashboard")
# Check if any match current Berlin hour
berlin_hour = berlin_now.strftime("%H:")
if any(berlin_hour in time for time in times_found):
print(f"✓ Timestamps appear to use Berlin time (found {berlin_hour}xx)")
else:
print(f" Could not confirm timezone from timestamps")
else:
print(" No timestamps found in dashboard")
# Check audit log
print("\nChecking audit log for LOGIN timestamp...")
response = session.get(f"{base_url_local}/audit", verify=verify_ssl)
if response.status_code == 200:
# Extract the most recent LOGIN entry
if "LOGIN_SUCCESS" in response.text:
# Look for timestamp near LOGIN_SUCCESS
berlin_time_str = berlin_now.strftime("%Y-%m-%d %H:")
if berlin_time_str in response.text:
print(f"✓ Audit log shows Berlin time (contains {berlin_time_str}xx)")
else:
utc_time_str = utc_now.strftime("%Y-%m-%d %H:")
if utc_time_str in response.text:
print(f"✗ Audit log might show UTC time (contains {utc_time_str}xx)")
else:
print(f" Could not determine timezone from audit log")
# Summary
print("\n" + "=" * 50)
print("Summary:")
if time_diff == 1:
print("✓ System timezone offset: +1 hour (CET - Winter time)")
elif time_diff == 2:
print("✓ System timezone offset: +2 hours (CEST - Summer time)")
else:
print(f"⚠ Unexpected timezone offset: +{time_diff} hours")
print("\nNote: The system should use Europe/Berlin timezone for all new data.")
print("Existing data created before the timezone change may still show UTC.")
if __name__ == "__main__":
test_timezone_simple()