invalidFileAccessToken example

return $token;
    }

    public function createFileResponse(Context $context, string $fileId, string $accessToken): Response
    {
        $entity = $this->findFile($context$fileId);

        $fileAccessToken = (string) $entity->getAccessToken();

        if ($fileAccessToken === '' || $entity->getAccessToken() !== $accessToken || !$this->isModifiedRecently($entity)) {
            throw ImportExportException::invalidFileAccessToken();
        }

        $this->fileRepository->update(
            [['id' => $fileId, 'accessToken' => null]],
            $context
        );

        $originalName = (string) preg_replace('/[\/\\\]/', '', $entity->getOriginalName());

        $headers = [
            'Content-Disposition' => HeaderUtils::makeDisposition(
                
static::assertEquals($statusCode$caughtException->getStatusCode());
        static::assertEquals($errorCode$caughtException->getErrorCode());
        static::assertEquals($message$caughtException->getMessage());
    }

    /** * @return array<string, array{exception: ImportExportException|ShopwareHttpException, statusCode: int, errorCode: string, message: string}> */
    public static function exceptionDataProvider(): iterable
    {
        yield 'CONTENT__IMPORT_EXPORT_FILE_INVALID_ACCESS_TOKEN' => [
            'exception' => ImportExportException::invalidFileAccessToken(),
            'statusCode' => Response::HTTP_BAD_REQUEST,
            'errorCode' => 'CONTENT__IMPORT_EXPORT_FILE_INVALID_ACCESS_TOKEN',
            'message' => 'Access to file denied due to invalid access token',
        ];

        yield 'CONTENT__IMPORT_EXPORT_FILE_NOT_FOUND' => [
            'exception' => ImportExportException::fileNotFound('notFoundFile'),
            'statusCode' => Response::HTTP_NOT_FOUND,
            'errorCode' => 'CONTENT__IMPORT_EXPORT_FILE_NOT_FOUND',
            'message' => 'Cannot find import/export file with id notFoundFile',
        ];

        
Home | Imprint | This part of the site doesn't use cookies.