-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUGFIX] Do not cache public json endpoint (#337)
* [BUGFIX] Do not cache public json endpoint * Require symfony/cache-contracts * [TASK] Remove not needed constructor parameter and string check * Check returned types * Apply CS rules * Reintroduce string check * Type check on retrival * Fix sqlite3 installation * Remove string check Co-authored-by: Simon Gilli <[email protected]>
- Loading branch information
1 parent
dfc6dac
commit 591f337
Showing
9 changed files
with
147 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the package t3o/get.typo3.org. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE file that was distributed with this source code. | ||
* | ||
* The TYPO3 project - inspiring people to share! | ||
*/ | ||
|
||
namespace App\Controller; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\Routing\Annotation\Route; | ||
|
||
#[Route(path: '/json', methods: ['GET'], name: 'json_')] | ||
class JsonController extends AbstractController | ||
{ | ||
public function __construct( | ||
private \App\Service\LegacyDataService $legacyDataService, | ||
) { | ||
} | ||
|
||
// Route has set a priority to avoid conflicts with `specificversion` | ||
#[Route(path: '', methods: ['GET'], name: 'index', priority: 1)] | ||
public function index(): Response | ||
{ | ||
$content = $this->legacyDataService->getReleaseJson(); | ||
$headers = [ | ||
'Content-type' => 'application/json', | ||
'Access-Control-Allow-Origin' => '*', | ||
]; | ||
return new Response($content, \Symfony\Component\HttpFoundation\Response::HTTP_OK, $headers); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the package t3o/get.typo3.org. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE file that was distributed with this source code. | ||
* | ||
* The TYPO3 project - inspiring people to share! | ||
*/ | ||
|
||
namespace App\Tests\Functional\Controller\Web; | ||
|
||
use App\DataFixtures\MajorVersionFixtures; | ||
use App\DataFixtures\ReleaseFixtures; | ||
use App\DataFixtures\RequirementFixtures; | ||
use App\Tests\Functional\AbstractCase; | ||
use RuntimeException; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
class JsonControllerTest extends AbstractCase | ||
{ | ||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
$this->addFixture(new MajorVersionFixtures()); | ||
$this->addFixture(new ReleaseFixtures()); | ||
$this->addFixture(new RequirementFixtures()); | ||
$this->executeFixtures(); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function index(): void | ||
{ | ||
$this->client->request('GET', '/json'); | ||
$response = $this->client->getResponse(); | ||
|
||
if (($json = $response->getContent()) === false) { | ||
throw new RuntimeException('Error no response content.', 1_657_642_832); | ||
} | ||
|
||
if (!\is_array($content = json_decode($json, true, 512, JSON_THROW_ON_ERROR))) { | ||
throw new RuntimeException('Error array expected.', 1_657_642_833); | ||
} | ||
|
||
self::assertSame(Response::HTTP_OK, $response->getStatusCode()); | ||
self::assertArrayHasKey('10', $content); | ||
self::assertArrayHasKey('latest_stable', $content); | ||
self::assertArrayHasKey('latest_old_stable', $content); | ||
self::assertArrayHasKey('latest_lts', $content); | ||
self::assertArrayHasKey('latest_old_lts', $content); | ||
} | ||
} |