mirror of
https://github.com/pterodactyl/panel.git
synced 2026-11-30 11:25:52 -05:00
Co-authored-by: Anthony <anthony@infraly.co> Co-authored-by: Sky Mulley <daniel.mulley@outlook.com>
31 lines
1.8 KiB
PHP
31 lines
1.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Pterodactyl\Tests\Pest\Integration\Api\Application\Users\ExternalUserControllerTest;
|
|
|
|
use Illuminate\Http\Response;
|
|
use Illuminate\Support\Str;
|
|
use Pterodactyl\Models\User;
|
|
use Pterodactyl\Tests\Integration\Api\Application\ApplicationApiIntegrationTestCase;
|
|
|
|
uses(ApplicationApiIntegrationTestCase::class);
|
|
test('get remote user', function () {
|
|
$user = User::factory()->create(['external_id' => Str::random()]);
|
|
$response = $this->getJson('/api/application/users/external/'.$user->external_id);
|
|
$response->assertStatus(Response::HTTP_OK);
|
|
$response->assertJsonCount(2);
|
|
$response->assertJsonStructure(['object', 'attributes' => ['id', 'external_id', 'uuid', 'username', 'email', 'first_name', 'last_name', 'language', 'root_admin', '2fa', 'created_at', 'updated_at']]);
|
|
$response->assertJson(['object' => 'user', 'attributes' => ['id' => $user->id, 'external_id' => $user->external_id, 'uuid' => $user->uuid, 'username' => $user->username, 'email' => $user->email, 'first_name' => $user->name_first, 'last_name' => $user->name_last, 'language' => $user->language, 'root_admin' => (bool) $user->root_admin, '2fa' => (bool) $user->totp_enabled, 'created_at' => $this->formatTimestamp($user->created_at), 'updated_at' => $this->formatTimestamp($user->updated_at)]], true);
|
|
});
|
|
test('get missing user', function () {
|
|
$response = $this->getJson('/api/application/users/external/nil');
|
|
$this->assertNotFoundJson($response);
|
|
});
|
|
test('error returned if no permission', function () {
|
|
$user = User::factory()->create(['external_id' => Str::random()]);
|
|
$this->createNewDefaultApiKey($this->getApiUser(), ['r_users' => 0]);
|
|
$response = $this->getJson('/api/application/users/external/'.$user->external_id);
|
|
$this->assertAccessDeniedJson($response);
|
|
});
|