Update transformers and controllers to no longer pull an API key attribute

This commit is contained in:
DaneEveritt 2022-05-22 15:37:39 -04:00
parent bd37978a98
commit e9c633fd03
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
9 changed files with 91 additions and 173 deletions

View file

@ -3,6 +3,7 @@
namespace Pterodactyl\Tests\Integration\Api\Application;
use Pterodactyl\Models\User;
use Illuminate\Http\Request;
use PHPUnit\Framework\Assert;
use Pterodactyl\Models\ApiKey;
use Pterodactyl\Services\Acl\Api\AdminAcl;
@ -110,9 +111,12 @@ abstract class ApplicationApiIntegrationTestCase extends IntegrationTestCase
*/
protected function getTransformer(string $abstract): BaseTransformer
{
/** @var \Pterodactyl\Transformers\Api\Application\BaseTransformer $transformer */
$transformer = $this->app->make($abstract);
$transformer->setKey($this->getApiKey());
$request = Request::createFromGlobals();
$request->setUserResolver(function () {
return $this->getApiKey()->user;
});
$transformer = $abstract::fromRequest($request);
Assert::assertInstanceOf(BaseTransformer::class, $transformer);
Assert::assertNotInstanceOf(BaseClientTransformer::class, $transformer);