ADconsole v1.0.0
First public release. - docs: document the audit log, user offboarding, CSV export and the "require a reason for destructive actions" setting across README, docs/ and CLAUDE/AGENTS.md; note retention for panel_audit - docs: fill the publishing placeholders (repo URL, security contact, issue-template links) and add a semantic-versioning policy - move agent/contributor context into CLAUDE/ (AGENTS.md + a README); root CLAUDE.md is now a thin @-import pointer - add a favicon (shield-lock, matching the login screen) to the login page and the app layout - CHANGELOG: promote [Unreleased] to [1.0.0]; keep the earlier internal build as [0.1.0] Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UfuvfwexztdS7LDpGuKsuK
This commit is contained in:
commit
1126d96271
174 files changed
+27113
No files matched your search
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Services\AttributeCipher;
|
||||
use App\Services\PanelSettingsService;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AttributeCipherTest extends TestCase
|
||||
{
|
||||
private function cipher(string $key): AttributeCipher
|
||||
{
|
||||
$settings = new class($key) extends PanelSettingsService
|
||||
{
|
||||
public function __construct(private string $k)
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function encryptionKey(): string
|
||||
{
|
||||
return $this->k;
|
||||
}
|
||||
};
|
||||
|
||||
return new AttributeCipher($settings);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function it_round_trips_a_value_when_a_key_is_configured(): void
|
||||
{
|
||||
$cipher = $this->cipher('TajneHaslo123');
|
||||
|
||||
$encrypted = $cipher->encrypt('p.zielinski.secret');
|
||||
|
||||
$this->assertNotSame('p.zielinski.secret', $encrypted);
|
||||
$this->assertSame('p.zielinski.secret', $cipher->decrypt($encrypted));
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function it_does_not_re_encrypt_an_already_encrypted_value(): void
|
||||
{
|
||||
$cipher = $this->cipher('TajneHaslo123');
|
||||
$encrypted = $cipher->encrypt('abc');
|
||||
|
||||
$this->assertSame($encrypted, $cipher->encrypt($encrypted));
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function it_passes_values_through_unchanged_when_no_key_is_configured(): void
|
||||
{
|
||||
$cipher = $this->cipher('');
|
||||
|
||||
$this->assertSame('abc', $cipher->encrypt('abc'));
|
||||
$this->assertSame('abc', $cipher->decrypt('abc'));
|
||||
$this->assertFalse($cipher->isConfigured());
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function it_returns_the_raw_value_when_it_cannot_be_decrypted(): void
|
||||
{
|
||||
$cipher = $this->cipher('TajneHaslo123');
|
||||
|
||||
// Wartość nie w naszym formacie (np. wpisana ręcznie / inny klucz).
|
||||
$this->assertSame('not-our-ciphertext', $cipher->decrypt('not-our-ciphertext'));
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function null_and_empty_values_are_left_alone(): void
|
||||
{
|
||||
$cipher = $this->cipher('TajneHaslo123');
|
||||
|
||||
$this->assertNull($cipher->encrypt(null));
|
||||
$this->assertSame('', $cipher->encrypt(''));
|
||||
$this->assertNull($cipher->decrypt(null));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user