Add test coverage for the SSH key endpoints
This commit is contained in:
parent
97280a62a2
commit
6554164252
7 changed files with 201 additions and 7 deletions
|
@ -4,7 +4,7 @@ namespace Pterodactyl\Http\Controllers\Api\Client;
|
|||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Pterodactyl\Http\Requests\Api\Client\ClientApiRequest;
|
||||
use Pterodactyl\Transformers\Api\Client\SSHKeyTransformer;
|
||||
use Pterodactyl\Transformers\Api\Client\UserSSHKeyTransformer;
|
||||
use Pterodactyl\Http\Requests\Api\Client\Account\StoreSSHKeyRequest;
|
||||
|
||||
class SSHKeyController extends ClientApiController
|
||||
|
@ -16,7 +16,7 @@ class SSHKeyController extends ClientApiController
|
|||
public function index(ClientApiRequest $request): array
|
||||
{
|
||||
return $this->fractal->collection($request->user()->sshKeys)
|
||||
->transformWith($this->getTransformer(SSHKeyTransformer::class))
|
||||
->transformWith($this->getTransformer(UserSSHKeyTransformer::class))
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ class SSHKeyController extends ClientApiController
|
|||
]);
|
||||
|
||||
return $this->fractal->item($model)
|
||||
->transformWith($this->getTransformer(SSHKeyTransformer::class))
|
||||
->transformWith($this->getTransformer(UserSSHKeyTransformer::class))
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
|
|
@ -43,11 +43,11 @@ class StoreSSHKeyRequest extends ClientApiRequest
|
|||
}
|
||||
|
||||
if ($this->key instanceof DSA) {
|
||||
$this->validator->errors()->add('public_key', 'DSA public keys are not supported.');
|
||||
$this->validator->errors()->add('public_key', 'DSA keys are not supported.');
|
||||
}
|
||||
|
||||
if ($this->key instanceof RSA && $this->key->getLength() < 2048) {
|
||||
$this->validator->errors()->add('public_key', 'RSA keys must be at 2048 bytes.');
|
||||
$this->validator->errors()->add('public_key', 'RSA keys must be at least 2048 bytes in length.');
|
||||
}
|
||||
|
||||
$fingerprint = $this->key->getFingerprint('sha256');
|
||||
|
|
|
@ -17,7 +17,6 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property \Illuminate\Support\Carbon|null $deleted_at
|
||||
* @property \Pterodactyl\Models\User $user
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserSSHKey newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserSSHKey newQuery()
|
||||
* @method static \Illuminate\Database\Query\Builder|UserSSHKey onlyTrashed()
|
||||
|
@ -33,6 +32,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|||
* @method static \Illuminate\Database\Query\Builder|UserSSHKey withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|UserSSHKey withoutTrashed()
|
||||
* @mixin \Eloquent
|
||||
* @method static \Database\Factories\UserSSHKeyFactory factory(...$parameters)
|
||||
*/
|
||||
class UserSSHKey extends Model
|
||||
{
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace Pterodactyl\Transformers\Api\Client;
|
|||
|
||||
use Pterodactyl\Models\UserSSHKey;
|
||||
|
||||
class SSHKeyTransformer extends BaseClientTransformer
|
||||
class UserSSHKeyTransformer extends BaseClientTransformer
|
||||
{
|
||||
public function getResourceName(): string
|
||||
{
|
Loading…
Add table
Add a link
Reference in a new issue