Anbindung Shinkan, Übungsverwaltung #7

Merged
Lars merged 34 commits from develop into main 2026-11-23 19:10:35 +01:00
2 changed files with 23 additions and 1 deletions
Showing only changes of commit e5b3eea7de - Show all commits

No files matched your search

+10 -1
View File
@@ -27,7 +27,16 @@ public function url(): ?string
{
$value = config('services.shinkan.url');
return is_string($value) && trim($value) !== '' ? rtrim(trim($value), '/') : null;
if (! is_string($value) || trim($value) === '') {
return null;
}
// Die Adresse ist die der Shinkan-Installation. Der Pfad `/api/distribution/v1` hängt der Abruf selbst an; wer ihn
// (oder nur `/api`) mit einträgt, bekommt trotzdem die richtige Adresse und keinen doppelten Pfad.
$base = rtrim(trim($value), '/');
$base = (string) preg_replace('#/api(/distribution(/v1)?)?$#', '', $base);
return $base === '' ? null : $base;
}
public function apiKey(): ?string
+13
View File
@@ -452,6 +452,19 @@ public function test_the_key_from_the_server_environment_wins_and_an_existing_co
$this->assertFalse(app(ShinkanImport::class)->configured());
}
public function test_the_address_may_name_the_installation_or_its_api_path_without_doubling_the_path(): void
{
foreach (['https://dev.shinkan.jinkendo.de', 'https://dev.shinkan.jinkendo.de/', 'https://dev.shinkan.jinkendo.de/api', 'https://dev.shinkan.jinkendo.de/api/', 'https://dev.shinkan.jinkendo.de/api/distribution/v1'] as $configured) {
config(['services.shinkan.url' => $configured]);
$this->freshHttp();
Http::fake(['dev.shinkan.jinkendo.de/*' => Http::response(['exercises' => [], 'changes' => [], 'next_cursor' => 'c'])]);
$this->assertTrue(app(ShinkanImport::class)->check()['ok'], $configured);
Http::assertSent(fn ($request): bool => $request->url() === 'https://dev.shinkan.jinkendo.de/api/distribution/v1/catalog'
&& $request->hasHeader('Authorization', 'Bearer geheim-fuer-den-test'));
}
}
public function test_the_exercise_list_leads_to_the_takeover_page(): void
{
Livewire::actingAs($this->staff('redakteur'), 'staff')