2026-03-13 13:57:33 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace MintyPHP\Tests\Service\Auth;
|
|
|
|
|
|
|
|
|
|
use MintyPHP\Service\Auth\AuthCryptoGateway;
|
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
2026-03-19 19:36:17 +01:00
|
|
|
final class AuthCryptoGatewayTest extends TestCase
|
2026-03-13 13:57:33 +01:00
|
|
|
{
|
|
|
|
|
private AuthCryptoGateway $gateway;
|
|
|
|
|
|
|
|
|
|
protected function setUp(): void
|
|
|
|
|
{
|
|
|
|
|
if (!defined('APP_CRYPTO_KEY')) {
|
|
|
|
|
define('APP_CRYPTO_KEY', str_repeat('ab', 32));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->gateway = new AuthCryptoGateway();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testIsConfiguredReturnsTrueWhenKeyIsSet(): void
|
|
|
|
|
{
|
2026-03-19 19:36:17 +01:00
|
|
|
self::assertTrue($this->gateway->isConfigured());
|
2026-03-13 13:57:33 +01:00
|
|
|
}
|
|
|
|
|
|
2026-03-19 19:36:17 +01:00
|
|
|
public function testEncryptDecryptDelegatesToCrypto(): void
|
2026-03-13 13:57:33 +01:00
|
|
|
{
|
2026-03-19 19:36:17 +01:00
|
|
|
$plaintext = 'auth-secret';
|
2026-03-13 13:57:33 +01:00
|
|
|
$encrypted = $this->gateway->encryptString($plaintext);
|
|
|
|
|
|
2026-03-19 19:36:17 +01:00
|
|
|
self::assertNotSame($plaintext, $encrypted);
|
|
|
|
|
self::assertSame($plaintext, $this->gateway->decryptString($encrypted));
|
2026-03-13 13:57:33 +01:00
|
|
|
}
|
|
|
|
|
}
|