Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public function rules(?array $rules = null): array
return collect($rules ?? Node::getRules())->only([
'public',
'name',
'description',
'location_id',
'fqdn',
'scheme',
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class Node extends Model
*/
protected $fillable = [
'public', 'name', 'location_id',
'fqdn', 'scheme', 'behind_proxy',
'description', 'fqdn', 'scheme', 'behind_proxy',
'memory', 'memory_overallocate', 'disk',
'disk_overallocate', 'upload_size', 'daemonBase',
'daemonSFTP', 'daemonListen',
Expand Down
11 changes: 3 additions & 8 deletions database/Factories/LocationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,13 @@
namespace Database\Factories;

use Illuminate\Support\Str;
use Pterodactyl\Models\Location;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\Pterodactyl\Models\Location>
*/
class LocationFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Location::class;

/**
* Define the model's default state.
*/
Expand Down
2 changes: 1 addition & 1 deletion routes/api-application.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
Route::get('/{node:id}/configuration', Application\Nodes\NodeConfigurationController::class);

Route::post('/', [Application\Nodes\NodeController::class, 'store']);
Route::patch('/{node:id}', [Application\Nodes\NodeController::class, 'update']);
Route::patch('/{node:id}', [Application\Nodes\NodeController::class, 'update'])->name('api.application.nodes.update');

Route::delete('/{node:id}', [Application\Nodes\NodeController::class, 'delete']);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

namespace Pterodactyl\Tests\Integration\Api\Application\Nodes\NodeController;

use Mockery\MockInterface;
use Pterodactyl\Models\Node;
use GuzzleHttp\Psr7\Response;
use Pterodactyl\Models\Location;
use Pterodactyl\Repositories\Wings\DaemonConfigurationRepository;
use Pterodactyl\Tests\Integration\Api\Application\ApplicationApiIntegrationTestCase;

class UpdateNodeTest extends ApplicationApiIntegrationTestCase
{
public function testCanUpdateNodeProperties(): void
{
$node = Node::factory()->for(Location::factory())->create();
$location = Location::factory()->create();

$this->mock(DaemonConfigurationRepository::class, function (MockInterface $mock) use ($node) {
$mock->expects('setNode')->with(\Mockery::on(fn ($value) => $value->is($node)))->andReturnSelf();
$mock->expects('update')->withAnyArgs()->andReturn(
new Response()
);
});

$this->patchJson(route('api.application.nodes.update', ['node' => $node]), [
'name' => 'New Name',
'description' => 'New Description',
'location_id' => $location->id,
'fqdn' => 'new.example.com',
'scheme' => 'https',
'memory' => 100,
'memory_overallocate' => 10,
'disk' => 200,
'disk_overallocate' => 20,
'daemon_sftp' => 1101,
'daemon_listen' => 1102,
])
->assertOk()
->assertJsonPath('object', 'node')
->assertJsonPath('attributes.name', 'New Name')
->assertJsonPath('attributes.description', 'New Description')
->assertJsonPath('attributes.fqdn', 'new.example.com')
->assertJsonPath('attributes.scheme', 'https')
->assertJsonPath('attributes.memory', 100)
->assertJsonPath('attributes.memory_overallocate', 10)
->assertJsonPath('attributes.disk', 200)
->assertJsonPath('attributes.disk_overallocate', 20)
->assertJsonPath('attributes.daemon_sftp', 1101)
->assertJsonPath('attributes.daemon_listen', 1102);

$this->assertEquals($location->id, $node->refresh()->location_id);
}
}