From f6da6bee6db93b47a1a27f666543ea01c167cf5b Mon Sep 17 00:00:00 2001 From: Nicolas CARPi Date: Mon, 15 Apr 2024 23:58:37 +0200 Subject: [PATCH] remove pointless test rng class we were testing a test class, which didn't make a lot of sense. --- tests/Providers/Rng/CSRNGProviderTest.php | 13 +++--------- tests/Providers/Rng/IRNGProviderTest.php | 13 ------------ tests/Providers/Rng/TestRNGProvider.php | 24 ----------------------- 3 files changed, 3 insertions(+), 47 deletions(-) delete mode 100644 tests/Providers/Rng/TestRNGProvider.php diff --git a/tests/Providers/Rng/CSRNGProviderTest.php b/tests/Providers/Rng/CSRNGProviderTest.php index abb6488..39739e9 100644 --- a/tests/Providers/Rng/CSRNGProviderTest.php +++ b/tests/Providers/Rng/CSRNGProviderTest.php @@ -11,18 +11,11 @@ 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(); + $rng = new CSRNGProvider(); + foreach ($this->rngTestLengths as $l) { + $this->assertSame($l, strlen($rng->getRandomBytes($l))); } } } diff --git a/tests/Providers/Rng/IRNGProviderTest.php b/tests/Providers/Rng/IRNGProviderTest.php index 743774a..fd2c742 100644 --- a/tests/Providers/Rng/IRNGProviderTest.php +++ b/tests/Providers/Rng/IRNGProviderTest.php @@ -15,17 +15,4 @@ public function testCreateSecret(): void $tfa = new TwoFactorAuth('Test', 6, 30, Algorithm::Sha1, null, null); $this->assertIsString($tfa->createSecret()); } - - public function testCreateSecretGeneratesDesiredAmountOfEntropy(): void - { - $rng = new TestRNGProvider(); - - $tfa = new TwoFactorAuth('Test', 6, 30, Algorithm::Sha1, null, $rng); - $this->assertSame('A', $tfa->createSecret(5)); - $this->assertSame('AB', $tfa->createSecret(6)); - $this->assertSame('ABCDEFGHIJKLMNOPQRSTUVWXYZ', $tfa->createSecret(128)); - $this->assertSame('ABCDEFGHIJKLMNOPQRSTUVWXYZ234567', $tfa->createSecret(160)); - $this->assertSame('ABCDEFGHIJKLMNOPQRSTUVWXYZ234567ABCDEFGHIJKLMNOPQRSTUVWXYZ234567', $tfa->createSecret(320)); - $this->assertSame('ABCDEFGHIJKLMNOPQRSTUVWXYZ234567ABCDEFGHIJKLMNOPQRSTUVWXYZ234567A', $tfa->createSecret(321)); - } } diff --git a/tests/Providers/Rng/TestRNGProvider.php b/tests/Providers/Rng/TestRNGProvider.php deleted file mode 100644 index fd5b591..0000000 --- a/tests/Providers/Rng/TestRNGProvider.php +++ /dev/null @@ -1,24 +0,0 @@ -