mirror of
https://github.com/MarijnDoeve/TijdVoorDeTest.git
synced 2026-03-06 04:44:19 +01:00
Refactor Base64 encoding/decoding methods for consistency, update controller routes, and improve CI configuration
This commit is contained in:
47
.github/workflows/ci.yml
vendored
47
.github/workflows/ci.yml
vendored
@@ -16,14 +16,11 @@ jobs:
|
|||||||
name: Tests
|
name: Tests
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
-
|
- name: Checkout
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
-
|
- name: Set up Docker Buildx
|
||||||
name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
-
|
- name: Build Docker images
|
||||||
name: Build Docker images
|
|
||||||
uses: docker/bake-action@v4
|
uses: docker/bake-action@v4
|
||||||
with:
|
with:
|
||||||
pull: true
|
pull: true
|
||||||
@@ -35,42 +32,30 @@ jobs:
|
|||||||
*.cache-from=type=gha,scope=${{github.ref}}
|
*.cache-from=type=gha,scope=${{github.ref}}
|
||||||
*.cache-from=type=gha,scope=refs/heads/main
|
*.cache-from=type=gha,scope=refs/heads/main
|
||||||
*.cache-to=type=gha,scope=${{github.ref}},mode=max
|
*.cache-to=type=gha,scope=${{github.ref}},mode=max
|
||||||
-
|
- name: Start services
|
||||||
name: Start services
|
|
||||||
run: docker compose up --wait --no-build
|
run: docker compose up --wait --no-build
|
||||||
-
|
- name: Check HTTP reachability
|
||||||
name: Check HTTP reachability
|
|
||||||
run: curl -v --fail-with-body http://localhost
|
run: curl -v --fail-with-body http://localhost
|
||||||
-
|
- name: Check HTTPS reachability
|
||||||
name: Check HTTPS reachability
|
|
||||||
if: false # Remove this line when the homepage will be configured, or change the path to check
|
if: false # Remove this line when the homepage will be configured, or change the path to check
|
||||||
run: curl -vk --fail-with-body https://localhost
|
run: curl -vk --fail-with-body https://localhost
|
||||||
-
|
- name: Check Mercure reachability
|
||||||
name: Check Mercure reachability
|
|
||||||
run: curl -vkI --fail-with-body https://localhost/.well-known/mercure?topic=test
|
run: curl -vkI --fail-with-body https://localhost/.well-known/mercure?topic=test
|
||||||
-
|
- name: Create test database
|
||||||
name: Create test database
|
|
||||||
if: false # Remove this line if Doctrine ORM is installed
|
|
||||||
run: docker compose exec -T php bin/console -e test doctrine:database:create
|
run: docker compose exec -T php bin/console -e test doctrine:database:create
|
||||||
-
|
- name: Run migrations
|
||||||
name: Run migrations
|
|
||||||
if: false # Remove this line if Doctrine Migrations is installed
|
|
||||||
run: docker compose exec -T php bin/console -e test doctrine:migrations:migrate --no-interaction
|
run: docker compose exec -T php bin/console -e test doctrine:migrations:migrate --no-interaction
|
||||||
-
|
- name: Run PHPUnit
|
||||||
name: Run PHPUnit
|
if: false # Remove this line when the tests are ready
|
||||||
if: false # Remove this line if PHPUnit is installed
|
run: docker compose exec -T php vendor/bin/phpunit
|
||||||
run: docker compose exec -T php bin/phpunit
|
- name: Doctrine Schema Validator
|
||||||
-
|
|
||||||
name: Doctrine Schema Validator
|
|
||||||
if: false # Remove this line if Doctrine ORM is installed
|
|
||||||
run: docker compose exec -T php bin/console -e test doctrine:schema:validate
|
run: docker compose exec -T php bin/console -e test doctrine:schema:validate
|
||||||
lint:
|
lint:
|
||||||
name: Docker Lint
|
name: Docker Lint
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
-
|
- name: Checkout
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
-
|
- name: Lint Dockerfile
|
||||||
name: Lint Dockerfile
|
|
||||||
uses: hadolint/hadolint-action@v3.1.0
|
uses: hadolint/hadolint-action@v3.1.0
|
||||||
|
|
||||||
|
|||||||
3
Justfile
3
Justfile
@@ -22,3 +22,6 @@ fixtures:
|
|||||||
|
|
||||||
translations:
|
translations:
|
||||||
docker compose exec php bin/console translation:extract --domain=messages --force --format=yaml --sort=asc --clean nl
|
docker compose exec php bin/console translation:extract --domain=messages --force --format=yaml --sort=asc --clean nl
|
||||||
|
|
||||||
|
fix-cs:
|
||||||
|
docker compose exec php vendor/bin/php-cs-fixer fix
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ use App\Entity\Quiz;
|
|||||||
use App\Entity\Season;
|
use App\Entity\Season;
|
||||||
use App\Repository\CandidateRepository;
|
use App\Repository\CandidateRepository;
|
||||||
use App\Repository\SeasonRepository;
|
use App\Repository\SeasonRepository;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
|
|||||||
@@ -6,9 +6,11 @@ namespace App\Controller;
|
|||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
|
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
|
||||||
|
|
||||||
|
#[AsController]
|
||||||
class LoginController extends AbstractController
|
class LoginController extends AbstractController
|
||||||
{
|
{
|
||||||
#[Route(path: '/login', name: 'app_login_login')]
|
#[Route(path: '/login', name: 'app_login_login')]
|
||||||
|
|||||||
21
src/Controller/PrepareEliminationController.php
Normal file
21
src/Controller/PrepareEliminationController.php
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
|
|
||||||
|
#[Route(path: '/backoffice/elimination')]
|
||||||
|
final class PrepareEliminationController extends AbstractController
|
||||||
|
{
|
||||||
|
#[Route('/prepare', name: 'app_prepare_elimination')]
|
||||||
|
public function index(): Response
|
||||||
|
{
|
||||||
|
return $this->render('prepare_elimination/index.html.twig', [
|
||||||
|
'controller_name' => 'PrepareEliminationController',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -60,7 +60,7 @@ final class QuizController extends AbstractController
|
|||||||
$data = $form->getData();
|
$data = $form->getData();
|
||||||
$name = $data['name'];
|
$name = $data['name'];
|
||||||
|
|
||||||
return $this->redirectToRoute('app_quiz_quizpage', ['seasonCode' => $season->getSeasonCode(), 'nameHash' => Base64::base64_url_encode($name)]);
|
return $this->redirectToRoute('app_quiz_quizpage', ['seasonCode' => $season->getSeasonCode(), 'nameHash' => Base64::base64UrlEncode($name)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render('quiz/enter_name.twig', ['season' => $season, 'form' => $form]);
|
return $this->render('quiz/enter_name.twig', ['season' => $season, 'form' => $form]);
|
||||||
@@ -90,7 +90,7 @@ final class QuizController extends AbstractController
|
|||||||
return $this->redirectToRoute('app_quiz_entername', ['seasonCode' => $season->getSeasonCode()]);
|
return $this->redirectToRoute('app_quiz_entername', ['seasonCode' => $season->getSeasonCode()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$candidate = new Candidate(Base64::base64_url_decode($nameHash));
|
$candidate = new Candidate(Base64::base64UrlDecode($nameHash));
|
||||||
$candidateRepository->save($candidate);
|
$candidateRepository->save($candidate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -135,6 +135,6 @@ class Candidate
|
|||||||
|
|
||||||
public function getNameHash(): string
|
public function getNameHash(): string
|
||||||
{
|
{
|
||||||
return Base64::base64_url_encode($this->name);
|
return Base64::base64UrlEncode($this->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,15 +8,13 @@ use Safe\Exceptions\UrlException;
|
|||||||
|
|
||||||
class Base64
|
class Base64
|
||||||
{
|
{
|
||||||
private function __construct() {}
|
public static function base64UrlEncode(string $input): string
|
||||||
|
|
||||||
public static function base64_url_encode(string $input): string
|
|
||||||
{
|
{
|
||||||
return rtrim(strtr(base64_encode($input), '+/', '-_'), '=');
|
return rtrim(strtr(base64_encode($input), '+/', '-_'), '=');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @throws UrlException */
|
/** @throws UrlException */
|
||||||
public static function base64_url_decode(string $input): string
|
public static function base64UrlDecode(string $input): string
|
||||||
{
|
{
|
||||||
return \Safe\base64_decode(strtr($input, '-_', '+/'), true);
|
return \Safe\base64_decode(strtr($input, '-_', '+/'), true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class CandidateRepository extends ServiceEntityRepository
|
|||||||
public function getCandidateByHash(Season $season, string $hash): ?Candidate
|
public function getCandidateByHash(Season $season, string $hash): ?Candidate
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$name = Base64::base64_url_decode($hash);
|
$name = Base64::base64UrlDecode($hash);
|
||||||
} catch (UrlException) {
|
} catch (UrlException) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
3
templates/backoffice/prepare_elimination/index.html.twig
Normal file
3
templates/backoffice/prepare_elimination/index.html.twig
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{% extends 'backoffice/base.html.twig' %}
|
||||||
|
{% block body %}
|
||||||
|
{% endblock %}
|
||||||
Reference in New Issue
Block a user