Skip to content

Commit

Permalink
remove pointless test rng class
Browse files Browse the repository at this point in the history
we were testing a test class, which didn't make a lot of sense.
  • Loading branch information
NicolasCARPi committed Apr 15, 2024
1 parent e44997c commit f6da6be
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 47 deletions.
13 changes: 3 additions & 10 deletions tests/Providers/Rng/CSRNGProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}
}
}
13 changes: 0 additions & 13 deletions tests/Providers/Rng/IRNGProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
24 changes: 0 additions & 24 deletions tests/Providers/Rng/TestRNGProvider.php

This file was deleted.

0 comments on commit f6da6be

Please sign in to comment.