create(); $company = Company::factory()->presseecho()->create(); $category = Category::factory()->withTranslations()->create(); $user->companies()->attach($company->id, ['role' => 'owner']); Sanctum::actingAs($user, ['press-releases:read', 'press-releases:write']); $createResponse = $this->postJson('/api/v1/press-releases', [ 'company_id' => $company->id, 'category_id' => $category->id, 'language' => 'de', 'title' => 'Neue API Pressemitteilung', 'text' => 'Inhalt der Pressemitteilung', 'status' => 'draft', ]); $createResponse ->assertCreated() ->assertJsonPath('data.title', 'Neue API Pressemitteilung') ->assertJsonPath('data.portal', 'presseecho'); $pressReleaseId = PressRelease::withoutGlobalScopes() ->where('title', 'Neue API Pressemitteilung') ->value('id'); $this->getJson('/api/v1/press-releases') ->assertOk() ->assertJsonPath('data.0.id', $pressReleaseId); $this->patchJson("/api/v1/press-releases/{$pressReleaseId}", [ 'title' => 'Aktualisierte API Pressemitteilung', ]) ->assertOk() ->assertJsonPath('data.title', 'Aktualisierte API Pressemitteilung'); $this->deleteJson("/api/v1/press-releases/{$pressReleaseId}") ->assertNoContent(); expect(PressRelease::withoutGlobalScopes()->withTrashed()->find($pressReleaseId)?->trashed())->toBeTrue(); }); test('api submitted html text is sanitized before persistence', function () { /** * Regression zu Befund M6 (Audit 14.07.2026): Über die API eingereichtes * HTML muss – wie im Web-Formular – vor der Speicherung durch den Sanitizer. */ /** @var TestCase $this */ $user = User::factory()->create(); $company = Company::factory()->presseecho()->create(); $category = Category::factory()->withTranslations()->create(); $user->companies()->attach($company->id, ['role' => 'owner']); Sanctum::actingAs($user, ['press-releases:read', 'press-releases:write']); $this->postJson('/api/v1/press-releases', [ 'company_id' => $company->id, 'category_id' => $category->id, 'language' => 'de', 'title' => 'XSS Versuch', 'text' => '
Sauber
x', 'status' => 'draft', ])->assertCreated(); $stored = PressRelease::withoutGlobalScopes()->where('title', 'XSS Versuch')->firstOrFail(); expect($stored->text) ->not->toContain('