Files
TwoFactorAuth/tests/Providers/Rng/CSRNGProviderTest.php
T
Nicolas CARPi d1792f07d1 remove insecure rng providers
and remove the openssl provider. We now rely exclusively on
random_bytes(), as there are no reasons not to. Fix #121
2024-04-15 23:28:45 +02:00

29 lines
661 B
PHP

<?php
declare(strict_types=1);
namespace Tests\Providers\Rng;
use PHPUnit\Framework\TestCase;
use RobThree\Auth\Providers\Rng\CSRNGProvider;
class CSRNGProviderTest extends TestCase
{
use NeedsRngLengths;
/**
* @requires function random_bytes
*/
public function testCSRNGProvidersReturnExpectedNumberOfBytes(): void
{
if (function_exists('random_bytes')) {
$rng = new CSRNGProvider();
foreach ($this->rngTestLengths as $l) {
$this->assertSame($l, strlen($rng->getRandomBytes($l)));
}
} else {
$this->expectNotToPerformAssertions();
}
}
}