Update random ID method to use str_random and not random_bytes
The use of random_bytes in combination with bin2hex was producing a lot of duplicate keys when tested in batches of 10k (anywhere from 2 to 6). The use of str_random yielded no duplicates even at scales of 100k keys that were 8 characters.
This commit is contained in:
parent
0e518be6ca
commit
a8c4d6afdb
14 changed files with 50 additions and 59 deletions
|
@ -61,12 +61,12 @@ class NodeCreationServiceTest extends TestCase
|
|||
*/
|
||||
public function testNodeIsCreatedAndDaemonSecretIsGenerated()
|
||||
{
|
||||
$this->getFunctionMock('\\Pterodactyl\\Services\\Nodes', 'bin2hex')
|
||||
->expects($this->once())->willReturn('hexResult');
|
||||
$this->getFunctionMock('\\Pterodactyl\\Services\\Nodes', 'str_random')
|
||||
->expects($this->once())->willReturn('random_string');
|
||||
|
||||
$this->repository->shouldReceive('create')->with([
|
||||
'name' => 'NodeName',
|
||||
'daemonSecret' => 'hexResult',
|
||||
'daemonSecret' => 'random_string',
|
||||
])->once()->andReturnNull();
|
||||
|
||||
$this->assertNull($this->service->handle(['name' => 'NodeName']));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue