From ff1d0feb89c8df13ab9676e2b59ff0d7563d9106 Mon Sep 17 00:00:00 2001 From: UserIsMH Date: Sat, 7 Jun 2025 12:44:35 +0200 Subject: [PATCH] Testing und mini Fixes wegen Pfadverschiebung --- .claude/settings.local.json | 10 ++++- v2/docker-compose.yaml | 5 ++- v2_testing/test_admin_login.py | 53 +++++++++++++++++++++++++++ v2_testing/test_license_creation.py | 57 +++++++++++++++++++++++++++++ 4 files changed, 123 insertions(+), 2 deletions(-) create mode 100644 v2_testing/test_admin_login.py create mode 100644 v2_testing/test_license_creation.py diff --git a/.claude/settings.local.json b/.claude/settings.local.json index 1d2f67b..bbf35b2 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -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": [] } diff --git a/v2/docker-compose.yaml b/v2/docker-compose.yaml index a83981c..9535713 100644 --- a/v2/docker-compose.yaml +++ b/v2/docker-compose.yaml @@ -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: diff --git a/v2_testing/test_admin_login.py b/v2_testing/test_admin_login.py new file mode 100644 index 0000000..b165029 --- /dev/null +++ b/v2_testing/test_admin_login.py @@ -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) \ No newline at end of file diff --git a/v2_testing/test_license_creation.py b/v2_testing/test_license_creation.py new file mode 100644 index 0000000..d14f649 --- /dev/null +++ b/v2_testing/test_license_creation.py @@ -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) \ No newline at end of file