Complete TASK_CHECKUP: security, UX, tests, coverage, accessibility, config externalization

Billetterie:
- Partial refund support (STATUS_PARTIALLY_REFUNDED, refundedAmount field, migration)
- Race condition fix: PESSIMISTIC_WRITE lock on stock decrement in transaction
- Idempotency key on PaymentIntent::create, reuse existing PI if stripeSessionId set
- Disable checkout when event ended (server 400 + template hide)
- Webhook deduplication via cache (24h TTL on stripe event.id)
- Email validation (filter_var) in OrderController guest flow
- JSON cart validation (structure check before processing)
- Invitation expiration after 7 days (isExpired method + landing page message)
- Stripe Checkout fallback when JS fails to load (noscript + redirect)

Config externalization:
- Move Stripe fees (STRIPE_FEE_RATE, STRIPE_FEE_FIXED) and admin email (ADMIN_EMAIL) to .env/services.yaml
- Replace all hardcoded contact@e-cosplay.fr across 13 files
- MailerService: getAdminEmail()/getAdminFrom(), default $from=null resolves to admin

UX & Accessibility:
- ARIA tabs: role=tablist/tab/tabpanel, aria-selected, keyboard nav (arrows, Home, End)
- aria-label on cart +/- buttons and editor toolbar buttons
- tabindex=0 on editor toolbar buttons for keyboard access
- data-confirm handler in app.js (was only in admin.js)
- Cart error feedback on checkout failure
- Billet designer save feedback (loading/success/error states)
- Stock polling every 30s with rupture/low stock badges
- Back to event link on payment page

Security:
- HTML sanitizer: BLOCKED_TAGS list (script, style, iframe, svg, etc.) - content fully removed
- Stripe polling timeout (15s max) with fallback redirect
- Rate limiting on public order access (20/5min)
- .catch() on all fetch() calls (sortable, billet-designer)

Tests (92% PHP, 100% JS lines):
- PCOV added to dev Dockerfile
- Test DB setup: .env.test with DATABASE_URL, Redis auth, Meilisearch key
- Rate limiter disabled in test env
- Makefile: test_db_setup, test_db_reset, run_test_php, run_test_coverage_php/js
- New tests: InvitationFlowTest (21), AuditServiceTest (4), ExportServiceTest (9), InvoiceServiceTest (4)
- New tests: SuspendedUserSubscriberTest, RateLimiterSubscriberTest, MeilisearchServiceTest
- New tests: Stripe webhook payment_failed (6) + charge.refunded (6)
- New tests: BilletBuyer refund, User suspended, OrganizerInvitation expiration
- JS tests: stock polling (6), data-confirm (2), copy-url restore (1), editor ARIA (2), XSS (9), tabs keyboard (9)
- ESLint + PHP CS Fixer: 0 errors
- SonarQube exclusions aligned with vitest coverage config

Infra:
- Meilisearch consistency command (app:meilisearch:check-consistency --fix) + cron daily 3am
- MeilisearchService: getAllDocumentIds(), listIndexes()

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Serreau Jovann
2026-03-23 11:14:06 +01:00
parent 61200adc74
commit 04927ec988
68 changed files with 3317 additions and 141 deletions

View File

@@ -3,9 +3,15 @@
{% block title %}Remboursement - {{ order.event.title }}{% endblock %}
{% block content %}
{% if isPartial|default(false) %}
<h2>Remboursement partiel</h2>
<p>Bonjour {{ order.firstName }},</p>
<p>Un remboursement partiel a ete effectue sur votre commande <strong>{{ order.orderNumber }}</strong> pour l'evenement <strong>{{ order.event.title }}</strong>.</p>
{% else %}
<h2>Votre commande a ete remboursee</h2>
<p>Bonjour {{ order.firstName }},</p>
<p>Votre commande <strong>{{ order.orderNumber }}</strong> pour l'evenement <strong>{{ order.event.title }}</strong> a ete remboursee.</p>
<p>Votre commande <strong>{{ order.orderNumber }}</strong> pour l'evenement <strong>{{ order.event.title }}</strong> a ete integralement remboursee.</p>
{% endif %}
<table style="width: 100%; border-collapse: collapse; margin: 20px 0; border: 2px solid #111827;">
<tr style="border-bottom: 1px solid #e5e7eb;">
@@ -14,11 +20,18 @@
</tr>
<tr style="border-bottom: 1px solid #e5e7eb;">
<td style="padding: 10px 12px; font-weight: 900; text-transform: uppercase; font-size: 11px; color: #6b7280;">Montant rembourse</td>
<td style="padding: 10px 12px; font-weight: 900; color: #16a34a;">{{ order.totalHTDecimal|number_format(2, ',', ' ') }} &euro;</td>
<td style="padding: 10px 12px; font-weight: 900; color: #16a34a;">{{ (refundedAmount|default(order.totalHTDecimal))|number_format(2, ',', ' ') }} &euro;</td>
</tr>
{% if isPartial|default(false) %}
<tr>
<td style="padding: 10px 12px; font-weight: 900; text-transform: uppercase; font-size: 11px; color: #6b7280;">Total commande</td>
<td style="padding: 10px 12px; font-weight: 700;">{{ order.totalHTDecimal|number_format(2, ',', ' ') }} &euro;</td>
</tr>
{% endif %}
</table>
<p>Le remboursement sera visible sur votre releve bancaire sous 5 a 10 jours ouvrables. Les billets associes a cette commande ont ete invalides.</p>
<p>Le remboursement sera visible sur votre releve bancaire sous 5 a 10 jours ouvrables.
{% if not isPartial|default(false) %} Les billets associes a cette commande ont ete invalides.{% else %} Vos billets restent valides.{% endif %}</p>
<p style="font-size: 12px; color: #9ca3af;">Si vous avez des questions, contactez l'organisateur de l'evenement.</p>
{% endblock %}

View File

@@ -72,10 +72,17 @@
</div>
{% if categories|length > 0 %}
<div class="card-brutal overflow-hidden p-0 mt-8" id="billetterie">
{% set event_ended = event.endAt and event.endAt < date() %}
<div class="card-brutal overflow-hidden p-0 mt-8" id="billetterie" data-stock-url="{{ path('app_event_stock', {id: event.id}) }}">
<div class="section-header">
<h2 class="text-sm font-black uppercase tracking-widest text-white">Billetterie</h2>
</div>
{% if event_ended %}
<div class="p-6">
<p class="font-black uppercase text-red-600 text-center">Cet evenement est termine. La billetterie est fermee.</p>
</div>
{% endif %}
{% if not event_ended %}
<div class="p-6">
{% for category in categories %}
{% if category.active %}
@@ -97,9 +104,17 @@
{% if billet.description %}
<p class="text-xs text-gray-500 font-bold mt-1">{{ billet.description }}</p>
{% endif %}
{% if not billet.unlimited and billet.quantity is not null %}
<p class="text-[10px] text-gray-400 font-bold mt-1">{{ billet.quantity }} place{{ billet.quantity > 1 ? 's' : '' }} disponible{{ billet.quantity > 1 ? 's' : '' }}</p>
{% endif %}
<p class="text-[10px] font-bold mt-1" data-stock-label>
{% if not billet.unlimited and billet.quantity is not null %}
{% if billet.quantity == 0 %}
<span class="text-red-600">Rupture de stock</span>
{% elseif billet.quantity <= 10 %}
<span class="text-orange-500">Plus que {{ billet.quantity }} place{{ billet.quantity > 1 ? 's' : '' }} !</span>
{% else %}
<span class="text-gray-400">{{ billet.quantity }} place{{ billet.quantity > 1 ? 's' : '' }} disponible{{ billet.quantity > 1 ? 's' : '' }}</span>
{% endif %}
{% endif %}
</p>
</div>
</div>
@@ -107,9 +122,9 @@
<p class="font-black text-indigo-600 text-lg w-24 text-right">{{ billet.priceHTDecimal|number_format(2, ',', ' ') }} &euro;</p>
<div class="flex items-center border-2 border-gray-900">
<button type="button" data-cart-minus class="w-9 h-9 flex items-center justify-center font-black text-lg hover:bg-gray-100 transition-all cursor-pointer select-none">-</button>
<input type="number" data-cart-qty min="0" max="{{ billet.quantity ?? 99 }}" value="0" class="w-12 h-9 text-center font-black text-sm border-x-2 border-gray-900 outline-none" readonly>
<button type="button" data-cart-plus class="w-9 h-9 flex items-center justify-center font-black text-lg hover:bg-gray-100 transition-all cursor-pointer select-none">+</button>
<button type="button" data-cart-minus aria-label="Retirer un {{ billet.name }}" class="w-9 h-9 flex items-center justify-center font-black text-lg hover:bg-gray-100 transition-all cursor-pointer select-none">-</button>
<input type="number" data-cart-qty min="0" max="{{ billet.quantity ?? 99 }}" value="0" aria-label="Quantite {{ billet.name }}" class="w-12 h-9 text-center font-black text-sm border-x-2 border-gray-900 outline-none" readonly>
<button type="button" data-cart-plus aria-label="Ajouter un {{ billet.name }}" class="w-9 h-9 flex items-center justify-center font-black text-lg hover:bg-gray-100 transition-all cursor-pointer select-none">+</button>
</div>
<p class="font-black text-sm w-24 text-right" data-cart-line-total>0,00 &euro;</p>
@@ -134,11 +149,15 @@
<span class="text-xs font-bold text-gray-400 uppercase tracking-widest">Articles</span>
<span class="font-black text-sm" id="cart-count">0</span>
</div>
<div id="cart-error" class="hidden flash-error mb-4">
<p class="font-black text-sm" id="cart-error-text"></p>
</div>
<button type="button" id="cart-checkout" disabled data-order-url="{{ path('app_order_create', {id: event.id}) }}" class="w-full btn-brutal font-black uppercase text-sm tracking-widest bg-indigo-600 text-white hover:bg-indigo-800 transition-all disabled:opacity-30 disabled:cursor-not-allowed">
Commander
</button>
</div>
</div>
{% endif %}
</div>
{% endif %}

View File

@@ -175,7 +175,15 @@
</div>
</section>
{% if invitation.status in ['sent', 'opened'] %}
{% if expired|default(false) %}
<section class="py-12 px-4 border-t-8 border-gray-900 bg-white">
<div class="max-w-xl mx-auto text-center">
<div class="text-5xl mb-4 text-red-600">&#9201;</div>
<p class="font-black uppercase text-lg tracking-tighter">Invitation expiree</p>
<p class="text-sm font-bold text-gray-500 mt-2">Cette invitation a expire. Veuillez contacter l'administrateur pour en recevoir une nouvelle.</p>
</div>
</section>
{% elseif invitation.status in ['sent', 'opened'] %}
<section class="py-12 px-4 border-t-8 border-gray-900 bg-white">
<div class="max-w-xl mx-auto text-center">
<h2 class="text-2xl font-black uppercase tracking-tighter mb-6">Votre reponse</h2>

View File

@@ -77,11 +77,16 @@
</div>
</div>
<div class="card-brutal overflow-hidden" id="payment-card" data-stripe-key="{{ stripe_public_key }}" data-stripe-account="{{ stripe_account }}" data-intent-url="{{ path('app_order_create_intent', {id: order.id}) }}" data-return-url="{{ url('app_order_success', {id: order.id}) }}" data-amount="{{ order.totalHTDecimal|number_format(2, ',', ' ') }}">
<div class="card-brutal overflow-hidden" id="payment-card" data-stripe-key="{{ stripe_public_key }}" data-stripe-account="{{ stripe_account }}" data-intent-url="{{ path('app_order_create_intent', {id: order.id}) }}" data-return-url="{{ url('app_order_success', {id: order.id}) }}" data-fallback-url="{{ path('app_order_checkout_fallback', {id: order.id}) }}" data-amount="{{ order.totalHTDecimal|number_format(2, ',', ' ') }}">
<div class="section-header">
<h2 class="text-[10px] font-black uppercase tracking-widest text-white">Paiement securise</h2>
</div>
<div class="p-6">
<noscript>
<a href="{{ path('app_order_checkout_fallback', {id: order.id}) }}" class="w-full btn-brutal font-black uppercase text-sm tracking-widest bg-indigo-600 text-white hover:bg-indigo-800 transition-all block text-center">
Payer {{ order.totalHTDecimal|number_format(2, ',', ' ') }} &euro; via Stripe
</a>
</noscript>
<div id="payment-element" class="mb-6"></div>
<div id="payment-message" class="hidden flash-error mb-4">
<p class="font-black text-sm" id="payment-message-text"></p>
@@ -93,5 +98,7 @@
</div>
</div>
<a href="{{ path('app_event_detail', {orgaSlug: order.event.account.slug, id: order.event.id, eventSlug: order.event.slug}) }}" class="block text-center mt-6 text-sm font-bold text-gray-500 hover:text-gray-900 transition-colors">&larr; Retour a l'evenement</a>
</div>
{% endblock %}