- Rückmeldungen an den Hersteller (docs/specs/feedback.md): Fehlerbericht und
Funktionswunsch, nur freigeschaltete Wege, Idempotency-Key je Meldung,
Warteschlange mit höchstens fünf Versuchen, 422 am Feld, 429 mit Wartezeit,
404 blendet den Weg aus, Referenznummer und „Meine Rückmeldungen“,
sichtbare technische Angaben und Datenschutzhinweis über dem Absendeknopf
- Hintergrundaufgaben ohne Dauerprozess: Cron, Web-Cron (/cron/{token}) oder
Pseudo-Cron nach dem Seitenaufruf; Queue in kurzen Häppchen
- Seite „Systemzustand“ mit Voraussetzungen, Grenzen, Betrieb, Sicherheit und
Anleitung für den Cronjob
- Web-Installer (Systemprüfung → Datenbank → Administrator), legt .env und
Anwendungsschlüssel selbst an, arbeitet vor der Einrichtung ohne Datenbank
- Datenbank-Benachrichtigungen im Admin-Bereich
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
115 lines
4.3 KiB
PHP
115 lines
4.3 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Models\User;
|
|
use App\Support\Installation;
|
|
use App\Support\License\LicenseStore;
|
|
use App\Support\Settings;
|
|
use App\Support\Update\Filesystem;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Tests\TestCase;
|
|
|
|
class InstallerTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
private string $dir;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->dir = sys_get_temp_dir().'/inhaus-inst-'.bin2hex(random_bytes(4));
|
|
mkdir($this->dir);
|
|
copy(base_path('.env.example'), $this->dir.'/.env');
|
|
$this->app->useEnvironmentPath($this->dir);
|
|
$this->app->instance(LicenseStore::class, new LicenseStore($this->dir.'/license.json'));
|
|
config(['inhaus.installed' => false]);
|
|
}
|
|
|
|
protected function tearDown(): void
|
|
{
|
|
@unlink(storage_path('.installed'));
|
|
Filesystem::deleteDirectory($this->dir);
|
|
|
|
parent::tearDown();
|
|
}
|
|
|
|
public function test_every_page_leads_to_the_installer(): void
|
|
{
|
|
$this->get('/')->assertRedirect('/install');
|
|
$this->get('/login')->assertRedirect('/install');
|
|
$this->get('/install')->assertOk()->assertSee('Systemprüfung')->assertSee('PHP-Version');
|
|
}
|
|
|
|
public function test_wrong_database_credentials_are_explained(): void
|
|
{
|
|
$this->post('/install/datenbank', [
|
|
'host' => config('database.connections.mysql.host'),
|
|
'port' => config('database.connections.mysql.port'),
|
|
'database' => config('database.connections.mysql.database'),
|
|
'username' => 'gibtesnicht',
|
|
'password' => 'falsch',
|
|
])->assertSessionHasErrors(['host' => 'Verbindung fehlgeschlagen: Benutzername oder Passwort sind falsch, oder der Benutzer hat keinen Zugriff auf diese Datenbank.']);
|
|
}
|
|
|
|
public function test_database_settings_are_written_to_env(): void
|
|
{
|
|
$this->post('/install/datenbank', [
|
|
'host' => config('database.connections.mysql.host'),
|
|
'port' => config('database.connections.mysql.port'),
|
|
'database' => config('database.connections.mysql.database'),
|
|
'username' => config('database.connections.mysql.username'),
|
|
'password' => config('database.connections.mysql.password'),
|
|
])->assertRedirect('/install/konto');
|
|
|
|
$env = file_get_contents($this->dir.'/.env');
|
|
$this->assertStringContainsString('DB_DATABASE='.config('database.connections.mysql.database'), $env);
|
|
$this->assertStringContainsString('DB_USERNAME='.config('database.connections.mysql.username'), $env);
|
|
$this->assertStringContainsString('APP_URL='.url('/'), $env);
|
|
}
|
|
|
|
public function test_account_step_completes_the_installation(): void
|
|
{
|
|
$this->post('/install/konto', [
|
|
'portal_name' => 'Caritas-Netz',
|
|
'first_name' => 'Ada',
|
|
'last_name' => 'Admin',
|
|
'email' => 'Ada@Example.com',
|
|
'password' => 'SicheresPasswort1',
|
|
'password_confirmation' => 'SicheresPasswort1',
|
|
'license_email' => 'lizenz@example.com',
|
|
'license_key' => 'KEY-123',
|
|
])->assertRedirect('/login');
|
|
|
|
$admin = User::query()->where('email', 'ada@example.com')->sole();
|
|
$this->assertTrue($admin->is_admin);
|
|
$this->assertSame('Ada Admin', $admin->name);
|
|
$this->assertSame('Caritas-Netz', app(Settings::class)->get('branding.portal_name'));
|
|
$this->assertSame('KEY-123', app(LicenseStore::class)->key());
|
|
$this->assertFileExists(storage_path('.installed'));
|
|
|
|
config(['inhaus.installed' => null]);
|
|
$this->assertTrue(Installation::isInstalled());
|
|
$this->get('/install')->assertNotFound();
|
|
}
|
|
|
|
public function test_weak_admin_password_is_rejected(): void
|
|
{
|
|
$this->post('/install/konto', [
|
|
'portal_name' => 'Portal', 'first_name' => 'A', 'last_name' => 'B', 'email' => 'a@example.com',
|
|
'password' => 'kurz', 'password_confirmation' => 'kurz',
|
|
])->assertSessionHasErrors('password');
|
|
|
|
$this->assertFileDoesNotExist(storage_path('.installed'));
|
|
}
|
|
|
|
public function test_installer_is_gone_once_installed(): void
|
|
{
|
|
config(['inhaus.installed' => true]);
|
|
|
|
$this->get('/install')->assertNotFound();
|
|
$this->post('/install/konto', [])->assertNotFound();
|
|
}
|
|
}
|