Files
nextcloud-server-mirror/apps/admin_audit/tests/Actions/VersionsTest.php
Ghassen kefi 3d9abd7a68 feat(admin_audit): log structured parameters with audit entries
Audit entries now carry the parameters they are built from as a nested
"params" object in their data (e.g. data.params.shareWith), so log
consumers no longer need to parse the human-readable message. Numbers
and booleans keep their type. Parameters are left out when the call
asks for obfuscation.

The audit logger requests a custom logger with structured context, so
only audit.log is affected.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Ghassen kefi <ghassen.kefi.dev@gmail.com>
2026-10-13 14:41:55 +02:00

36 lines
951 B
PHP

<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\AdminAudit\Tests\Actions;
use OCA\AdminAudit\Actions\Versions;
use OCA\AdminAudit\IAuditLogger;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class VersionsTest extends TestCase {
private IAuditLogger&MockObject $logger;
private Versions $versions;
protected function setUp(): void {
parent::setUp();
$this->logger = $this->createMock(IAuditLogger::class);
$this->versions = new Versions($this->logger);
}
public function testDelete(): void {
$this->logger->expects($this->once())
->method('info')
->with('Version "/a.txt.v1700000000" was deleted.', ['app' => 'admin_audit', 'operation' => 'versions.version.deleted', 'params' => ['path' => '/a.txt.v1700000000']]);
$this->versions->delete(['path' => '/a.txt.v1700000000']);
}
}