OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
firebase
/
vendor
/
ramsey
/
uuid
/
tests
/
Generator
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
08/12/2024 10:36:11 AM
rwxr-xr-x
📄
CombGeneratorTest.php
4.65 KB
08/12/2024 10:34:38 AM
rw-r--r--
📄
DceSecurityGeneratorTest.php
11.4 KB
08/12/2024 10:34:38 AM
rw-r--r--
📄
DefaultNameGeneratorTest.php
2.48 KB
08/12/2024 10:34:38 AM
rw-r--r--
📄
DefaultTimeGeneratorTest.php
6.88 KB
08/12/2024 10:34:38 AM
rw-r--r--
📄
NameGeneratorFactoryTest.php
464 bytes
08/12/2024 10:34:38 AM
rw-r--r--
📄
PeclUuidNameGeneratorTest.php
3.48 KB
08/12/2024 10:34:38 AM
rw-r--r--
📄
PeclUuidRandomGeneratorTest.php
757 bytes
08/12/2024 10:34:38 AM
rw-r--r--
📄
PeclUuidTimeGeneratorTest.php
747 bytes
08/12/2024 10:34:38 AM
rw-r--r--
📄
RandomBytesGeneratorTest.php
1.89 KB
08/12/2024 10:34:38 AM
rw-r--r--
📄
RandomGeneratorFactoryTest.php
498 bytes
08/12/2024 10:34:38 AM
rw-r--r--
📄
RandomLibAdapterTest.php
2.28 KB
08/12/2024 10:34:38 AM
rw-r--r--
📄
TimeGeneratorFactoryTest.php
1.21 KB
08/12/2024 10:34:38 AM
rw-r--r--
📄
UnixTimeGeneratorTest.php
7.36 KB
08/12/2024 10:34:38 AM
rw-r--r--
Editing: DefaultNameGeneratorTest.php
Close
<?php declare(strict_types=1); namespace Ramsey\Uuid\Test\Generator; use Ramsey\Uuid\Exception\NameException; use Ramsey\Uuid\Generator\DefaultNameGenerator; use Ramsey\Uuid\Test\TestCase; use Ramsey\Uuid\Uuid; use function hash; class DefaultNameGeneratorTest extends TestCase { /** * @param non-empty-string $ns * * @dataProvider provideNamesForHashingTest */ public function testDefaultNameGeneratorHashesName(string $ns, string $name, string $algorithm): void { $namespace = Uuid::fromString($ns); $expectedBytes = hash($algorithm, $namespace->getBytes() . $name, true); $generator = new DefaultNameGenerator(); $this->assertSame($expectedBytes, $generator->generate($namespace, $name, $algorithm)); } /** * @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification */ public function provideNamesForHashingTest(): array { return [ [ 'ns' => Uuid::NAMESPACE_URL, 'name' => 'https://example.com/foobar', 'algorithm' => 'md5', ], [ 'ns' => Uuid::NAMESPACE_URL, 'name' => 'https://example.com/foobar', 'algorithm' => 'sha1', ], [ 'ns' => Uuid::NAMESPACE_URL, 'name' => 'https://example.com/foobar', 'algorithm' => 'sha256', ], [ 'ns' => Uuid::NAMESPACE_OID, 'name' => '1.3.6.1.4.1.343', 'algorithm' => 'sha1', ], [ 'ns' => Uuid::NAMESPACE_OID, 'name' => '1.3.6.1.4.1.52627', 'algorithm' => 'md5', ], [ 'ns' => 'd988ae29-674e-48e7-b93c-2825e2a96fbe', 'name' => 'foobar', 'algorithm' => 'sha1', ], ]; } public function testGenerateThrowsException(): void { $namespace = Uuid::fromString('cd998804-c661-4264-822c-00cada75a87b'); $generator = new DefaultNameGenerator(); $this->expectException(NameException::class); $this->expectExceptionMessage( 'Unable to hash namespace and name with algorithm \'aBadAlgorithm\'' ); $generator->generate($namespace, 'a test name', 'aBadAlgorithm'); } }