Setzt Phase 1 aus Visualization.md um: Vanilla-PHP-REST-API mit SQLite-Persistenz, statischen API-Keys pro Agent, Codeberg-Sync fuer Backlog/Done, PHPUnit-Tests und vollstaendiger API.md-Dokumentation - Vorgaben aus Detailantworten.md (F1-F16) umgesetzt. Entwicklung/Build/Test laufen komplett in Docker-Compose-Containern (PHP 8.2 + SQLite + Composer + PHPUnit/pcov), analog zum NC-Gantt-Projekt ist auf dem Host kein PHP/Composer noetig. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
28 lines
724 B
PHP
28 lines
724 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Monitor\Api\Tests\Auth;
|
|
|
|
use Monitor\Api\Auth\ApiKeyGenerator;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
final class ApiKeyGeneratorTest extends TestCase
|
|
{
|
|
public function testGenerateProducesUnique64CharHexKeys(): void
|
|
{
|
|
$a = ApiKeyGenerator::generate();
|
|
$b = ApiKeyGenerator::generate();
|
|
|
|
self::assertMatchesRegularExpression('/^[0-9a-f]{64}$/', $a);
|
|
self::assertNotSame($a, $b);
|
|
}
|
|
|
|
public function testHashIsDeterministicSha256(): void
|
|
{
|
|
$key = 'test-key';
|
|
|
|
self::assertSame(hash('sha256', $key), ApiKeyGenerator::hash($key));
|
|
self::assertSame(ApiKeyGenerator::hash($key), ApiKeyGenerator::hash($key));
|
|
}
|
|
}
|