Add more middleware tests

This commit is contained in:
Dane Everitt 2017-11-03 18:16:49 -05:00
parent 133fd17da6
commit 7882250baf
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
13 changed files with 515 additions and 48 deletions

View file

@ -11,10 +11,8 @@ namespace Pterodactyl\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Pterodactyl\Models\Node;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
use Pterodactyl\Exceptions\Repository\RecordNotFoundException;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
class DaemonAuthenticate
{
@ -56,15 +54,10 @@ class DaemonAuthenticate
}
if (! $request->header('X-Access-Node')) {
throw new HttpException(403);
}
try {
$node = $this->repository->findWhere(['daemonSecret' => $request->header('X-Access-Node')]);
} catch (RecordNotFoundException $exception) {
throw new HttpException(401);
throw new AccessDeniedHttpException;
}
$node = $this->repository->findWhere(['daemonSecret' => $request->header('X-Access-Node')]);
$request->attributes->set('node', $node);
return $next($request);