35 lines
884 B
PHP
35 lines
884 B
PHP
<?php
|
|
|
|
namespace MintyPHP\Tests\Service\Auth;
|
|
|
|
use MintyPHP\Service\Auth\AuthCryptoGateway;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
final class AuthCryptoGatewayTest extends TestCase
|
|
{
|
|
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
|
|
{
|
|
self::assertTrue($this->gateway->isConfigured());
|
|
}
|
|
|
|
public function testEncryptDecryptDelegatesToCrypto(): void
|
|
{
|
|
$plaintext = 'auth-secret';
|
|
$encrypted = $this->gateway->encryptString($plaintext);
|
|
|
|
self::assertNotSame($plaintext, $encrypted);
|
|
self::assertSame($plaintext, $this->gateway->decryptString($encrypted));
|
|
}
|
|
}
|