actingAsPanelAdmin()->put('/settings', [ 'reset_password' => ['must_change_password' => '1', 'unlock_account' => '1'], 'password_policy' => ['max_age_days' => '30'], 'audit' => ['require_reason' => '1'], ])->assertRedirect(); $entry = AuditLog::query()->where('action', 'config.settings')->latest('id')->first(); $this->assertNotNull($entry); $this->assertSame('tester', $entry->actor); $this->assertSame(30, $entry->context['max_age_days']); $this->assertTrue($entry->context['require_reason']); } public function test_attribute_config_change_is_recorded(): void { $this->actingAsPanelAdmin()->put('/settings/attributes', [ 'attributes' => [ ['key' => 'title', 'label' => 'Stanowisko', 'ldap' => 'title', 'category' => 'org', 'type' => 'text', 'column' => '0'], ], ])->assertRedirect(); $this->assertDatabaseHas('panel_audit', ['action' => 'config.attributes', 'actor' => 'tester']); } public function test_audit_page_renders_and_filters_by_action(): void { AuditLog::create(['actor' => 'alice', 'actor_name' => 'Alice', 'action' => 'user.disable', 'target' => 'jkowalski', 'created_at' => now()]); AuditLog::create(['actor' => 'bob', 'actor_name' => 'Bob', 'action' => 'user.move', 'target' => 'anowak', 'created_at' => now()]); $this->actingAsPanelAdmin()->get('/audit')->assertOk()->assertSee('jkowalski')->assertSee('anowak'); $this->actingAsPanelAdmin()->get('/audit?action=user.disable') ->assertOk() ->assertSee('jkowalski') ->assertDontSee('anowak'); } public function test_audit_page_requires_authentication(): void { $this->get('/audit')->assertRedirect('/login'); } }