Skip to content
Snippets Groups Projects
Commit 77f3caf9 authored by Neuber, Eugen Ramon's avatar Neuber, Eugen Ramon :speech_balloon:
Browse files

Apply php-cs-fixer's recommendations.

parent fa4a11cc
No related branches found
No related tags found
No related merge requests found
Pipeline #229916 passed
...@@ -152,12 +152,12 @@ class FileDataDataProvider extends AbstractDataProvider ...@@ -152,12 +152,12 @@ class FileDataDataProvider extends AbstractDataProvider
// check if signed params aer equal to request params // check if signed params aer equal to request params
if ($data['bucketID'] !== $bucketId) { if ($data['bucketID'] !== $bucketId) {
/** @noinspection ForgottenDebugOutputInspection */ /* @noinspection ForgottenDebugOutputInspection */
dump($data['bucketID'], $bucketId); dump($data['bucketID'], $bucketId);
throw ApiError::withDetails(Response::HTTP_FORBIDDEN, 'BucketId change forbidden', 'blob:bucketid-change-forbidden'); throw ApiError::withDetails(Response::HTTP_FORBIDDEN, 'BucketId change forbidden', 'blob:bucketid-change-forbidden');
} }
if ((int) $data['creationTime'] !== (int) $creationTime) { if ((int) $data['creationTime'] !== (int) $creationTime) {
/** @noinspection ForgottenDebugOutputInspection */ /* @noinspection ForgottenDebugOutputInspection */
dump($data['creationTime'], $creationTime); dump($data['creationTime'], $creationTime);
throw ApiError::withDetails(Response::HTTP_FORBIDDEN, 'Creation Time change forbidden', 'blob:creationtime-change-forbidden'); throw ApiError::withDetails(Response::HTTP_FORBIDDEN, 'Creation Time change forbidden', 'blob:creationtime-change-forbidden');
} }
......
...@@ -49,6 +49,7 @@ class DenyAccessUnlessCheckSignature ...@@ -49,6 +49,7 @@ class DenyAccessUnlessCheckSignature
$payload = []; $payload = [];
if (!self::verifyToken($jwk, $token, $payload)) { if (!self::verifyToken($jwk, $token, $payload)) {
/* @noinspection ForgottenDebugOutputInspection */
dump(['token' => $token, 'payload' => $payload, 'secret' => $secret]); dump(['token' => $token, 'payload' => $payload, 'secret' => $secret]);
throw ApiError::withDetails(Response::HTTP_FORBIDDEN, 'Signature invalid', 'blob:signature-invalid'); throw ApiError::withDetails(Response::HTTP_FORBIDDEN, 'Signature invalid', 'blob:signature-invalid');
} }
...@@ -101,7 +102,6 @@ class DenyAccessUnlessCheckSignature ...@@ -101,7 +102,6 @@ class DenyAccessUnlessCheckSignature
* *
* @param string $token the JWS token as string * @param string $token the JWS token as string
* @param array $payload to extract from token on success * @param array $payload to extract from token on success
* @return bool
* *
* @throws \JsonException * @throws \JsonException
*/ */
......
...@@ -7,7 +7,6 @@ namespace Dbp\Relay\BlobBundle\Service; ...@@ -7,7 +7,6 @@ namespace Dbp\Relay\BlobBundle\Service;
use Dbp\Relay\BlobBundle\Entity\Bucket; use Dbp\Relay\BlobBundle\Entity\Bucket;
use Dbp\Relay\BlobBundle\Entity\FileData; use Dbp\Relay\BlobBundle\Entity\FileData;
use Dbp\Relay\CoreBundle\Exception\ApiError; use Dbp\Relay\CoreBundle\Exception\ApiError;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use PHPUnit\TextUI\XmlConfiguration\File; use PHPUnit\TextUI\XmlConfiguration\File;
use Symfony\Component\HttpFoundation\File\UploadedFile; use Symfony\Component\HttpFoundation\File\UploadedFile;
...@@ -140,7 +139,7 @@ class BlobService ...@@ -140,7 +139,7 @@ class BlobService
$this->em->flush(); $this->em->flush();
} catch (\Exception $e) { } catch (\Exception $e) {
echo " error: {$e->getMessage()}\n"; echo " error: {$e->getMessage()}\n";
echo " fileData =" . print_r($fileData, true)."\n"; echo ' fileData ='.print_r($fileData, true)."\n";
throw ApiError::withDetails(Response::HTTP_INTERNAL_SERVER_ERROR, 'File could not be saved!', 'blob:file-not-saved', ['message' => $e->getMessage()]); throw ApiError::withDetails(Response::HTTP_INTERNAL_SERVER_ERROR, 'File could not be saved!', 'blob:file-not-saved', ['message' => $e->getMessage()]);
} }
} }
......
<?php declare(strict_types=1); <?php
declare(strict_types=1);
namespace Dbp\Relay\BlobBundle\Tests; namespace Dbp\Relay\BlobBundle\Tests;
...@@ -26,8 +28,8 @@ use function uuid_is_valid; ...@@ -26,8 +28,8 @@ use function uuid_is_valid;
class DummyFileSystemService implements DatasystemProviderServiceInterface class DummyFileSystemService implements DatasystemProviderServiceInterface
{ {
static $fd = []; public static $fd = [];
static $data = []; public static $data = [];
public function saveFile(FileData $fileData): ?FileData public function saveFile(FileData $fileData): ?FileData
{ {
...@@ -49,6 +51,7 @@ class DummyFileSystemService implements DatasystemProviderServiceInterface ...@@ -49,6 +51,7 @@ class DummyFileSystemService implements DatasystemProviderServiceInterface
$identifier = $fileData->getIdentifier(); $identifier = $fileData->getIdentifier();
if (!isset(self::$fd[$identifier])) { if (!isset(self::$fd[$identifier])) {
echo " DummyFileSystemService::getLink($identifier): not found!\n"; echo " DummyFileSystemService::getLink($identifier): not found!\n";
return null; return null;
} }
...@@ -68,10 +71,10 @@ class CurlGetTest extends ApiTestCase ...@@ -68,10 +71,10 @@ class CurlGetTest extends ApiTestCase
{ {
use UserAuthTrait; use UserAuthTrait;
/** @var EntityManagerInterface $entityManager */ /** @var EntityManagerInterface */
private $entityManager; private $entityManager;
/** @var array[] $files */ /** @var array[] */
private $files; private $files;
/** /**
...@@ -145,7 +148,7 @@ class CurlGetTest extends ApiTestCase ...@@ -145,7 +148,7 @@ class CurlGetTest extends ApiTestCase
], ],
]; ];
/** @noinspection PhpInternalEntityUsedInspection */ /* @noinspection PhpInternalEntityUsedInspection */
$client->getKernelBrowser()->followRedirects(); $client->getKernelBrowser()->followRedirects();
/** @var Response $response */ /** @var Response $response */
...@@ -170,9 +173,8 @@ class CurlGetTest extends ApiTestCase ...@@ -170,9 +173,8 @@ class CurlGetTest extends ApiTestCase
* - create blob no 2 * - create blob no 2
* - get all blobs: two blobs are available * - get all blobs: two blobs are available
* - delete all blobs for the prefix: no entries in database * - delete all blobs for the prefix: no entries in database
* - get all blobs: no blobs available * - get all blobs: no blobs available.
* *
* @return void
* @throws \Doctrine\DBAL\Exception * @throws \Doctrine\DBAL\Exception
* @throws \JsonException * @throws \JsonException
* @throws ClientExceptionInterface * @throws ClientExceptionInterface
...@@ -183,7 +185,6 @@ class CurlGetTest extends ApiTestCase ...@@ -183,7 +185,6 @@ class CurlGetTest extends ApiTestCase
public function testPostGetDelete(): void public function testPostGetDelete(): void
{ {
try { try {
$client = static::createClient(); $client = static::createClient();
/** @var BlobService $blobService */ /** @var BlobService $blobService */
$blobService = $client->getContainer()->get(BlobService::class); $blobService = $client->getContainer()->get(BlobService::class);
...@@ -218,7 +219,7 @@ class CurlGetTest extends ApiTestCase ...@@ -218,7 +219,7 @@ class CurlGetTest extends ApiTestCase
$requestPost = Request::create($url, 'POST', [], [], $requestPost = Request::create($url, 'POST', [], [],
[ [
'file' => new UploadedFile($this->files[0]['path'], $this->files[0]['name'], $this->files[0]['mime']) 'file' => new UploadedFile($this->files[0]['path'], $this->files[0]['name'], $this->files[0]['mime']),
], ],
[ [
'HTTP_ACCEPT' => 'application/ld+json', 'HTTP_ACCEPT' => 'application/ld+json',
...@@ -227,7 +228,7 @@ class CurlGetTest extends ApiTestCase ...@@ -227,7 +228,7 @@ class CurlGetTest extends ApiTestCase
], ],
"HTTP_ACCEPT: application/ld+json\r\n" "HTTP_ACCEPT: application/ld+json\r\n"
."HTTP_X_DBP_SIGNATURE: $token\r\n\r\n" ."HTTP_X_DBP_SIGNATURE: $token\r\n\r\n"
. "file=" . base64_encode($this->files[0]['content']) .'file='.base64_encode($this->files[0]['content'])
."&fileName={$this->files[0]['name']}&prefix=$prefix&bucketID=$bucketId" ."&fileName={$this->files[0]['name']}&prefix=$prefix&bucketID=$bucketId"
); );
$c = new CreateFileDataAction($blobService); $c = new CreateFileDataAction($blobService);
...@@ -260,7 +261,7 @@ class CurlGetTest extends ApiTestCase ...@@ -260,7 +261,7 @@ class CurlGetTest extends ApiTestCase
], ],
]; ];
/** @noinspection PhpInternalEntityUsedInspection */ /* @noinspection PhpInternalEntityUsedInspection */
$client->getKernelBrowser()->followRedirects(); $client->getKernelBrowser()->followRedirects();
/** @var \ApiPlatform\Core\Bridge\Symfony\Bundle\Test\Response $response */ /** @var \ApiPlatform\Core\Bridge\Symfony\Bundle\Test\Response $response */
...@@ -302,7 +303,7 @@ class CurlGetTest extends ApiTestCase ...@@ -302,7 +303,7 @@ class CurlGetTest extends ApiTestCase
$requestPost = Request::create($url, 'POST', [], [], $requestPost = Request::create($url, 'POST', [], [],
[ [
'file' => new UploadedFile($this->files[1]['path'], $this->files[1]['name'], $this->files[1]['mime']) 'file' => new UploadedFile($this->files[1]['path'], $this->files[1]['name'], $this->files[1]['mime']),
], ],
[ [
'HTTP_ACCEPT' => 'application/ld+json', 'HTTP_ACCEPT' => 'application/ld+json',
...@@ -311,7 +312,7 @@ class CurlGetTest extends ApiTestCase ...@@ -311,7 +312,7 @@ class CurlGetTest extends ApiTestCase
], ],
"HTTP_ACCEPT: application/ld+json\r\n" "HTTP_ACCEPT: application/ld+json\r\n"
."HTTP_X_DBP_SIGNATURE: $token\r\n\r\n" ."HTTP_X_DBP_SIGNATURE: $token\r\n\r\n"
. "file=" . base64_encode($this->files[1]['content']) .'file='.base64_encode($this->files[1]['content'])
."&fileName={$this->files[1]['name']}&prefix=$prefix&bucketID=$bucketId" ."&fileName={$this->files[1]['name']}&prefix=$prefix&bucketID=$bucketId"
); );
$c = new CreateFileDataAction($blobService); $c = new CreateFileDataAction($blobService);
...@@ -344,7 +345,7 @@ class CurlGetTest extends ApiTestCase ...@@ -344,7 +345,7 @@ class CurlGetTest extends ApiTestCase
], ],
]; ];
/** @noinspection PhpInternalEntityUsedInspection */ /* @noinspection PhpInternalEntityUsedInspection */
$client->getKernelBrowser()->followRedirects(); $client->getKernelBrowser()->followRedirects();
/** @var Response $response */ /** @var Response $response */
...@@ -419,7 +420,6 @@ class CurlGetTest extends ApiTestCase ...@@ -419,7 +420,6 @@ class CurlGetTest extends ApiTestCase
$this->assertArrayHasKey('hydra:view', $data); $this->assertArrayHasKey('hydra:view', $data);
$this->assertArrayHasKey('hydra:member', $data); $this->assertArrayHasKey('hydra:member', $data);
$this->assertCount(0, $data['hydra:member'], 'More files than expected'); $this->assertCount(0, $data['hydra:member'], 'More files than expected');
} catch (\Throwable $e) { } catch (\Throwable $e) {
echo $e->getTraceAsString()."\n"; echo $e->getTraceAsString()."\n";
$this->fail($e->getMessage()); $this->fail($e->getMessage());
...@@ -429,7 +429,6 @@ class CurlGetTest extends ApiTestCase ...@@ -429,7 +429,6 @@ class CurlGetTest extends ApiTestCase
public function testGetDeleteById() public function testGetDeleteById()
{ {
try { try {
// $client = $this->withUser('foobar'); // $client = $this->withUser('foobar');
$client = static::createClient(); $client = static::createClient();
/** @var BlobService $blobService */ /** @var BlobService $blobService */
...@@ -465,7 +464,7 @@ class CurlGetTest extends ApiTestCase ...@@ -465,7 +464,7 @@ class CurlGetTest extends ApiTestCase
$requestPost = Request::create($url, 'POST', [], [], $requestPost = Request::create($url, 'POST', [], [],
[ [
'file' => new UploadedFile($this->files[0]['path'], $this->files[0]['name'], $this->files[0]['mime']) 'file' => new UploadedFile($this->files[0]['path'], $this->files[0]['name'], $this->files[0]['mime']),
], ],
[ [
'HTTP_ACCEPT' => 'application/ld+json', 'HTTP_ACCEPT' => 'application/ld+json',
...@@ -474,7 +473,7 @@ class CurlGetTest extends ApiTestCase ...@@ -474,7 +473,7 @@ class CurlGetTest extends ApiTestCase
], ],
"HTTP_ACCEPT: application/ld+json\r\n" "HTTP_ACCEPT: application/ld+json\r\n"
."HTTP_X_DBP_SIGNATURE: $token\r\n\r\n" ."HTTP_X_DBP_SIGNATURE: $token\r\n\r\n"
. "file=" . base64_encode($this->files[0]['content']) .'file='.base64_encode($this->files[0]['content'])
."&fileName={$this->files[0]['name']}&prefix=$prefix&bucketID=$bucketId" ."&fileName={$this->files[0]['name']}&prefix=$prefix&bucketID=$bucketId"
); );
$c = new CreateFileDataAction($blobService); $c = new CreateFileDataAction($blobService);
...@@ -507,7 +506,7 @@ class CurlGetTest extends ApiTestCase ...@@ -507,7 +506,7 @@ class CurlGetTest extends ApiTestCase
], ],
]; ];
/** @noinspection PhpInternalEntityUsedInspection */ /* @noinspection PhpInternalEntityUsedInspection */
$client->getKernelBrowser()->followRedirects(); $client->getKernelBrowser()->followRedirects();
$this->assertArrayHasKey($this->files[0]['uuid'], DummyFileSystemService::$fd, 'File data not in dummy store.'); $this->assertArrayHasKey($this->files[0]['uuid'], DummyFileSystemService::$fd, 'File data not in dummy store.');
...@@ -530,7 +529,7 @@ class CurlGetTest extends ApiTestCase ...@@ -530,7 +529,7 @@ class CurlGetTest extends ApiTestCase
], ],
]; ];
/** @noinspection PhpInternalEntityUsedInspection */ /* @noinspection PhpInternalEntityUsedInspection */
$client->getKernelBrowser()->followRedirects(false); $client->getKernelBrowser()->followRedirects(false);
$url = "/blob/files/{$this->files[0]['uuid']}?prefix=$prefix&bucketID=$bucketId&creationTime=$creationTime"; $url = "/blob/files/{$this->files[0]['uuid']}?prefix=$prefix&bucketID=$bucketId&creationTime=$creationTime";
...@@ -555,7 +554,7 @@ class CurlGetTest extends ApiTestCase ...@@ -555,7 +554,7 @@ class CurlGetTest extends ApiTestCase
// ======================================================= // =======================================================
echo "GET all files\n"; echo "GET all files\n";
/** @noinspection PhpInternalEntityUsedInspection */ /* @noinspection PhpInternalEntityUsedInspection */
$client->getKernelBrowser()->followRedirects(); $client->getKernelBrowser()->followRedirects();
$url = "/blob/files/?bucketID=$bucketId&prefix=$prefix&creationTime=$creationTime"; $url = "/blob/files/?bucketID=$bucketId&prefix=$prefix&creationTime=$creationTime";
...@@ -568,7 +567,6 @@ class CurlGetTest extends ApiTestCase ...@@ -568,7 +567,6 @@ class CurlGetTest extends ApiTestCase
$this->assertArrayHasKey('hydra:view', $data); $this->assertArrayHasKey('hydra:view', $data);
$this->assertArrayHasKey('hydra:member', $data); $this->assertArrayHasKey('hydra:member', $data);
$this->assertCount(0, $data['hydra:member'], 'More files than expected'); $this->assertCount(0, $data['hydra:member'], 'More files than expected');
} catch (\Throwable $e) { } catch (\Throwable $e) {
echo $e->getTraceAsString()."\n"; echo $e->getTraceAsString()."\n";
$this->fail($e->getMessage()); $this->fail($e->getMessage());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment