Fix LibreTranslate deploy: healthcheck from PHP container, ignore_errors, add QR code tests

- Ansible: healthcheck via PHP container (curl from php, not libretranslate)
- Ansible: exit 0 if LibreTranslate not ready (don't block deploy)
- Ansible: ignore_errors on translation step (non-blocking)
- AccountControllerTest: add testEventQrCode (PNG response) and testEventQrCodeDeniedForOtherUser (403)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Serreau Jovann
2026-03-23 18:12:18 +01:00
parent acccd4a0c4
commit 82c90f5b8b
2 changed files with 35 additions and 2 deletions

View File

@@ -138,10 +138,11 @@
- name: Wait for LibreTranslate to be healthy - name: Wait for LibreTranslate to be healthy
shell: | shell: |
for i in $(seq 1 60); do for i in $(seq 1 60); do
docker compose -f docker-compose-prod.yml exec -T libretranslate curl -sf http://localhost:5000/languages >/dev/null 2>&1 && exit 0 docker compose -f docker-compose-prod.yml exec -T php curl -sf http://libretranslate:5000/languages >/dev/null 2>&1 && exit 0
sleep 5 sleep 5
done done
exit 1 echo "LibreTranslate not ready after 5 minutes, skipping translation"
exit 0
args: args:
chdir: /var/www/e-ticket chdir: /var/www/e-ticket
@@ -149,6 +150,7 @@
command: make trans_prod command: make trans_prod
args: args:
chdir: /var/www/e-ticket chdir: /var/www/e-ticket
ignore_errors: true
- name: Ensure uploads directories exist with correct permissions - name: Ensure uploads directories exist with correct permissions
file: file:

View File

@@ -1955,6 +1955,37 @@ class AccountControllerTest extends WebTestCase
return $category; return $category;
} }
public function testEventQrCode(): void
{
$client = static::createClient();
$em = static::getContainer()->get(EntityManagerInterface::class);
$user = $this->createUser(['ROLE_ORGANIZER'], true);
$event = $this->createEvent($em, $user);
$client->loginUser($user);
$client->request('GET', '/mon-compte/evenement/'.$event->getId().'/qrcode');
self::assertResponseIsSuccessful();
self::assertSame('image/png', $client->getResponse()->headers->get('Content-Type'));
self::assertStringContainsString('attachment', $client->getResponse()->headers->get('Content-Disposition'));
}
public function testEventQrCodeDeniedForOtherUser(): void
{
$client = static::createClient();
$em = static::getContainer()->get(EntityManagerInterface::class);
$user = $this->createUser(['ROLE_ORGANIZER'], true);
$otherUser = $this->createUser(['ROLE_ORGANIZER'], true);
$event = $this->createEvent($em, $user);
$client->loginUser($otherUser);
$client->request('GET', '/mon-compte/evenement/'.$event->getId().'/qrcode');
self::assertResponseStatusCodeSame(403);
}
public function testGetAllowedBilletTypesBasic(): void public function testGetAllowedBilletTypesBasic(): void
{ {
$types = \App\Controller\AccountController::getAllowedBilletTypes('basic'); $types = \App\Controller\AccountController::getAllowedBilletTypes('basic');