Some checks failed
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m37s
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m41s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m40s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m42s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 2m10s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 2m6s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 1m55s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 2m2s
CI / Build-Artefakte aktuell (pull_request) Successful in 52s
- OpenID Connect mit PKCE, State und Nonce; ID-Token-Prüfung gegen die Microsoft-Schlüssel (Signatur, Mandant, App, Gültigkeit, Nonce) inkl. Neuladen bei Schlüsselwechsel - Konto bei erster Anmeldung anlegen oder per E-Mail verknüpfen, optionale Domain-Beschränkung, deaktivierte Konten bleiben gesperrt - Gruppen (inkl. Overage über Graph, transitiv) und App-Rollen → Rollen, additiv; nur Zuweisungen aus Entra werden abgeglichen, manuelle bleiben - Profilfelder, Vorgesetzte*r und Profilfoto aus Graph, je Feld wählbar und im Portal schreibgeschützt; Fallback auf Token-Angaben, wenn Graph ausfällt - Hintergrund-Abgleich mit Delta-Abfragen (Zeitbudget, Fortsetzung über nextLink/deltaLink), Offboarding deaktivierter/gelöschter Konten, optionale Vorab-Anlage, Fotos/Vorgesetzte rollierend, Gruppen und App-Rollen stündlich - Admin „Anmeldung“: Einrichtung mit Umleitungs-URI und Berechtigungen, verschlüsseltes Geheimnis (nie im Browser), Gruppensuche, Status, „Mapping testen“ - Fix: @odata.nextLink/@odata.deltaLink wurden als Pfad gelesen – Folgeseiten fehlten - Profilseite mit Vorgesetzter/m und Mitarbeitenden; Version 0.4.0 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
113 lines
3.7 KiB
PHP
113 lines
3.7 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Update;
|
|
|
|
use App\Support\Update\Filesystem;
|
|
use App\Support\Update\InstalledVersion;
|
|
use App\Support\Update\MaintenanceFlag;
|
|
use App\Support\Update\UpdateProgress;
|
|
use InvalidArgumentException;
|
|
use Tests\TestCase;
|
|
|
|
class UpdateStateTest extends TestCase
|
|
{
|
|
private string $dir;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->dir = sys_get_temp_dir().'/inhaus-state-'.bin2hex(random_bytes(4));
|
|
mkdir($this->dir);
|
|
}
|
|
|
|
protected function tearDown(): void
|
|
{
|
|
Filesystem::deleteDirectory($this->dir);
|
|
|
|
parent::tearDown();
|
|
}
|
|
|
|
public function test_sha_is_read_and_written(): void
|
|
{
|
|
$version = new InstalledVersion($this->dir.'/.version');
|
|
|
|
$this->assertNull($version->current());
|
|
$this->assertSame('0.4.0', $version->release());
|
|
$this->assertSame('0.4.0', $version->full());
|
|
|
|
$version->save('A1B2C3D4E5F60718293a4b5c6d7e8f9012345678');
|
|
|
|
$this->assertSame('a1b2c3d4e5f60718293a4b5c6d7e8f9012345678', $version->current());
|
|
$this->assertSame('a1b2c3d', $version->short());
|
|
$this->assertSame('0.4.0 (a1b2c3d)', $version->full());
|
|
}
|
|
|
|
public function test_invalid_sha_is_rejected(): void
|
|
{
|
|
$version = new InstalledVersion($this->dir.'/.version');
|
|
|
|
foreach (['', 'main', 'a1b2c3d', str_repeat('g', 40), str_repeat('a', 41)] as $invalid) {
|
|
try {
|
|
$version->save($invalid);
|
|
$this->fail("„{$invalid}“ hätte abgelehnt werden müssen.");
|
|
} catch (InvalidArgumentException) {
|
|
$this->assertNull($version->current());
|
|
}
|
|
}
|
|
|
|
file_put_contents($this->dir.'/.version', "kaputt\n");
|
|
$this->assertNull($version->current());
|
|
}
|
|
|
|
public function test_maintenance_mode_heals_itself_after_expiry(): void
|
|
{
|
|
$flag = new MaintenanceFlag($this->dir.'/.maintenance');
|
|
|
|
$this->assertFalse($flag->isActive());
|
|
|
|
$flag->activate(600);
|
|
$this->assertTrue($flag->isActive());
|
|
|
|
$flag->deactivate();
|
|
$this->assertFalse($flag->isActive());
|
|
|
|
// Absturz mitten im Update: Flag bleibt liegen, ist aber abgelaufen.
|
|
file_put_contents($this->dir.'/.maintenance', json_encode(['since' => time() - 700, 'until' => time() - 100]));
|
|
$this->assertFalse($flag->isActive());
|
|
$this->assertFileDoesNotExist($this->dir.'/.maintenance');
|
|
|
|
// Kaputte Datei sperrt ebenfalls nicht.
|
|
file_put_contents($this->dir.'/.maintenance', 'Müll');
|
|
$this->assertFalse($flag->isActive());
|
|
}
|
|
|
|
public function test_progress_file_including_error_state(): void
|
|
{
|
|
$progress = new UpdateProgress($this->dir.'/.update-progress');
|
|
|
|
$this->assertSame(['pct' => 0, 'step' => 'idle', 'text' => '', 'ts' => 0], $progress->get());
|
|
$this->assertFalse($progress->isRunning());
|
|
|
|
$progress->set(20, 'download', 'Lädt …');
|
|
$this->assertSame(20, $progress->get()['pct']);
|
|
$this->assertSame('Lädt …', $progress->get()['text']);
|
|
$this->assertTrue($progress->isRunning());
|
|
|
|
$progress->fail('Kaputt');
|
|
$this->assertSame(-1, $progress->get()['pct']);
|
|
$this->assertSame('error', $progress->get()['step']);
|
|
$this->assertFalse($progress->isRunning());
|
|
}
|
|
|
|
public function test_stale_run_does_not_block_forever(): void
|
|
{
|
|
$progress = new UpdateProgress($this->dir.'/.update-progress');
|
|
|
|
file_put_contents($this->dir.'/.update-progress', json_encode([
|
|
'pct' => 50, 'step' => 'extract', 'text' => '', 'ts' => time() - UpdateProgress::STALE_AFTER_SECONDS - 1,
|
|
]));
|
|
|
|
$this->assertFalse($progress->isRunning());
|
|
}
|
|
}
|