Refactor obscure service names to be clearer

This commit is contained in:
Dane Everitt 2017-08-27 15:10:51 -05:00
parent a91d84ecfe
commit 67ac36f5ce
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
25 changed files with 96 additions and 341 deletions

View file

@ -29,9 +29,9 @@ use Illuminate\Http\Request;
use Pterodactyl\Models\Node; use Pterodactyl\Models\Node;
use Prologue\Alerts\AlertsMessageBag; use Prologue\Alerts\AlertsMessageBag;
use Pterodactyl\Http\Controllers\Controller; use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Services\Nodes\UpdateService; use Pterodactyl\Services\Nodes\NodeUpdateService;
use Pterodactyl\Services\Nodes\CreationService; use Pterodactyl\Services\Nodes\NodeCreationService;
use Pterodactyl\Services\Nodes\DeletionService; use Pterodactyl\Services\Nodes\NodeDeletionService;
use Illuminate\Cache\Repository as CacheRepository; use Illuminate\Cache\Repository as CacheRepository;
use Pterodactyl\Services\Allocations\AssignmentService; use Pterodactyl\Services\Allocations\AssignmentService;
use Pterodactyl\Http\Requests\Admin\Node\NodeFormRequest; use Pterodactyl\Http\Requests\Admin\Node\NodeFormRequest;
@ -64,12 +64,12 @@ class NodesController extends Controller
protected $cache; protected $cache;
/** /**
* @var \Pterodactyl\Services\Nodes\CreationService * @var \Pterodactyl\Services\Nodes\NodeCreationService
*/ */
protected $creationService; protected $creationService;
/** /**
* @var \Pterodactyl\Services\Nodes\DeletionService * @var \Pterodactyl\Services\Nodes\NodeDeletionService
*/ */
protected $deletionService; protected $deletionService;
@ -84,7 +84,7 @@ class NodesController extends Controller
protected $repository; protected $repository;
/** /**
* @var \Pterodactyl\Services\Nodes\UpdateService * @var \Pterodactyl\Services\Nodes\NodeUpdateService
*/ */
protected $updateService; protected $updateService;
@ -95,22 +95,22 @@ class NodesController extends Controller
* @param \Pterodactyl\Contracts\Repository\AllocationRepositoryInterface $allocationRepository * @param \Pterodactyl\Contracts\Repository\AllocationRepositoryInterface $allocationRepository
* @param \Pterodactyl\Services\Allocations\AssignmentService $assignmentService * @param \Pterodactyl\Services\Allocations\AssignmentService $assignmentService
* @param \Illuminate\Cache\Repository $cache * @param \Illuminate\Cache\Repository $cache
* @param \Pterodactyl\Services\Nodes\CreationService $creationService * @param \Pterodactyl\Services\Nodes\NodeCreationService $creationService
* @param \Pterodactyl\Services\Nodes\DeletionService $deletionService * @param \Pterodactyl\Services\Nodes\NodeDeletionService $deletionService
* @param \Pterodactyl\Contracts\Repository\LocationRepositoryInterface $locationRepository * @param \Pterodactyl\Contracts\Repository\LocationRepositoryInterface $locationRepository
* @param \Pterodactyl\Contracts\Repository\NodeRepositoryInterface $repository * @param \Pterodactyl\Contracts\Repository\NodeRepositoryInterface $repository
* @param \Pterodactyl\Services\Nodes\UpdateService $updateService * @param \Pterodactyl\Services\Nodes\NodeUpdateService $updateService
*/ */
public function __construct( public function __construct(
AlertsMessageBag $alert, AlertsMessageBag $alert,
AllocationRepositoryInterface $allocationRepository, AllocationRepositoryInterface $allocationRepository,
AssignmentService $assignmentService, AssignmentService $assignmentService,
CacheRepository $cache, CacheRepository $cache,
CreationService $creationService, NodeCreationService $creationService,
DeletionService $deletionService, NodeDeletionService $deletionService,
LocationRepositoryInterface $locationRepository, LocationRepositoryInterface $locationRepository,
NodeRepositoryInterface $repository, NodeRepositoryInterface $repository,
UpdateService $updateService NodeUpdateService $updateService
) { ) {
$this->alert = $alert; $this->alert = $alert;
$this->allocationRepository = $allocationRepository; $this->allocationRepository = $allocationRepository;

View file

@ -30,9 +30,9 @@ use Pterodactyl\Models\Server;
use Prologue\Alerts\AlertsMessageBag; use Prologue\Alerts\AlertsMessageBag;
use Pterodactyl\Exceptions\DisplayException; use Pterodactyl\Exceptions\DisplayException;
use Pterodactyl\Http\Controllers\Controller; use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Services\Servers\CreationService; use Pterodactyl\Services\Servers\ServerCreationService;
use Pterodactyl\Services\Servers\DeletionService; use Pterodactyl\Services\Servers\ServerDeletionService;
use Pterodactyl\Services\Servers\ReinstallService; use Pterodactyl\Services\Servers\ReinstallServerService;
use Pterodactyl\Services\Servers\SuspensionService; use Pterodactyl\Services\Servers\SuspensionService;
use Pterodactyl\Http\Requests\Admin\ServerFormRequest; use Pterodactyl\Http\Requests\Admin\ServerFormRequest;
use Pterodactyl\Services\Servers\ContainerRebuildService; use Pterodactyl\Services\Servers\ContainerRebuildService;
@ -92,7 +92,7 @@ class ServersController extends Controller
protected $databaseHostRepository; protected $databaseHostRepository;
/** /**
* @var \Pterodactyl\Services\Servers\DeletionService * @var \Pterodactyl\Services\Servers\ServerDeletionService
*/ */
protected $deletionService; protected $deletionService;
@ -112,7 +112,7 @@ class ServersController extends Controller
protected $nodeRepository; protected $nodeRepository;
/** /**
* @var \Pterodactyl\Services\Servers\ReinstallService * @var \Pterodactyl\Services\Servers\ReinstallServerService
*/ */
protected $reinstallService; protected $reinstallService;
@ -122,7 +122,7 @@ class ServersController extends Controller
protected $repository; protected $repository;
/** /**
* @var \Pterodactyl\Services\Servers\CreationService * @var \Pterodactyl\Services\Servers\ServerCreationService
*/ */
protected $service; protected $service;
@ -149,15 +149,15 @@ class ServersController extends Controller
* @param \Pterodactyl\Services\Servers\BuildModificationService $buildModificationService * @param \Pterodactyl\Services\Servers\BuildModificationService $buildModificationService
* @param \Illuminate\Contracts\Config\Repository $config * @param \Illuminate\Contracts\Config\Repository $config
* @param \Pterodactyl\Services\Servers\ContainerRebuildService $containerRebuildService * @param \Pterodactyl\Services\Servers\ContainerRebuildService $containerRebuildService
* @param \Pterodactyl\Services\Servers\CreationService $service * @param \Pterodactyl\Services\Servers\ServerCreationService $service
* @param \Pterodactyl\Services\Database\DatabaseManagementService $databaseManagementService * @param \Pterodactyl\Services\Database\DatabaseManagementService $databaseManagementService
* @param \Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface $databaseRepository * @param \Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface $databaseRepository
* @param \Pterodactyl\Repositories\Eloquent\DatabaseHostRepository $databaseHostRepository * @param \Pterodactyl\Repositories\Eloquent\DatabaseHostRepository $databaseHostRepository
* @param \Pterodactyl\Services\Servers\DeletionService $deletionService * @param \Pterodactyl\Services\Servers\ServerDeletionService $deletionService
* @param \Pterodactyl\Services\Servers\DetailsModificationService $detailsModificationService * @param \Pterodactyl\Services\Servers\DetailsModificationService $detailsModificationService
* @param \Pterodactyl\Contracts\Repository\LocationRepositoryInterface $locationRepository * @param \Pterodactyl\Contracts\Repository\LocationRepositoryInterface $locationRepository
* @param \Pterodactyl\Contracts\Repository\NodeRepositoryInterface $nodeRepository * @param \Pterodactyl\Contracts\Repository\NodeRepositoryInterface $nodeRepository
* @param \Pterodactyl\Services\Servers\ReinstallService $reinstallService * @param \Pterodactyl\Services\Servers\ReinstallServerService $reinstallService
* @param \Pterodactyl\Contracts\Repository\ServerRepositoryInterface $repository * @param \Pterodactyl\Contracts\Repository\ServerRepositoryInterface $repository
* @param \Pterodactyl\Contracts\Repository\ServiceRepositoryInterface $serviceRepository * @param \Pterodactyl\Contracts\Repository\ServiceRepositoryInterface $serviceRepository
* @param \Pterodactyl\Services\Servers\StartupModificationService $startupModificationService * @param \Pterodactyl\Services\Servers\StartupModificationService $startupModificationService
@ -169,15 +169,15 @@ class ServersController extends Controller
BuildModificationService $buildModificationService, BuildModificationService $buildModificationService,
ConfigRepository $config, ConfigRepository $config,
ContainerRebuildService $containerRebuildService, ContainerRebuildService $containerRebuildService,
CreationService $service, ServerCreationService $service,
DatabaseManagementService $databaseManagementService, DatabaseManagementService $databaseManagementService,
DatabaseRepositoryInterface $databaseRepository, DatabaseRepositoryInterface $databaseRepository,
DatabaseHostRepository $databaseHostRepository, DatabaseHostRepository $databaseHostRepository,
DeletionService $deletionService, ServerDeletionService $deletionService,
DetailsModificationService $detailsModificationService, DetailsModificationService $detailsModificationService,
LocationRepositoryInterface $locationRepository, LocationRepositoryInterface $locationRepository,
NodeRepositoryInterface $nodeRepository, NodeRepositoryInterface $nodeRepository,
ReinstallService $reinstallService, ReinstallServerService $reinstallService,
ServerRepositoryInterface $repository, ServerRepositoryInterface $repository,
ServiceRepositoryInterface $serviceRepository, ServiceRepositoryInterface $serviceRepository,
StartupModificationService $startupModificationService, StartupModificationService $startupModificationService,

View file

@ -29,9 +29,9 @@ use Pterodactyl\Models\User;
use Prologue\Alerts\AlertsMessageBag; use Prologue\Alerts\AlertsMessageBag;
use Pterodactyl\Exceptions\DisplayException; use Pterodactyl\Exceptions\DisplayException;
use Pterodactyl\Http\Controllers\Controller; use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Services\Users\UpdateService; use Pterodactyl\Services\Users\UserUpdateService;
use Pterodactyl\Services\Users\CreationService; use Pterodactyl\Services\Users\UserCreationService;
use Pterodactyl\Services\Users\DeletionService; use Pterodactyl\Services\Users\UserDeletionService;
use Illuminate\Contracts\Translation\Translator; use Illuminate\Contracts\Translation\Translator;
use Pterodactyl\Http\Requests\Admin\UserFormRequest; use Pterodactyl\Http\Requests\Admin\UserFormRequest;
use Pterodactyl\Contracts\Repository\UserRepositoryInterface; use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
@ -44,12 +44,12 @@ class UserController extends Controller
protected $alert; protected $alert;
/** /**
* @var \Pterodactyl\Services\Users\CreationService * @var \Pterodactyl\Services\Users\UserCreationService
*/ */
protected $creationService; protected $creationService;
/** /**
* @var \Pterodactyl\Services\Users\DeletionService * @var \Pterodactyl\Services\Users\UserDeletionService
*/ */
protected $deletionService; protected $deletionService;
@ -64,7 +64,7 @@ class UserController extends Controller
protected $translator; protected $translator;
/** /**
* @var \Pterodactyl\Services\Users\UpdateService * @var \Pterodactyl\Services\Users\UserUpdateService
*/ */
protected $updateService; protected $updateService;
@ -72,18 +72,18 @@ class UserController extends Controller
* UserController constructor. * UserController constructor.
* *
* @param \Prologue\Alerts\AlertsMessageBag $alert * @param \Prologue\Alerts\AlertsMessageBag $alert
* @param \Pterodactyl\Services\Users\CreationService $creationService * @param \Pterodactyl\Services\Users\UserCreationService $creationService
* @param \Pterodactyl\Services\Users\DeletionService $deletionService * @param \Pterodactyl\Services\Users\UserDeletionService $deletionService
* @param \Illuminate\Contracts\Translation\Translator $translator * @param \Illuminate\Contracts\Translation\Translator $translator
* @param \Pterodactyl\Services\Users\UpdateService $updateService * @param \Pterodactyl\Services\Users\UserUpdateService $updateService
* @param \Pterodactyl\Contracts\Repository\UserRepositoryInterface $repository * @param \Pterodactyl\Contracts\Repository\UserRepositoryInterface $repository
*/ */
public function __construct( public function __construct(
AlertsMessageBag $alert, AlertsMessageBag $alert,
CreationService $creationService, UserCreationService $creationService,
DeletionService $deletionService, UserDeletionService $deletionService,
Translator $translator, Translator $translator,
UpdateService $updateService, UserUpdateService $updateService,
UserRepositoryInterface $repository UserRepositoryInterface $repository
) { ) {
$this->alert = $alert; $this->alert = $alert;

View file

@ -30,11 +30,14 @@ use Alert;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Pterodactyl\Models\User; use Pterodactyl\Models\User;
use Pterodactyl\Http\Controllers\Controller; use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Repositories\oldUserRepository;
use Pterodactyl\Exceptions\DisplayValidationException; use Pterodactyl\Exceptions\DisplayValidationException;
class AccountController extends Controller class AccountController extends Controller
{ {
public function __construct()
{
}
/** /**
* Display base account information page. * Display base account information page.
* *

View file

@ -26,7 +26,7 @@ namespace Pterodactyl\Services\Nodes;
use Pterodactyl\Contracts\Repository\NodeRepositoryInterface; use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
class CreationService class NodeCreationService
{ {
const DAEMON_SECRET_LENGTH = 18; const DAEMON_SECRET_LENGTH = 18;

View file

@ -30,7 +30,7 @@ use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
use Pterodactyl\Exceptions\Service\HasActiveServersException; use Pterodactyl\Exceptions\Service\HasActiveServersException;
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface; use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
class DeletionService class NodeDeletionService
{ {
/** /**
* @var \Pterodactyl\Contracts\Repository\NodeRepositoryInterface * @var \Pterodactyl\Contracts\Repository\NodeRepositoryInterface

View file

@ -31,7 +31,7 @@ use Pterodactyl\Exceptions\DisplayException;
use Pterodactyl\Contracts\Repository\NodeRepositoryInterface; use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
use Pterodactyl\Contracts\Repository\Daemon\ConfigurationRepositoryInterface; use Pterodactyl\Contracts\Repository\Daemon\ConfigurationRepositoryInterface;
class UpdateService class NodeUpdateService
{ {
/** /**
* @var \Pterodactyl\Contracts\Repository\Daemon\ConfigurationRepositoryInterface * @var \Pterodactyl\Contracts\Repository\Daemon\ConfigurationRepositoryInterface
@ -74,6 +74,7 @@ class UpdateService
* *
* @throws \Pterodactyl\Exceptions\DisplayException * @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/ */
public function handle($node, array $data) public function handle($node, array $data)
{ {
@ -82,7 +83,7 @@ class UpdateService
} }
if (! is_null(array_get($data, 'reset_secret'))) { if (! is_null(array_get($data, 'reset_secret'))) {
$data['daemonSecret'] = bin2hex(random_bytes(CreationService::DAEMON_SECRET_LENGTH)); $data['daemonSecret'] = bin2hex(random_bytes(NodeCreationService::DAEMON_SECRET_LENGTH));
unset($data['reset_secret']); unset($data['reset_secret']);
} }

View file

@ -1,249 +0,0 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Services;
use DB;
use Pterodactyl\Models\Node;
use Pterodactyl\Models\Server;
use Pterodactyl\Models\Location;
use Pterodactyl\Exceptions\AutoDeploymentException;
class DeploymentService
{
/**
* Eloquent model representing the allocation to use.
*
* @var \Pterodactyl\Models\Allocation
*/
protected $allocation;
/**
* Amount of disk to be used by the server.
*
* @var int
*/
protected $disk;
/**
* Amount of memory to be used by the sever.
*
* @var int
*/
protected $memory;
/**
* Eloquent model representing the location to use.
*
* @var \Pterodactyl\Models\Location
*/
protected $location;
/**
* Eloquent model representing the node to use.
*
* @var \Pterodactyl\Models\Node
*/
protected $node;
/**
* Set the location to use when auto-deploying.
*
* @param int|\Pterodactyl\Models\Location $location
*/
public function setLocation($location)
{
$this->location = ($location instanceof Location) ? $location : Location::with('nodes')->findOrFail($location);
if (! $this->location->relationLoaded('nodes')) {
$this->location->load('nodes');
}
if (count($this->location->nodes) < 1) {
throw new AutoDeploymentException('The location provided does not contain any nodes and cannot be used.');
}
return $this;
}
/**
* Set the node to use when auto-deploying.
*
* @param int|\Pterodactyl\Models\Node $node
*/
public function setNode($node)
{
$this->node = ($node instanceof Node) ? $node : Node::findOrFail($node);
if (! $this->node->relationLoaded('allocations')) {
$this->node->load('allocations');
}
$this->setLocation($this->node->location);
return $this;
}
/**
* Set the amount of disk space to be used by the new server.
*
* @param int $disk
*/
public function setDisk(int $disk)
{
$this->disk = $disk;
return $this;
}
/**
* Set the amount of memory to be used by the new server.
*
* @param int $memory
*/
public function setMemory(int $memory)
{
$this->memory = $memory;
return $this;
}
/**
* Return a random location model.
*
* @param array $exclude
*/
protected function findLocation(array $exclude = [])
{
$location = Location::with('nodes')->whereNotIn('id', $exclude)->inRandomOrder()->first();
if (! $location) {
throw new AutoDeploymentException('Unable to locate a suitable location to select a node from.');
}
if (count($location->nodes) < 1) {
return $this->findLocation(array_merge($exclude, [$location->id]));
}
$this->setLocation($location);
}
/**
* Return a model instance of a random node.
*/
protected function findNode(array $exclude = [])
{
if (! $this->location) {
$this->setLocation($this->findLocation());
}
$select = $this->location->nodes->whereNotIn('id', $exclude);
if (count($select) < 1) {
throw new AutoDeploymentException('Unable to find a suitable node within the assigned location with enough space.');
}
// Check usage, select new node if necessary
$this->setNode($select->random());
if (! $this->checkNodeUsage()) {
return $this->findNode(array_merge($exclude, [$this->node()->id]));
}
}
/**
* Checks that a node's allocation limits will not be passed
* with the assigned limits.
*
* @return bool
*/
protected function checkNodeUsage()
{
if (! $this->disk && ! $this->memory) {
return true;
}
$totals = Server::select(DB::raw('SUM(memory) as memory, SUM(disk) as disk'))->where('node_id', $this->node()->id)->first();
if ($this->memory) {
$limit = ($this->node()->memory * (1 + ($this->node()->memory_overallocate / 100)));
if (($totals->memory + $this->memory) > $limit) {
return false;
}
}
if ($this->disk) {
$limit = ($this->node()->disk * (1 + ($this->node()->disk_overallocate / 100)));
if (($totals->disk + $this->disk) > $limit) {
return false;
}
}
return true;
}
/**
* Return the assigned node for this auto-deployment.
*
* @return \Pterodactyl\Models\Node
*/
public function node()
{
return $this->node;
}
/**
* Return the assigned location for this auto-deployment.
*
* @return \Pterodactyl\Models\Location
*/
public function location()
{
return $this->location;
}
/**
* Return the assigned location for this auto-deployment.
*
* @return \Pterodactyl\Models\Allocation
*/
public function allocation()
{
return $this->allocation;
}
/**
* Select and return the node to be used by the auto-deployment system.
*/
public function select()
{
if (! $this->node) {
$this->findNode();
}
// Set the Allocation
$this->allocation = $this->node()->allocations->where('server_id', null)->random();
if (! $this->allocation) {
throw new AutoDeploymentException('Unable to find a suitable allocation to assign to this server.');
}
}
}

View file

@ -32,7 +32,7 @@ use Pterodactyl\Exceptions\DisplayException;
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface; use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
use Pterodactyl\Contracts\Repository\Daemon\ServerRepositoryInterface as DaemonServerRepositoryInterface; use Pterodactyl\Contracts\Repository\Daemon\ServerRepositoryInterface as DaemonServerRepositoryInterface;
class ReinstallService class ReinstallServerService
{ {
/** /**
* @var \Pterodactyl\Contracts\Repository\Daemon\ServerRepositoryInterface * @var \Pterodactyl\Contracts\Repository\Daemon\ServerRepositoryInterface

View file

@ -36,7 +36,7 @@ use Pterodactyl\Contracts\Repository\AllocationRepositoryInterface;
use Pterodactyl\Contracts\Repository\ServerVariableRepositoryInterface; use Pterodactyl\Contracts\Repository\ServerVariableRepositoryInterface;
use Pterodactyl\Contracts\Repository\Daemon\ServerRepositoryInterface as DaemonServerRepositoryInterface; use Pterodactyl\Contracts\Repository\Daemon\ServerRepositoryInterface as DaemonServerRepositoryInterface;
class CreationService class ServerCreationService
{ {
/** /**
* @var \Pterodactyl\Contracts\Repository\AllocationRepositoryInterface * @var \Pterodactyl\Contracts\Repository\AllocationRepositoryInterface

View file

@ -34,7 +34,7 @@ use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
use Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface; use Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface;
use Pterodactyl\Contracts\Repository\Daemon\ServerRepositoryInterface as DaemonServerRepositoryInterface; use Pterodactyl\Contracts\Repository\Daemon\ServerRepositoryInterface as DaemonServerRepositoryInterface;
class DeletionService class ServerDeletionService
{ {
/** /**
* @var \Illuminate\Database\ConnectionInterface * @var \Illuminate\Database\ConnectionInterface

View file

@ -29,7 +29,7 @@ use Pterodactyl\Models\Server;
use GuzzleHttp\Exception\RequestException; use GuzzleHttp\Exception\RequestException;
use Illuminate\Database\ConnectionInterface; use Illuminate\Database\ConnectionInterface;
use Pterodactyl\Exceptions\DisplayException; use Pterodactyl\Exceptions\DisplayException;
use Pterodactyl\Services\Users\CreationService; use Pterodactyl\Services\Users\UserCreationService;
use Pterodactyl\Contracts\Repository\UserRepositoryInterface; use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface; use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
use Pterodactyl\Contracts\Repository\SubuserRepositoryInterface; use Pterodactyl\Contracts\Repository\SubuserRepositoryInterface;
@ -67,7 +67,7 @@ class SubuserCreationService
protected $serverRepository; protected $serverRepository;
/** /**
* @var \Pterodactyl\Services\Users\CreationService * @var \Pterodactyl\Services\Users\UserCreationService
*/ */
protected $userCreationService; protected $userCreationService;
@ -83,7 +83,7 @@ class SubuserCreationService
public function __construct( public function __construct(
ConnectionInterface $connection, ConnectionInterface $connection,
CreationService $userCreationService, UserCreationService $userCreationService,
DaemonServerRepositoryInterface $daemonRepository, DaemonServerRepositoryInterface $daemonRepository,
PermissionCreationService $permissionService, PermissionCreationService $permissionService,
ServerRepositoryInterface $serverRepository, ServerRepositoryInterface $serverRepository,

View file

@ -32,7 +32,7 @@ use Pterodactyl\Notifications\AccountCreated;
use Pterodactyl\Services\Helpers\TemporaryPasswordService; use Pterodactyl\Services\Helpers\TemporaryPasswordService;
use Pterodactyl\Contracts\Repository\UserRepositoryInterface; use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
class CreationService class UserCreationService
{ {
/** /**
* @var \Illuminate\Foundation\Application * @var \Illuminate\Foundation\Application

View file

@ -30,7 +30,7 @@ use Illuminate\Contracts\Translation\Translator;
use Pterodactyl\Contracts\Repository\UserRepositoryInterface; use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface; use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
class DeletionService class UserDeletionService
{ {
/** /**
* @var \Pterodactyl\Contracts\Repository\UserRepositoryInterface * @var \Pterodactyl\Contracts\Repository\UserRepositoryInterface

View file

@ -27,7 +27,7 @@ namespace Pterodactyl\Services\Users;
use Illuminate\Contracts\Hashing\Hasher; use Illuminate\Contracts\Hashing\Hasher;
use Pterodactyl\Contracts\Repository\UserRepositoryInterface; use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
class UpdateService class UserUpdateService
{ {
/** /**
* @var \Illuminate\Contracts\Hashing\Hasher * @var \Illuminate\Contracts\Hashing\Hasher

View file

@ -27,10 +27,10 @@ namespace Tests\Unit\Services\Nodes;
use Mockery as m; use Mockery as m;
use Tests\TestCase; use Tests\TestCase;
use phpmock\phpunit\PHPMock; use phpmock\phpunit\PHPMock;
use Pterodactyl\Services\Nodes\CreationService; use Pterodactyl\Services\Nodes\NodeCreationService;
use Pterodactyl\Contracts\Repository\NodeRepositoryInterface; use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
class CreationServiceTest extends TestCase class NodeCreationServiceTest extends TestCase
{ {
use PHPMock; use PHPMock;
@ -40,7 +40,7 @@ class CreationServiceTest extends TestCase
protected $repository; protected $repository;
/** /**
* @var \Pterodactyl\Services\Nodes\CreationService * @var \Pterodactyl\Services\Nodes\NodeCreationService
*/ */
protected $service; protected $service;
@ -53,7 +53,7 @@ class CreationServiceTest extends TestCase
$this->repository = m::mock(NodeRepositoryInterface::class); $this->repository = m::mock(NodeRepositoryInterface::class);
$this->service = new CreationService($this->repository); $this->service = new NodeCreationService($this->repository);
} }
/** /**

View file

@ -27,12 +27,12 @@ namespace Tests\Unit\Services\Nodes;
use Mockery as m; use Mockery as m;
use Tests\TestCase; use Tests\TestCase;
use Pterodactyl\Models\Node; use Pterodactyl\Models\Node;
use Pterodactyl\Services\Nodes\DeletionService; use Pterodactyl\Services\Nodes\NodeDeletionService;
use Illuminate\Contracts\Translation\Translator; use Illuminate\Contracts\Translation\Translator;
use Pterodactyl\Contracts\Repository\NodeRepositoryInterface; use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface; use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
class DeletionServiceTest extends TestCase class NodeDeletionServiceTest extends TestCase
{ {
/** /**
* @var \Pterodactyl\Contracts\Repository\NodeRepositoryInterface * @var \Pterodactyl\Contracts\Repository\NodeRepositoryInterface
@ -50,7 +50,7 @@ class DeletionServiceTest extends TestCase
protected $translator; protected $translator;
/** /**
* @var \Pterodactyl\Services\Nodes\DeletionService * @var \Pterodactyl\Services\Nodes\NodeDeletionService
*/ */
protected $service; protected $service;
@ -65,7 +65,7 @@ class DeletionServiceTest extends TestCase
$this->serverRepository = m::mock(ServerRepositoryInterface::class); $this->serverRepository = m::mock(ServerRepositoryInterface::class);
$this->translator = m::mock(Translator::class); $this->translator = m::mock(Translator::class);
$this->service = new DeletionService( $this->service = new NodeDeletionService(
$this->repository, $this->repository,
$this->serverRepository, $this->serverRepository,
$this->translator $this->translator

View file

@ -32,12 +32,12 @@ use phpmock\phpunit\PHPMock;
use Pterodactyl\Models\Node; use Pterodactyl\Models\Node;
use GuzzleHttp\Exception\RequestException; use GuzzleHttp\Exception\RequestException;
use Pterodactyl\Exceptions\DisplayException; use Pterodactyl\Exceptions\DisplayException;
use Pterodactyl\Services\Nodes\UpdateService; use Pterodactyl\Services\Nodes\NodeUpdateService;
use Pterodactyl\Services\Nodes\CreationService; use Pterodactyl\Services\Nodes\NodeCreationService;
use Pterodactyl\Contracts\Repository\NodeRepositoryInterface; use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
use Pterodactyl\Contracts\Repository\Daemon\ConfigurationRepositoryInterface; use Pterodactyl\Contracts\Repository\Daemon\ConfigurationRepositoryInterface;
class UpdateServiceTest extends TestCase class NodeUpdateServiceTest extends TestCase
{ {
use PHPMock; use PHPMock;
@ -62,7 +62,7 @@ class UpdateServiceTest extends TestCase
protected $repository; protected $repository;
/** /**
* @var \Pterodactyl\Services\Nodes\UpdateService * @var \Pterodactyl\Services\Nodes\NodeUpdateService
*/ */
protected $service; protected $service;
@ -85,7 +85,7 @@ class UpdateServiceTest extends TestCase
$this->repository = m::mock(NodeRepositoryInterface::class); $this->repository = m::mock(NodeRepositoryInterface::class);
$this->writer = m::mock(Writer::class); $this->writer = m::mock(Writer::class);
$this->service = new UpdateService( $this->service = new NodeUpdateService(
$this->configRepository, $this->configRepository,
$this->repository, $this->repository,
$this->writer $this->writer
@ -99,7 +99,7 @@ class UpdateServiceTest extends TestCase
{ {
$this->getFunctionMock('\\Pterodactyl\\Services\\Nodes', 'random_bytes') $this->getFunctionMock('\\Pterodactyl\\Services\\Nodes', 'random_bytes')
->expects($this->once())->willReturnCallback(function ($bytes) { ->expects($this->once())->willReturnCallback(function ($bytes) {
$this->assertEquals(CreationService::DAEMON_SECRET_LENGTH, $bytes); $this->assertEquals(NodeCreationService::DAEMON_SECRET_LENGTH, $bytes);
return '\00'; return '\00';
}); });

View file

@ -32,11 +32,11 @@ use Pterodactyl\Models\Server;
use GuzzleHttp\Exception\RequestException; use GuzzleHttp\Exception\RequestException;
use Illuminate\Database\ConnectionInterface; use Illuminate\Database\ConnectionInterface;
use Pterodactyl\Exceptions\DisplayException; use Pterodactyl\Exceptions\DisplayException;
use Pterodactyl\Services\Servers\ReinstallService; use Pterodactyl\Services\Servers\ReinstallServerService;
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface; use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
use Pterodactyl\Contracts\Repository\Daemon\ServerRepositoryInterface as DaemonServerRepositoryInterface; use Pterodactyl\Contracts\Repository\Daemon\ServerRepositoryInterface as DaemonServerRepositoryInterface;
class ReinstallServiceTest extends TestCase class ReinstallServerServiceTest extends TestCase
{ {
/** /**
* @var \Pterodactyl\Contracts\Repository\Daemon\ServerRepositoryInterface * @var \Pterodactyl\Contracts\Repository\Daemon\ServerRepositoryInterface
@ -64,7 +64,7 @@ class ReinstallServiceTest extends TestCase
protected $server; protected $server;
/** /**
* @var \Pterodactyl\Services\Servers\ReinstallService * @var \Pterodactyl\Services\Servers\ReinstallServerService
*/ */
protected $service; protected $service;
@ -88,7 +88,7 @@ class ReinstallServiceTest extends TestCase
$this->server = factory(Server::class)->make(['node_id' => 1]); $this->server = factory(Server::class)->make(['node_id' => 1]);
$this->service = new ReinstallService( $this->service = new ReinstallServerService(
$this->database, $this->database,
$this->daemonServerRepository, $this->daemonServerRepository,
$this->repository, $this->repository,

View file

@ -32,7 +32,7 @@ use phpmock\phpunit\PHPMock;
use Illuminate\Database\DatabaseManager; use Illuminate\Database\DatabaseManager;
use GuzzleHttp\Exception\RequestException; use GuzzleHttp\Exception\RequestException;
use Pterodactyl\Exceptions\DisplayException; use Pterodactyl\Exceptions\DisplayException;
use Pterodactyl\Services\Servers\CreationService; use Pterodactyl\Services\Servers\ServerCreationService;
use Pterodactyl\Services\Servers\VariableValidatorService; use Pterodactyl\Services\Servers\VariableValidatorService;
use Pterodactyl\Services\Servers\UsernameGenerationService; use Pterodactyl\Services\Servers\UsernameGenerationService;
use Pterodactyl\Contracts\Repository\NodeRepositoryInterface; use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
@ -42,7 +42,7 @@ use Pterodactyl\Contracts\Repository\AllocationRepositoryInterface;
use Pterodactyl\Contracts\Repository\ServerVariableRepositoryInterface; use Pterodactyl\Contracts\Repository\ServerVariableRepositoryInterface;
use Pterodactyl\Contracts\Repository\Daemon\ServerRepositoryInterface as DaemonServerRepositoryInterface; use Pterodactyl\Contracts\Repository\Daemon\ServerRepositoryInterface as DaemonServerRepositoryInterface;
class CreationServiceTest extends TestCase class ServerCreationServiceTest extends TestCase
{ {
use PHPMock; use PHPMock;
@ -106,7 +106,7 @@ class CreationServiceTest extends TestCase
protected $serverVariableRepository; protected $serverVariableRepository;
/** /**
* @var \Pterodactyl\Services\Servers\CreationService * @var \Pterodactyl\Services\Servers\ServerCreationService
*/ */
protected $service; protected $service;
@ -161,7 +161,7 @@ class CreationServiceTest extends TestCase
$this->getFunctionMock('\\Ramsey\\Uuid\\Uuid', 'uuid4') $this->getFunctionMock('\\Ramsey\\Uuid\\Uuid', 'uuid4')
->expects($this->any())->willReturn('s'); ->expects($this->any())->willReturn('s');
$this->service = new CreationService( $this->service = new ServerCreationService(
$this->allocationRepository, $this->allocationRepository,
$this->daemonServerRepository, $this->daemonServerRepository,
$this->database, $this->database,

View file

@ -32,13 +32,13 @@ use Pterodactyl\Models\Server;
use GuzzleHttp\Exception\RequestException; use GuzzleHttp\Exception\RequestException;
use Illuminate\Database\ConnectionInterface; use Illuminate\Database\ConnectionInterface;
use Pterodactyl\Exceptions\DisplayException; use Pterodactyl\Exceptions\DisplayException;
use Pterodactyl\Services\Servers\DeletionService; use Pterodactyl\Services\Servers\ServerDeletionService;
use Pterodactyl\Services\Database\DatabaseManagementService; use Pterodactyl\Services\Database\DatabaseManagementService;
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface; use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
use Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface; use Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface;
use Pterodactyl\Contracts\Repository\Daemon\ServerRepositoryInterface as DaemonServerRepositoryInterface; use Pterodactyl\Contracts\Repository\Daemon\ServerRepositoryInterface as DaemonServerRepositoryInterface;
class DeletionServiceTest extends TestCase class ServerDeletionServiceTest extends TestCase
{ {
/** /**
* @var \Illuminate\Database\ConnectionInterface * @var \Illuminate\Database\ConnectionInterface
@ -76,7 +76,7 @@ class DeletionServiceTest extends TestCase
protected $repository; protected $repository;
/** /**
* @var \Pterodactyl\Services\Servers\DeletionService * @var \Pterodactyl\Services\Servers\ServerDeletionService
*/ */
protected $service; protected $service;
@ -101,7 +101,7 @@ class DeletionServiceTest extends TestCase
$this->repository = m::mock(ServerRepositoryInterface::class); $this->repository = m::mock(ServerRepositoryInterface::class);
$this->writer = m::mock(Writer::class); $this->writer = m::mock(Writer::class);
$this->service = new DeletionService( $this->service = new ServerDeletionService(
$this->connection, $this->connection,
$this->daemonServerRepository, $this->daemonServerRepository,
$this->databaseRepository, $this->databaseRepository,
@ -118,7 +118,7 @@ class DeletionServiceTest extends TestCase
{ {
$response = $this->service->withForce(true); $response = $this->service->withForce(true);
$this->assertInstanceOf(DeletionService::class, $response); $this->assertInstanceOf(ServerDeletionService::class, $response);
} }
/** /**

View file

@ -33,7 +33,7 @@ use Pterodactyl\Models\Server;
use Pterodactyl\Models\Subuser; use Pterodactyl\Models\Subuser;
use Illuminate\Database\ConnectionInterface; use Illuminate\Database\ConnectionInterface;
use Pterodactyl\Exceptions\DisplayException; use Pterodactyl\Exceptions\DisplayException;
use Pterodactyl\Services\Users\CreationService; use Pterodactyl\Services\Users\UserCreationService;
use Pterodactyl\Services\Subusers\SubuserCreationService; use Pterodactyl\Services\Subusers\SubuserCreationService;
use Pterodactyl\Services\Subusers\PermissionCreationService; use Pterodactyl\Services\Subusers\PermissionCreationService;
use Pterodactyl\Contracts\Repository\UserRepositoryInterface; use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
@ -78,7 +78,7 @@ class SubuserCreationServiceTest extends TestCase
protected $service; protected $service;
/** /**
* @var \Pterodactyl\Services\Users\CreationService * @var \Pterodactyl\Services\Users\UserCreationService
*/ */
protected $userCreationService; protected $userCreationService;
@ -106,7 +106,7 @@ class SubuserCreationServiceTest extends TestCase
$this->permissionService = m::mock(PermissionCreationService::class); $this->permissionService = m::mock(PermissionCreationService::class);
$this->subuserRepository = m::mock(SubuserRepositoryInterface::class); $this->subuserRepository = m::mock(SubuserRepositoryInterface::class);
$this->serverRepository = m::mock(ServerRepositoryInterface::class); $this->serverRepository = m::mock(ServerRepositoryInterface::class);
$this->userCreationService = m::mock(CreationService::class); $this->userCreationService = m::mock(UserCreationService::class);
$this->userRepository = m::mock(UserRepositoryInterface::class); $this->userRepository = m::mock(UserRepositoryInterface::class);
$this->writer = m::mock(Writer::class); $this->writer = m::mock(Writer::class);

View file

@ -31,11 +31,11 @@ use Illuminate\Contracts\Hashing\Hasher;
use Illuminate\Database\ConnectionInterface; use Illuminate\Database\ConnectionInterface;
use Illuminate\Notifications\ChannelManager; use Illuminate\Notifications\ChannelManager;
use Pterodactyl\Notifications\AccountCreated; use Pterodactyl\Notifications\AccountCreated;
use Pterodactyl\Services\Users\CreationService; use Pterodactyl\Services\Users\UserCreationService;
use Pterodactyl\Services\Helpers\TemporaryPasswordService; use Pterodactyl\Services\Helpers\TemporaryPasswordService;
use Pterodactyl\Contracts\Repository\UserRepositoryInterface; use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
class CreationServiceTest extends TestCase class UserCreationServiceTest extends TestCase
{ {
/** /**
* @var \Illuminate\Foundation\Application * @var \Illuminate\Foundation\Application
@ -68,7 +68,7 @@ class CreationServiceTest extends TestCase
protected $repository; protected $repository;
/** /**
* @var \Pterodactyl\Services\Users\CreationService * @var \Pterodactyl\Services\Users\UserCreationService
*/ */
protected $service; protected $service;
@ -86,7 +86,7 @@ class CreationServiceTest extends TestCase
$this->passwordService = m::mock(TemporaryPasswordService::class); $this->passwordService = m::mock(TemporaryPasswordService::class);
$this->repository = m::mock(UserRepositoryInterface::class); $this->repository = m::mock(UserRepositoryInterface::class);
$this->service = new CreationService( $this->service = new UserCreationService(
$this->appMock, $this->appMock,
$this->notification, $this->notification,
$this->database, $this->database,

View file

@ -27,12 +27,12 @@ namespace Tests\Unit\Services\Users;
use Mockery as m; use Mockery as m;
use Tests\TestCase; use Tests\TestCase;
use Pterodactyl\Models\User; use Pterodactyl\Models\User;
use Pterodactyl\Services\Users\DeletionService; use Pterodactyl\Services\Users\UserDeletionService;
use Illuminate\Contracts\Translation\Translator; use Illuminate\Contracts\Translation\Translator;
use Pterodactyl\Contracts\Repository\UserRepositoryInterface; use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface; use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
class DeletionServiceTest extends TestCase class UserDeletionServiceTest extends TestCase
{ {
/** /**
* @var \Pterodactyl\Contracts\Repository\UserRepositoryInterface * @var \Pterodactyl\Contracts\Repository\UserRepositoryInterface
@ -50,7 +50,7 @@ class DeletionServiceTest extends TestCase
protected $serverRepository; protected $serverRepository;
/** /**
* @var \Pterodactyl\Services\Users\DeletionService * @var \Pterodactyl\Services\Users\UserDeletionService
*/ */
protected $service; protected $service;
@ -71,7 +71,7 @@ class DeletionServiceTest extends TestCase
$this->translator = m::mock(Translator::class); $this->translator = m::mock(Translator::class);
$this->serverRepository = m::mock(ServerRepositoryInterface::class); $this->serverRepository = m::mock(ServerRepositoryInterface::class);
$this->service = new DeletionService( $this->service = new UserDeletionService(
$this->serverRepository, $this->serverRepository,
$this->translator, $this->translator,
$this->repository $this->repository

View file

@ -27,10 +27,10 @@ namespace Tests\Unit\Services\Users;
use Mockery as m; use Mockery as m;
use Tests\TestCase; use Tests\TestCase;
use Illuminate\Contracts\Hashing\Hasher; use Illuminate\Contracts\Hashing\Hasher;
use Pterodactyl\Services\Users\UpdateService; use Pterodactyl\Services\Users\UserUpdateService;
use Pterodactyl\Contracts\Repository\UserRepositoryInterface; use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
class UpdateServiceTest extends TestCase class UserUpdateServiceTest extends TestCase
{ {
/** /**
* @var \Illuminate\Contracts\Hashing\Hasher * @var \Illuminate\Contracts\Hashing\Hasher
@ -43,7 +43,7 @@ class UpdateServiceTest extends TestCase
protected $repository; protected $repository;
/** /**
* @var \Pterodactyl\Services\Users\UpdateService * @var \Pterodactyl\Services\Users\UserUpdateService
*/ */
protected $service; protected $service;
@ -57,7 +57,7 @@ class UpdateServiceTest extends TestCase
$this->hasher = m::mock(Hasher::class); $this->hasher = m::mock(Hasher::class);
$this->repository = m::mock(UserRepositoryInterface::class); $this->repository = m::mock(UserRepositoryInterface::class);
$this->service = new UpdateService($this->hasher, $this->repository); $this->service = new UserUpdateService($this->hasher, $this->repository);
} }
/** /**