initial commit

This commit is contained in:
TheOnlyMace
2026-05-17 13:26:14 +02:00
commit 75299b723d
176 changed files with 20327 additions and 0 deletions

View File

@@ -0,0 +1,78 @@
<?php
namespace Tests\Unit;
use App\Services\Hosting\Traefik\TraefikGenerator;
use Illuminate\Support\Facades\File;
use Tests\TestCase;
class TraefikGeneratorTest extends TestCase
{
private string $configPath;
protected function setUp(): void
{
parent::setUp();
$this->configPath = storage_path('framework/testing/traefik-customers.yaml');
config(['hosting.traefik.dynamic_config_path' => $this->configPath]);
if (File::exists($this->configPath)) {
File::delete($this->configPath);
}
}
protected function tearDown(): void
{
if (File::exists($this->configPath)) {
File::delete($this->configPath);
}
parent::tearDown();
}
public function test_adds_customer_route_with_tls(): void
{
$generator = app(TraefikGenerator::class);
$generator->addCustomerRoute('kunde1.hexahost.de', '10.12.10.11');
$yaml = File::get($this->configPath);
$this->assertStringContainsString('kunde1.hexahost.de', $yaml);
$this->assertStringContainsString('10.12.10.11', $yaml);
$this->assertStringContainsString('letsencrypt', $yaml);
$this->assertStringContainsString('websecure', $yaml);
}
public function test_preserves_existing_non_managed_routes(): void
{
File::ensureDirectoryExists(dirname($this->configPath));
File::put($this->configPath, <<<'YAML'
http:
routers:
admin-panel:
rule: "Host(`admin.example.com`)"
service: admin-panel
services:
admin-panel:
loadBalancer:
servers:
- url: "http://127.0.0.1:8080"
YAML);
$generator = app(TraefikGenerator::class);
$generator->addCustomerRoute('kunde1.hexahost.de', '10.12.10.12');
$yaml = File::get($this->configPath);
$this->assertStringContainsString('admin-panel', $yaml);
$this->assertStringContainsString('kunde1.hexahost.de', $yaml);
}
public function test_rejects_invalid_domain(): void
{
$this->expectException(\App\Exceptions\Hosting\TraefikException::class);
app(TraefikGenerator::class)->addCustomerRoute('not a domain!', '10.12.10.11');
}
}