2022-01-05 17:44:02 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace App\Test\Fixture;
|
|
|
|
|
|
|
|
use Cake\TestSuite\Fixture\TestFixture;
|
|
|
|
use Authentication\PasswordHasher\DefaultPasswordHasher;
|
|
|
|
|
|
|
|
class AuthKeysFixture extends TestFixture
|
|
|
|
{
|
|
|
|
public $connection = 'test';
|
|
|
|
|
2022-01-18 17:39:41 +01:00
|
|
|
public const ADMIN_API_ID = 1;
|
2022-01-07 13:45:52 +01:00
|
|
|
public const ADMIN_API_KEY = 'd033e22ae348aeb5660fc2140aec35850c4da997';
|
2022-01-18 17:39:41 +01:00
|
|
|
|
|
|
|
|
|
|
|
public const SYNC_API_ID = 2;
|
2022-01-07 13:45:52 +01:00
|
|
|
public const SYNC_API_KEY = '6b387ced110858dcbcda36edb044dc18f91a0894';
|
2022-01-18 17:39:41 +01:00
|
|
|
|
|
|
|
|
|
|
|
public const ORG_ADMIN_API_ID = 3;
|
2022-01-07 13:45:52 +01:00
|
|
|
public const ORG_ADMIN_API_KEY = '1c4685d281d478dbcebd494158024bc3539004d0';
|
2022-01-18 17:39:41 +01:00
|
|
|
|
|
|
|
public const REGULAR_USER_API_ID = 4;
|
2022-01-10 11:58:52 +01:00
|
|
|
public const REGULAR_USER_API_KEY = '12dea96fec20593566ab75692c9949596833adc9';
|
2022-01-05 17:44:02 +01:00
|
|
|
|
|
|
|
public function init(): void
|
|
|
|
{
|
|
|
|
$hasher = new DefaultPasswordHasher();
|
2022-01-07 13:45:52 +01:00
|
|
|
$faker = \Faker\Factory::create();
|
2022-01-05 17:44:02 +01:00
|
|
|
|
|
|
|
$this->records = [
|
|
|
|
[
|
2022-01-18 17:39:41 +01:00
|
|
|
'id' => self::ADMIN_API_ID,
|
2022-01-07 13:45:52 +01:00
|
|
|
'uuid' => $faker->uuid(),
|
2022-01-05 17:44:02 +01:00
|
|
|
'authkey' => $hasher->hash(self::ADMIN_API_KEY),
|
2022-01-07 13:45:52 +01:00
|
|
|
'authkey_start' => substr(self::ADMIN_API_KEY, 0, 4),
|
|
|
|
'authkey_end' => substr(self::ADMIN_API_KEY, -4),
|
2022-01-05 17:44:02 +01:00
|
|
|
'expiration' => 0,
|
2022-01-07 13:45:52 +01:00
|
|
|
'user_id' => UsersFixture::USER_ADMIN_ID,
|
2022-01-05 17:44:02 +01:00
|
|
|
'comment' => '',
|
2022-01-07 13:45:52 +01:00
|
|
|
'created' => $faker->dateTime()->getTimestamp(),
|
|
|
|
'modified' => $faker->dateTime()->getTimestamp()
|
|
|
|
],
|
|
|
|
[
|
2022-01-18 17:39:41 +01:00
|
|
|
'id' => self::SYNC_API_ID,
|
2022-01-07 13:45:52 +01:00
|
|
|
'uuid' => $faker->uuid(),
|
|
|
|
'authkey' => $hasher->hash(self::SYNC_API_KEY),
|
|
|
|
'authkey_start' => substr(self::SYNC_API_KEY, 0, 4),
|
|
|
|
'authkey_end' => substr(self::SYNC_API_KEY, -4),
|
|
|
|
'expiration' => 0,
|
|
|
|
'user_id' => UsersFixture::USER_SYNC_ID,
|
|
|
|
'comment' => '',
|
|
|
|
'created' => $faker->dateTime()->getTimestamp(),
|
|
|
|
'modified' => $faker->dateTime()->getTimestamp()
|
|
|
|
],
|
|
|
|
[
|
2022-01-18 17:39:41 +01:00
|
|
|
'id' => self::ORG_ADMIN_API_ID,
|
2022-01-07 13:45:52 +01:00
|
|
|
'uuid' => $faker->uuid(),
|
|
|
|
'authkey' => $hasher->hash(self::ORG_ADMIN_API_KEY),
|
|
|
|
'authkey_start' => substr(self::ORG_ADMIN_API_KEY, 0, 4),
|
|
|
|
'authkey_end' => substr(self::ORG_ADMIN_API_KEY, -4),
|
|
|
|
'expiration' => 0,
|
|
|
|
'user_id' => UsersFixture::USER_ORG_ADMIN_ID,
|
|
|
|
'comment' => '',
|
|
|
|
'created' => $faker->dateTime()->getTimestamp(),
|
|
|
|
'modified' => $faker->dateTime()->getTimestamp()
|
|
|
|
],
|
|
|
|
[
|
2022-01-18 17:39:41 +01:00
|
|
|
'id' => self::REGULAR_USER_API_ID,
|
2022-01-07 13:45:52 +01:00
|
|
|
'uuid' => $faker->uuid(),
|
2022-01-10 11:58:52 +01:00
|
|
|
'authkey' => $hasher->hash(self::REGULAR_USER_API_KEY),
|
|
|
|
'authkey_start' => substr(self::REGULAR_USER_API_KEY, 0, 4),
|
|
|
|
'authkey_end' => substr(self::REGULAR_USER_API_KEY, -4),
|
2022-01-07 13:45:52 +01:00
|
|
|
'expiration' => 0,
|
|
|
|
'user_id' => UsersFixture::USER_REGULAR_USER_ID,
|
|
|
|
'comment' => '',
|
|
|
|
'created' => $faker->dateTime()->getTimestamp(),
|
|
|
|
'modified' => $faker->dateTime()->getTimestamp()
|
2022-01-05 17:44:02 +01:00
|
|
|
]
|
|
|
|
];
|
|
|
|
parent::init();
|
|
|
|
}
|
|
|
|
}
|