update 20.10.2025
This commit is contained in:
parent
8c11130b5d
commit
a939cd51ef
616 changed files with 84821 additions and 4121 deletions
298
dev/subdomain-optimization-claude-v2/TESTING.md
Normal file
298
dev/subdomain-optimization-claude-v2/TESTING.md
Normal file
|
|
@ -0,0 +1,298 @@
|
|||
# Testing Guide - Claude v2 Subdomain Resolver
|
||||
|
||||
## 🧪 Umfassende Test-Szenarien
|
||||
|
||||
### Vorbereitung
|
||||
|
||||
```bash
|
||||
# Test-UserShop in Datenbank erstellen (falls nicht vorhanden)
|
||||
php artisan tinker
|
||||
```
|
||||
|
||||
```php
|
||||
// In Tinker:
|
||||
$user = App\User::first(); // Oder einen bestimmten User
|
||||
$shop = new App\Models\UserShop();
|
||||
$shop->slug = 'testuser';
|
||||
$shop->name = 'Test User Shop';
|
||||
$shop->user_id = $user->id;
|
||||
$shop->active = 1;
|
||||
$shop->save();
|
||||
```
|
||||
|
||||
## 🌐 Domain-spezifische Tests
|
||||
|
||||
### 1. User-Shop Subdomain Tests
|
||||
|
||||
#### Test 1.1: Gültiger User-Shop
|
||||
```bash
|
||||
# Request simulieren
|
||||
curl -v -H "Host: testuser.mivita.care" http://localhost/
|
||||
|
||||
# Erwartete Ergebnisse:
|
||||
# ✅ HTTP 200 Response
|
||||
# ✅ Shop-spezifische Inhalte werden geladen
|
||||
# ✅ Session enthält user_shop-Daten
|
||||
```
|
||||
|
||||
#### Test 1.2: Ungültiger User-Shop
|
||||
```bash
|
||||
curl -v -H "Host: nonexistent.mivita.care" http://localhost/
|
||||
|
||||
# Erwartete Ergebnisse:
|
||||
# ✅ HTTP 301 Redirect zu mivita.care
|
||||
```
|
||||
|
||||
#### Test 1.3: Inaktiver User-Shop
|
||||
```bash
|
||||
# Shop deaktivieren in DB
|
||||
php artisan tinker
|
||||
# UserShop::where('slug', 'testuser')->update(['active' => 0]);
|
||||
|
||||
curl -v -H "Host: testuser.mivita.care" http://localhost/
|
||||
|
||||
# Erwartete Ergebnisse:
|
||||
# ✅ HTTP 503 Service Unavailable
|
||||
```
|
||||
|
||||
### 2. Main-Shop Domain Tests
|
||||
|
||||
#### Test 2.1: Main-Shop (mivita.shop)
|
||||
```bash
|
||||
curl -v -H "Host: mivita.shop" http://localhost/
|
||||
|
||||
# Erwartete Ergebnisse:
|
||||
# ✅ HTTP 200 Response
|
||||
# ✅ Default-Shop (aloevera) wird geladen
|
||||
# ✅ Session enthält user_shop mit aloevera-Daten
|
||||
```
|
||||
|
||||
### 3. Main-Care Domain Tests
|
||||
|
||||
#### Test 3.1: Main-Care (mivita.care)
|
||||
```bash
|
||||
curl -v -H "Host: mivita.care" http://localhost/
|
||||
|
||||
# Erwartete Ergebnisse:
|
||||
# ✅ HTTP 200 Response
|
||||
# ✅ Keine user_shop-Daten in Session
|
||||
# ✅ Corporate/Info-Seiten werden geladen
|
||||
```
|
||||
|
||||
### 4. Unknown Domain Tests
|
||||
|
||||
#### Test 4.1: Unbekannte Domain
|
||||
```bash
|
||||
curl -v -H "Host: unknown.example.com" http://localhost/
|
||||
|
||||
# Erwartete Ergebnisse:
|
||||
# ✅ HTTP 301 Redirect zu mivita.care
|
||||
```
|
||||
|
||||
## 🛒 Warenkorb-Tests
|
||||
|
||||
### Test 5.1: Warenkorb auf User-Shop
|
||||
```bash
|
||||
# 1. User-Shop aufrufen
|
||||
curl -c cookies.txt -H "Host: testuser.mivita.care" http://localhost/
|
||||
|
||||
# 2. Produkt zum Warenkorb hinzufügen
|
||||
curl -b cookies.txt -H "Host: testuser.mivita.care" \
|
||||
-d "product_id=1&quantity=1" \
|
||||
http://localhost/cart/add
|
||||
|
||||
# 3. Warenkorb anzeigen
|
||||
curl -b cookies.txt -H "Host: testuser.mivita.care" http://localhost/cart
|
||||
|
||||
# Erwartete Ergebnisse:
|
||||
# ✅ Produkt wird erfolgreich hinzugefügt
|
||||
# ✅ Warenkorb zeigt Produkt an
|
||||
# ✅ Session-Daten bleiben erhalten
|
||||
```
|
||||
|
||||
### Test 5.2: Warenkorb auf Main-Shop
|
||||
```bash
|
||||
# Gleiche Tests wie 5.1, aber mit "Host: mivita.shop"
|
||||
```
|
||||
|
||||
## 📱 Session-Tests
|
||||
|
||||
### Test 6.1: Session-Persistenz bei User-Shop
|
||||
```bash
|
||||
# Browser-Session simulieren mit Cookie-Handling
|
||||
session_file=$(mktemp)
|
||||
|
||||
# 1. Erste Anfrage - Session erstellen
|
||||
curl -c "$session_file" -H "Host: testuser.mivita.care" http://localhost/
|
||||
|
||||
# 2. Zweite Anfrage - Session verwenden
|
||||
curl -b "$session_file" -H "Host: testuser.mivita.care" http://localhost/profile
|
||||
|
||||
# Erwartete Ergebnisse:
|
||||
# ✅ Session-ID bleibt gleich
|
||||
# ✅ user_shop-Daten bleiben erhalten
|
||||
```
|
||||
|
||||
### Test 6.2: Session-Domain-Konfiguration
|
||||
```php
|
||||
// In Browser-Entwicklertools oder via Code:
|
||||
// Session-Cookies sollten die richtige Domain haben:
|
||||
|
||||
// Für testuser.mivita.care:
|
||||
// Session-Cookie-Domain: .mivita.care
|
||||
|
||||
// Für mivita.shop:
|
||||
// Session-Cookie-Domain: .mivita.shop
|
||||
```
|
||||
|
||||
## 🔗 URL-Generation Tests
|
||||
|
||||
### Test 7.1: URL-Helper auf User-Shop
|
||||
```php
|
||||
// Test in Blade-Template oder Controller:
|
||||
|
||||
// Auf testuser.mivita.care sollte route('home') zurückgeben:
|
||||
// https://testuser.mivita.care/
|
||||
|
||||
// config('app.url') sollte sein:
|
||||
// https://testuser.mivita.care
|
||||
```
|
||||
|
||||
### Test 7.2: URL-Helper auf Main-Shop
|
||||
```php
|
||||
// Auf mivita.shop sollte route('home') zurückgeben:
|
||||
// https://mivita.shop/
|
||||
```
|
||||
|
||||
## ⚡ Performance Tests
|
||||
|
||||
### Test 8.1: Asset-Request-Filtering
|
||||
```bash
|
||||
# CSS/JS/Image requests sollten übersprungen werden
|
||||
curl -H "Host: testuser.mivita.care" http://localhost/css/app.css
|
||||
|
||||
# Erwartete Ergebnisse:
|
||||
# ✅ Middleware wird NICHT ausgeführt (Performance)
|
||||
# ✅ Datei wird direkt serviert
|
||||
```
|
||||
|
||||
### Test 8.2: API-Request-Filtering
|
||||
```bash
|
||||
# API requests sollten übersprungen werden
|
||||
curl -H "Host: testuser.mivita.care" http://localhost/api/products
|
||||
|
||||
# Erwartete Ergebnisse:
|
||||
# ✅ Middleware wird NICHT ausgeführt
|
||||
# ✅ API funktioniert normal
|
||||
```
|
||||
|
||||
## 🚨 Error-Handling Tests
|
||||
|
||||
### Test 9.1: Database Connection Error
|
||||
```bash
|
||||
# Datenbank temporär deaktivieren und testen
|
||||
# (Simuliere DB-Ausfall)
|
||||
|
||||
curl -H "Host: testuser.mivita.care" http://localhost/
|
||||
|
||||
# Erwartete Ergebnisse:
|
||||
# ✅ Graceful Error-Handling
|
||||
# ✅ Redirect zu Hauptdomain oder 503 Error
|
||||
```
|
||||
|
||||
## 📋 Automatisierte Test-Suite
|
||||
|
||||
### Test-Script erstellen
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
# test-subdomain-resolver.sh
|
||||
|
||||
echo "=== Testing Claude v2 Subdomain Resolver ==="
|
||||
|
||||
# Test 1: User Shop
|
||||
echo "Test 1: User Shop (testuser.mivita.care)"
|
||||
response=$(curl -s -o /dev/null -w "%{http_code}" -H "Host: testuser.mivita.care" http://localhost/)
|
||||
if [ "$response" = "200" ]; then
|
||||
echo "✅ User Shop: PASS"
|
||||
else
|
||||
echo "❌ User Shop: FAIL ($response)"
|
||||
fi
|
||||
|
||||
# Test 2: Main Shop
|
||||
echo "Test 2: Main Shop (mivita.shop)"
|
||||
response=$(curl -s -o /dev/null -w "%{http_code}" -H "Host: mivita.shop" http://localhost/)
|
||||
if [ "$response" = "200" ]; then
|
||||
echo "✅ Main Shop: PASS"
|
||||
else
|
||||
echo "❌ Main Shop: FAIL ($response)"
|
||||
fi
|
||||
|
||||
# Test 3: Main Care
|
||||
echo "Test 3: Main Care (mivita.care)"
|
||||
response=$(curl -s -o /dev/null -w "%{http_code}" -H "Host: mivita.care" http://localhost/)
|
||||
if [ "$response" = "200" ]; then
|
||||
echo "✅ Main Care: PASS"
|
||||
else
|
||||
echo "❌ Main Care: FAIL ($response)"
|
||||
fi
|
||||
|
||||
# Test 4: Unknown Domain (should redirect)
|
||||
echo "Test 4: Unknown Domain (should redirect)"
|
||||
response=$(curl -s -o /dev/null -w "%{http_code}" -H "Host: unknown.example.com" http://localhost/)
|
||||
if [ "$response" = "301" ]; then
|
||||
echo "✅ Unknown Domain: PASS"
|
||||
else
|
||||
echo "❌ Unknown Domain: FAIL ($response)"
|
||||
fi
|
||||
|
||||
echo "=== Testing Complete ==="
|
||||
```
|
||||
|
||||
## 🔍 Debug-Tests
|
||||
|
||||
### Test 10.1: Session-Debug
|
||||
```php
|
||||
// In Controller oder Route:
|
||||
Route::get('/debug-session', function() {
|
||||
return [
|
||||
'host' => request()->getHost(),
|
||||
'session_domain' => config('session.domain'),
|
||||
'app_url' => config('app.url'),
|
||||
'user_shop' => session('user_shop'),
|
||||
'user_shop_domain' => session('user_shop_domain'),
|
||||
'session_id' => session()->getId(),
|
||||
];
|
||||
});
|
||||
```
|
||||
|
||||
### Test 10.2: Domain-Parsing-Debug
|
||||
```php
|
||||
// Temporärer Debug-Route:
|
||||
Route::get('/debug-domain/{host}', function($host) {
|
||||
$resolver = new \App\Http\Middleware\SubdomainResolver();
|
||||
$reflection = new ReflectionClass($resolver);
|
||||
$method = $reflection->getMethod('parseDomain');
|
||||
$method->setAccessible(true);
|
||||
|
||||
return $method->invoke($resolver, $host);
|
||||
});
|
||||
```
|
||||
|
||||
## ✅ Erfolgs-Checkliste
|
||||
|
||||
Nach allen Tests sollten folgende Punkte erfüllt sein:
|
||||
|
||||
- [ ] User-Shop Subdomains laden korrekt
|
||||
- [ ] Main-Shop Domain funktioniert
|
||||
- [ ] Main-Care Domain funktioniert
|
||||
- [ ] Unbekannte Domains werden umgeleitet
|
||||
- [ ] Warenkorb funktioniert auf allen Domains
|
||||
- [ ] Sessions bleiben bestehen
|
||||
- [ ] URLs werden korrekt generiert
|
||||
- [ ] Asset-Requests werden übersprungen
|
||||
- [ ] API-Requests werden übersprungen
|
||||
- [ ] Fehlerbehandlung funktioniert graceful
|
||||
- [ ] Performance ist akzeptabel
|
||||
- [ ] Keine Session-Timing-Issues
|
||||
- [ ] Checkout-Prozess funktioniert
|
||||
Loading…
Add table
Add a link
Reference in a new issue