- sentry/sentry-laravel 4.28; config/sentry.php gehaertet (keine PII, keine Request-Bodys, before_send ErrorReportScrubber) - Handler: Integration::captureUnhandledException, CommandNotFoundException nicht melden - ReportErrorSignals (global): toter interner Link (nach Pfad wegen Catch-all-Route), 403/429 fuer Angemeldete, 419; gedrosselt - Browser: selbst gehostetes SDK (esbuild-Bundle 11.5.0), Loader ohne Build-Schritt und ohne Regex-Lookbehind, in 7 Layouts mit area-Tag - phpunit.xml: DSNs und ntfy-URL leer, CACHE_DRIVER=array (Tests schrieben bisher in den lokalen Datei-Cache) - dev/glitch-tip/README.md mit Instanz, Org, Projekt-IDs, API-Auswertung Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
79 lines
2.2 KiB
PHP
79 lines
2.2 KiB
PHP
<?php
|
|
|
|
use App\Models\UserAccount;
|
|
use App\Services\Monitoring\HealthProbe;
|
|
use App\User;
|
|
use Tests\TestCase;
|
|
|
|
uses(TestCase::class);
|
|
|
|
/**
|
|
* Systemstatus unter Sysadmin (my.mivita.care/sysadmin/status). Die
|
|
* CRM-Routen werden host-abhängig geladen, daher startet die App mit dem
|
|
* CRM-Host neu.
|
|
*/
|
|
beforeEach(function () {
|
|
$this->previousHttpHost = $_SERVER['HTTP_HOST'] ?? null;
|
|
$_SERVER['HTTP_HOST'] = config('domains.domains.crm.host');
|
|
$this->refreshApplication();
|
|
$this->artisan('migrate');
|
|
config()->set('cache.default', 'array');
|
|
config()->set('queue.default', 'sync');
|
|
@unlink(HealthProbe::heartbeatPath());
|
|
});
|
|
|
|
afterEach(function () {
|
|
@unlink(HealthProbe::heartbeatPath());
|
|
|
|
if ($this->previousHttpHost === null) {
|
|
unset($_SERVER['HTTP_HOST']);
|
|
} else {
|
|
$_SERVER['HTTP_HOST'] = $this->previousHttpHost;
|
|
}
|
|
});
|
|
|
|
function statusPageUser(int $admin): User
|
|
{
|
|
$account = UserAccount::create([
|
|
'first_name' => 'Sys',
|
|
'last_name' => 'Admin',
|
|
'm_first_name' => 'Sys',
|
|
'm_last_name' => 'Admin',
|
|
'm_account' => 'M'.random_int(1000, 9999),
|
|
]);
|
|
|
|
return User::forceCreate([
|
|
'email' => 'sys-'.uniqid('', true).'@example.com',
|
|
'password' => bcrypt('secret'),
|
|
'lang' => 'de',
|
|
'active' => 1,
|
|
'blocked' => 0,
|
|
'wizard' => 100,
|
|
'admin' => $admin,
|
|
'payment_account' => now()->addYear(),
|
|
'account_id' => $account->id,
|
|
])->fresh();
|
|
}
|
|
|
|
test('system admins see the checks, the version and the menu entry', function () {
|
|
config()->set('app.version', 'v1.0.2');
|
|
config()->set('monitoring.health.token', null);
|
|
app(HealthProbe::class)->recordHeartbeat();
|
|
|
|
$this->actingAs(statusPageUser(4))
|
|
->get(route('sysadmin_status'))
|
|
->assertOk()
|
|
->assertSee('Systemstatus')
|
|
->assertSee('Datenbank')
|
|
->assertSee('Scheduler')
|
|
->assertSee('Fehlgeschlagene Jobs')
|
|
->assertSee('v1.0.2')
|
|
->assertSee(route('sysadmin_status'), false)
|
|
->assertSee('Kein Token');
|
|
});
|
|
|
|
test('other admins are not allowed to open the page', function () {
|
|
$this->actingAs(statusPageUser(3))
|
|
->get(route('sysadmin_status'))
|
|
->assertForbidden();
|
|
});
|