Testing und mini Fixes wegen Pfadverschiebung

Dieser Commit ist enthalten in:
2025-06-07 12:44:35 +02:00
Ursprung 9d742fa274
Commit ff1d0feb89
4 geänderte Dateien mit 123 neuen und 2 gelöschten Zeilen

Datei anzeigen

@@ -1,7 +1,15 @@
{
"permissions": {
"allow": [
"Bash(ls:*)"
"Bash(ls:*)",
"Bash(docker-compose ps:*)",
"Bash(docker-compose logs:*)",
"Bash(docker-compose up:*)",
"Bash(mkdir:*)",
"Bash(docker-compose down:*)",
"Bash(docker logs:*)",
"Bash(docker exec:*)",
"Bash(python3:*)"
],
"deny": []
}

Datei anzeigen

@@ -10,7 +10,7 @@ services:
POSTGRES_HOST: postgres
volumes:
# Persistente Speicherung der Datenbank auf dem Windows-Host
- C:/Users/Administrator/Documents/GitHub/v2-Docker/v2_postgreSQL:/var/lib/postgresql/data
- postgres_data:/var/lib/postgresql/data
# Init-Skript für Tabellen
- ../v2_adminpanel/init.sql:/docker-entrypoint-initdb.d/init.sql
networks:
@@ -60,3 +60,6 @@ services:
networks:
internal_net:
driver: bridge
volumes:
postgres_data:

Datei anzeigen

@@ -0,0 +1,53 @@
#!/usr/bin/env python3
import requests
import urllib3
# Disable SSL warnings for self-signed certificate
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
# Test configuration
base_url = "https://localhost:443"
admin_users = [
{"username": "rac00n", "password": "1248163264"},
{"username": "w@rh@mm3r", "password": "Warhammer123!"}
]
def test_login(username, password):
"""Test login functionality for admin user"""
session = requests.Session()
# Get login page
response = session.get(f"{base_url}/login", verify=False)
if response.status_code != 200:
return f"Failed to access login page: {response.status_code}"
# Attempt login
login_data = {
"username": username,
"password": password
}
response = session.post(f"{base_url}/login", data=login_data, verify=False, allow_redirects=False)
# Check if login was successful (redirect to dashboard)
if response.status_code == 302 and response.headers.get('Location') == '/':
# Try to access dashboard
dashboard_response = session.get(f"{base_url}/", verify=False)
if dashboard_response.status_code == 200 and username in dashboard_response.text:
return f"✓ Login successful for {username}"
else:
return f"✗ Login succeeded but dashboard access failed for {username}"
else:
return f"✗ Login failed for {username}"
# Test both admin users
print("Testing Admin Panel Login Functionality")
print("=" * 40)
for user in admin_users:
result = test_login(user["username"], user["password"])
print(result)
print("\nTesting invalid credentials...")
result = test_login("invalid_user", "wrong_password")
print(result)

Datei anzeigen

@@ -0,0 +1,57 @@
#!/usr/bin/env python3
import requests
import urllib3
from datetime import datetime, timedelta
# Disable SSL warnings for self-signed certificate
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
# Test configuration
base_url = "https://localhost:443"
admin_user = {"username": "rac00n", "password": "1248163264"}
def test_license_creation():
"""Test creating a license through the admin panel"""
session = requests.Session()
# Login first
login_data = {
"username": admin_user["username"],
"password": admin_user["password"]
}
response = session.post(f"{base_url}/login", data=login_data, verify=False, allow_redirects=False)
if response.status_code != 302:
return "Failed to login"
# Create a test license
license_data = {
"customer_name": "Test Customer",
"email": "test@example.com",
"license_key": "TEST-LICENSE-KEY-123",
"license_type": "premium",
"valid_from": datetime.now().strftime("%Y-%m-%d"),
"valid_until": (datetime.now() + timedelta(days=365)).strftime("%Y-%m-%d")
}
response = session.post(f"{base_url}/", data=license_data, verify=False, allow_redirects=False)
if response.status_code == 302 and response.headers.get('Location') == '/':
return "✓ License created successfully"
else:
return f"✗ Failed to create license: {response.status_code}"
print("Testing License Creation")
print("=" * 40)
result = test_license_creation()
print(result)
# Verify the license was created in the database
import subprocess
result = subprocess.run([
"docker", "exec", "db", "psql", "-U", "adminuser", "-d", "meinedatenbank",
"-c", "SELECT c.name, l.license_key, l.license_type, l.valid_from, l.valid_until FROM licenses l JOIN customers c ON l.customer_id = c.id;"
], capture_output=True, text=True)
print("\nLicenses in database:")
print(result.stdout)