Run cs-fixer on files

This commit is contained in:
Dane Everitt 2022-02-13 19:06:53 -05:00
parent afd0a8f768
commit fb1f75353d
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
17 changed files with 25 additions and 50 deletions

View file

@ -12,8 +12,8 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
php: [ 7.4, 8.0 ] php: [ 7.4, 8.0, 8.1 ]
database: [ 'mariadb:10.2', 'mysql:8' ] database: [ 'mariadb:10.6', 'mysql:8' ]
services: services:
database: database:
image: ${{ matrix.database }} image: ${{ matrix.database }}
@ -51,21 +51,14 @@ jobs:
run: composer install --prefer-dist --no-interaction --no-progress run: composer install --prefer-dist --no-interaction --no-progress
- name: Run cs-fixer - name: Run cs-fixer
run: vendor/bin/php-cs-fixer fix --dry-run --diff --format=txt --config .php-cs-fixer.dist.php run: vendor/bin/php-cs-fixer fix --dry-run --diff --format=txt --config .php-cs-fixer.dist.php
continue-on-error: true
- name: Static Analysis - name: Static Analysis
if: ${{ matrix.php }} == '8.0' if: ${{ matrix.php }} == '8.0'
run: | run: |
php artisan ide-helper:models -N php artisan ide-helper:models -N
./vendor/bin/phpstan analyse --memory-limit=2G ./vendor/bin/phpstan analyse --memory-limit=2G
env: env:
TESTING_DB_PORT: ${{ job.services.database.ports[3306] }} DB_PORT: ${{ job.services.database.ports[3306] }}
- name: Execute Unit Tests - name: Execute Tests
run: php artisan test tests/Unit run: php artisan test
if: ${{ always() }}
env:
DB_PORT: ${{ job.services.database.ports[3306] }}
- name: Execute Integration Tests
run: php artisan test tests/Integration
if: ${{ always() }}
env: env:
DB_PORT: ${{ job.services.database.ports[3306] }} DB_PORT: ${{ job.services.database.ports[3306] }}

View file

@ -119,6 +119,7 @@ class AppSettingsCommand extends Command
foreach ($validator->errors()->all() as $error) { foreach ($validator->errors()->all() as $error) {
$this->output->error($error); $this->output->error($error);
} }
return 1; return 1;
} }

View file

@ -15,8 +15,8 @@ use Pterodactyl\Exceptions\Http\QueryValueOutOfRangeHttpException;
use Pterodactyl\Http\Requests\Api\Application\Eggs\GetEggsRequest; use Pterodactyl\Http\Requests\Api\Application\Eggs\GetEggsRequest;
use Pterodactyl\Http\Requests\Api\Application\Eggs\StoreEggRequest; use Pterodactyl\Http\Requests\Api\Application\Eggs\StoreEggRequest;
use Pterodactyl\Http\Requests\Api\Application\Eggs\DeleteEggRequest; use Pterodactyl\Http\Requests\Api\Application\Eggs\DeleteEggRequest;
use Pterodactyl\Http\Requests\Api\Application\Eggs\UpdateEggRequest;
use Pterodactyl\Http\Requests\Api\Application\Eggs\ExportEggRequest; use Pterodactyl\Http\Requests\Api\Application\Eggs\ExportEggRequest;
use Pterodactyl\Http\Requests\Api\Application\Eggs\UpdateEggRequest;
use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController; use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController;
class EggController extends ApplicationApiController class EggController extends ApplicationApiController

View file

@ -7,12 +7,9 @@ use Illuminate\Support\Str;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Pterodactyl\Models\SecurityKey; use Pterodactyl\Models\SecurityKey;
use Nyholm\Psr7\Factory\Psr17Factory;
use Illuminate\Contracts\Cache\Repository; use Illuminate\Contracts\Cache\Repository;
use Psr\Http\Message\ServerRequestInterface;
use Pterodactyl\Exceptions\DisplayException; use Pterodactyl\Exceptions\DisplayException;
use Webauthn\PublicKeyCredentialCreationOptions; use Webauthn\PublicKeyCredentialCreationOptions;
use Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory;
use Pterodactyl\Transformers\Api\Client\SecurityKeyTransformer; use Pterodactyl\Transformers\Api\Client\SecurityKeyTransformer;
use Pterodactyl\Repositories\SecurityKeys\WebauthnServerRepository; use Pterodactyl\Repositories\SecurityKeys\WebauthnServerRepository;
use Pterodactyl\Services\Users\SecurityKeys\StoreSecurityKeyService; use Pterodactyl\Services\Users\SecurityKeys\StoreSecurityKeyService;

View file

@ -4,10 +4,10 @@ namespace Pterodactyl\Http\Controllers\Auth;
use Carbon\CarbonImmutable; use Carbon\CarbonImmutable;
use Carbon\CarbonInterface; use Carbon\CarbonInterface;
use Pterodactyl\Models\User;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use PragmaRX\Google2FA\Google2FA; use Pterodactyl\Models\User;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use PragmaRX\Google2FA\Google2FA;
use Pterodactyl\Models\SecurityKey; use Pterodactyl\Models\SecurityKey;
use Illuminate\Contracts\Encryption\Encrypter; use Illuminate\Contracts\Encryption\Encrypter;
use Webauthn\PublicKeyCredentialRequestOptions; use Webauthn\PublicKeyCredentialRequestOptions;

View file

@ -19,9 +19,6 @@ class LoginController extends AbstractLoginController
protected GeneratePublicKeyCredentialsRequestService $service; protected GeneratePublicKeyCredentialsRequestService $service;
/**
* @param \Pterodactyl\Services\Users\SecurityKeys\GeneratePublicKeyCredentialsRequestService $service
*/
public function __construct(GeneratePublicKeyCredentialsRequestService $service) public function __construct(GeneratePublicKeyCredentialsRequestService $service)
{ {
parent::__construct(); parent::__construct();

View file

@ -113,9 +113,6 @@ class SecurityKey extends Model
/** /**
* Returns a PSR17 Request factory to be used by different Webauthn tooling. * Returns a PSR17 Request factory to be used by different Webauthn tooling.
*
* @param \Illuminate\Http\Request $request
* @return \Psr\Http\Message\ServerRequestInterface
*/ */
public static function getPsrRequestFactory(Request $request): ServerRequestInterface public static function getPsrRequestFactory(Request $request): ServerRequestInterface
{ {

View file

@ -231,9 +231,6 @@ class User extends Model implements
->groupBy('servers.id'); ->groupBy('servers.id');
} }
/**
* @return \Webauthn\PublicKeyCredentialUserEntity
*/
public function toPublicKeyCredentialEntity(): PublicKeyCredentialUserEntity public function toPublicKeyCredentialEntity(): PublicKeyCredentialUserEntity
{ {
return new PublicKeyCredentialUserEntity($this->username, $this->uuid, $this->email, null); return new PublicKeyCredentialUserEntity($this->username, $this->uuid, $this->email, null);

View file

@ -2,12 +2,11 @@
namespace Pterodactyl\Repositories\SecurityKeys; namespace Pterodactyl\Repositories\SecurityKeys;
use Ramsey\Uuid\Uuid;
use Pterodactyl\Models\User; use Pterodactyl\Models\User;
use Illuminate\Container\Container; use Illuminate\Container\Container;
use Pterodactyl\Models\SecurityKey;
use Webauthn\PublicKeyCredentialSource; use Webauthn\PublicKeyCredentialSource;
use Webauthn\PublicKeyCredentialUserEntity; use Webauthn\PublicKeyCredentialUserEntity;
use Pterodactyl\Models\SecurityKey;
use Webauthn\PublicKeyCredentialSourceRepository as PublicKeyRepositoryInterface; use Webauthn\PublicKeyCredentialSourceRepository as PublicKeyRepositoryInterface;
class PublicKeyCredentialSourceRepository implements PublicKeyRepositoryInterface class PublicKeyCredentialSourceRepository implements PublicKeyRepositoryInterface

View file

@ -20,7 +20,8 @@ class SuspensionService
/** /**
* SuspensionService constructor. * SuspensionService constructor.
*/ */
public function __construct(DaemonServerRepository $daemonServerRepository) { public function __construct(DaemonServerRepository $daemonServerRepository)
{
$this->daemonServerRepository = $daemonServerRepository; $this->daemonServerRepository = $daemonServerRepository;
} }

View file

@ -11,18 +11,11 @@ class GeneratePublicKeyCredentialsRequestService
{ {
protected WebauthnServerRepository $serverRepository; protected WebauthnServerRepository $serverRepository;
/**
* @param \Pterodactyl\Repositories\SecurityKeys\WebauthnServerRepository $serverRepository
*/
public function __construct(WebauthnServerRepository $serverRepository) public function __construct(WebauthnServerRepository $serverRepository)
{ {
$this->serverRepository = $serverRepository; $this->serverRepository = $serverRepository;
} }
/**
* @param \Pterodactyl\Models\User $user
* @return \Webauthn\PublicKeyCredentialRequestOptions
*/
public function handle(User $user): PublicKeyCredentialRequestOptions public function handle(User $user): PublicKeyCredentialRequestOptions
{ {
$credentials = $user->securityKeys->map(function (SecurityKey $key) { $credentials = $user->securityKeys->map(function (SecurityKey $key) {
@ -31,7 +24,8 @@ class GeneratePublicKeyCredentialsRequestService
$response = $this->serverRepository->getServer($user) $response = $this->serverRepository->getServer($user)
->generatePublicKeyCredentialRequestOptions( ->generatePublicKeyCredentialRequestOptions(
PublicKeyCredentialRequestOptions::USER_VERIFICATION_REQUIREMENT_PREFERRED, $credentials PublicKeyCredentialRequestOptions::USER_VERIFICATION_REQUIREMENT_PREFERRED,
$credentials
); );
return $response->setTimeout(300); return $response->setTimeout(300);

View file

@ -26,7 +26,6 @@ class SecurityKeyFactory extends Factory
} }
/** /**
* @param \Pterodactyl\Models\User $user
* @return $this * @return $this
*/ */
public function withUser(User $user): self public function withUser(User $user): self

View file

@ -1,8 +1,8 @@
<?php <?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateSecurityKeysTable extends Migration class CreateSecurityKeysTable extends Migration
{ {

View file

@ -1,8 +1,8 @@
<?php <?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class MakeStartupFieldNullableOnServersTable extends Migration class MakeStartupFieldNullableOnServersTable extends Migration
{ {

View file

@ -1,8 +1,8 @@
<?php <?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class DropWebauthnKeysTable extends Migration class DropWebauthnKeysTable extends Migration
{ {

View file

@ -4,9 +4,9 @@ namespace Pterodactyl\Tests\Integration\Api\Application\Location;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Pterodactyl\Models\Location; use Pterodactyl\Models\Location;
use Pterodactyl\Transformers\Api\Application\LocationTransformer;
use Pterodactyl\Transformers\Api\Application\NodeTransformer; use Pterodactyl\Transformers\Api\Application\NodeTransformer;
use Pterodactyl\Transformers\Api\Application\ServerTransformer; use Pterodactyl\Transformers\Api\Application\ServerTransformer;
use Pterodactyl\Transformers\Api\Application\LocationTransformer;
use Pterodactyl\Tests\Integration\Api\Application\ApplicationApiIntegrationTestCase; use Pterodactyl\Tests\Integration\Api\Application\ApplicationApiIntegrationTestCase;
class LocationControllerTest extends ApplicationApiIntegrationTestCase class LocationControllerTest extends ApplicationApiIntegrationTestCase
@ -128,13 +128,13 @@ class LocationControllerTest extends ApplicationApiIntegrationTestCase
$response = $this->patchJson('/api/application/locations/' . $location->id, [ $response = $this->patchJson('/api/application/locations/' . $location->id, [
'short' => 'new inhouse', 'short' => 'new inhouse',
'long' => 'This is my new inhouse location' 'long' => 'This is my new inhouse location',
]); ]);
$response->assertStatus(Response::HTTP_OK); $response->assertStatus(Response::HTTP_OK);
$response->assertJsonCount(2); $response->assertJsonCount(2);
$response->assertJsonStructure([ $response->assertJsonStructure([
'object', 'object',
'attributes' => ['id', 'short', 'long', 'created_at', 'updated_at'] 'attributes' => ['id', 'short', 'long', 'created_at', 'updated_at'],
]); ]);
$this->assertDatabaseHas('locations', ['short' => 'new inhouse', 'long' => 'This is my new inhouse location']); $this->assertDatabaseHas('locations', ['short' => 'new inhouse', 'long' => 'This is my new inhouse location']);