More test suite coverage
This commit is contained in:
parent
8908a758ca
commit
774c9680a3
14 changed files with 373 additions and 46 deletions
|
@ -83,7 +83,7 @@ class DaemonKeyProviderService
|
|||
['server_id', '=', $server],
|
||||
]);
|
||||
|
||||
if (! $updateIfExpired || max($this->carbon->now()->diffInSeconds($key->expires_at, false), 0) > 0) {
|
||||
if (! $updateIfExpired || $this->carbon->now()->diffInSeconds($key->expires_at, false) > 0) {
|
||||
return $key->secret;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,22 +10,22 @@
|
|||
namespace Pterodactyl\Services\Helpers;
|
||||
|
||||
use Illuminate\Contracts\Hashing\Hasher;
|
||||
use Illuminate\Database\DatabaseManager;
|
||||
use Illuminate\Config\Repository as ConfigRepository;
|
||||
use Illuminate\Database\ConnectionInterface;
|
||||
use Illuminate\Contracts\Config\Repository as ConfigRepository;
|
||||
|
||||
class TemporaryPasswordService
|
||||
{
|
||||
const HMAC_ALGO = 'sha256';
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Config\Repository
|
||||
* @var \Illuminate\Contracts\Config\Repository
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Database\DatabaseManager
|
||||
* @var \Illuminate\Database\ConnectionInterface
|
||||
*/
|
||||
protected $database;
|
||||
protected $connection;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Hashing\Hasher
|
||||
|
@ -35,17 +35,17 @@ class TemporaryPasswordService
|
|||
/**
|
||||
* TemporaryPasswordService constructor.
|
||||
*
|
||||
* @param \Illuminate\Config\Repository $config
|
||||
* @param \Illuminate\Database\DatabaseManager $database
|
||||
* @param \Illuminate\Contracts\Hashing\Hasher $hasher
|
||||
* @param \Illuminate\Contracts\Config\Repository $config
|
||||
* @param \Illuminate\Database\ConnectionInterface $connection
|
||||
* @param \Illuminate\Contracts\Hashing\Hasher $hasher
|
||||
*/
|
||||
public function __construct(
|
||||
ConfigRepository $config,
|
||||
DatabaseManager $database,
|
||||
ConnectionInterface $connection,
|
||||
Hasher $hasher
|
||||
) {
|
||||
$this->config = $config;
|
||||
$this->database = $database;
|
||||
$this->connection = $connection;
|
||||
$this->hasher = $hasher;
|
||||
}
|
||||
|
||||
|
@ -55,11 +55,11 @@ class TemporaryPasswordService
|
|||
* @param string $email
|
||||
* @return string
|
||||
*/
|
||||
public function generateReset($email)
|
||||
public function handle($email)
|
||||
{
|
||||
$token = hash_hmac(self::HMAC_ALGO, str_random(40), $this->config->get('app.key'));
|
||||
|
||||
$this->database->table('password_resets')->insert([
|
||||
$this->connection->table('password_resets')->insert([
|
||||
'email' => $email,
|
||||
'token' => $this->hasher->make($token),
|
||||
]);
|
||||
|
|
|
@ -17,14 +17,24 @@ use Pterodactyl\Contracts\Repository\ScheduleRepositoryInterface;
|
|||
|
||||
class ProcessScheduleService
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\ScheduleRepositoryInterface
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Schedules\Tasks\RunTaskService
|
||||
*/
|
||||
protected $runnerService;
|
||||
|
||||
public function __construct(
|
||||
RunTaskService $runnerService,
|
||||
ScheduleRepositoryInterface $repository
|
||||
) {
|
||||
/**
|
||||
* ProcessScheduleService constructor.
|
||||
*
|
||||
* @param \Pterodactyl\Services\Schedules\Tasks\RunTaskService $runnerService
|
||||
* @param \Pterodactyl\Contracts\Repository\ScheduleRepositoryInterface $repository
|
||||
*/
|
||||
public function __construct(RunTaskService $runnerService, ScheduleRepositoryInterface $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
$this->runnerService = $runnerService;
|
||||
}
|
||||
|
|
|
@ -10,16 +10,13 @@
|
|||
namespace Pterodactyl\Services\Schedules\Tasks;
|
||||
|
||||
use Pterodactyl\Models\Task;
|
||||
use Illuminate\Contracts\Bus\Dispatcher;
|
||||
use Pterodactyl\Jobs\Schedule\RunTaskJob;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Pterodactyl\Contracts\Repository\TaskRepositoryInterface;
|
||||
|
||||
class RunTaskService
|
||||
{
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Bus\Dispatcher
|
||||
*/
|
||||
protected $dispatcher;
|
||||
use DispatchesJobs;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\TaskRepositoryInterface
|
||||
|
@ -29,14 +26,10 @@ class RunTaskService
|
|||
/**
|
||||
* RunTaskService constructor.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Bus\Dispatcher $dispatcher
|
||||
* @param \Pterodactyl\Contracts\Repository\TaskRepositoryInterface $repository
|
||||
*/
|
||||
public function __construct(
|
||||
Dispatcher $dispatcher,
|
||||
TaskRepositoryInterface $repository
|
||||
) {
|
||||
$this->dispatcher = $dispatcher;
|
||||
public function __construct(TaskRepositoryInterface $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
@ -55,6 +48,6 @@ class RunTaskService
|
|||
}
|
||||
|
||||
$this->repository->update($task->id, ['is_queued' => true]);
|
||||
$this->dispatcher->dispatch((new RunTaskJob($task->id, $task->schedule_id))->delay($task->time_offset));
|
||||
$this->dispatch((new RunTaskJob($task->id, $task->schedule_id))->delay($task->time_offset));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ class UserCreationService
|
|||
$this->connection->beginTransaction();
|
||||
if (! isset($data['password']) || empty($data['password'])) {
|
||||
$data['password'] = $this->hasher->make(str_random(30));
|
||||
$token = $this->passwordService->generateReset($data['email']);
|
||||
$token = $this->passwordService->handle($data['email']);
|
||||
}
|
||||
|
||||
$user = $this->repository->create($data);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue