Add a minimal payment mock server for end-to-end testing

This commit is contained in:
Marshal
2026-08-01 18:59:14 +00:00
parent 8ccb0e1558
commit 21fdf144ca
8 changed files with 420 additions and 105 deletions

View File

@@ -105,6 +105,31 @@ services:
timeout: 3s
retries: 10
# Stand-in for the payment microservice. The API's reconcile-before-expire
# step (booking-batch.service.ts:3492) asks the gateway whether a late
# payment landed before it will expire an unpaid hold, and treats ANY error
# as "unverifiable" — which defers the expiry forever. PAYMENT_API_URL
# otherwise defaults to the real paymentcallback.triaplc.com, unreachable
# from here, so without this every expiry scenario hangs. See
# payment-mock/server.js.
payment-mock-e2e:
image: node:20-alpine
volumes:
- ./e2e/freight/payment-mock:/app:ro
working_dir: /app
command: ["node", "server.js"]
healthcheck:
test:
[
"CMD",
"node",
"-e",
"fetch('http://localhost:4500/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))",
]
interval: 3s
timeout: 3s
retries: 10
# Stand-in for https://etrade.gov.et — ETradeService's base URL is
# hardcoded (not env-configurable like Fayda's endpoints), so this is
# reached by DNS alias instead: the "etrade.gov.et" network alias below
@@ -166,6 +191,8 @@ services:
condition: service_healthy
etrade-mock-e2e:
condition: service_healthy
payment-mock-e2e:
condition: service_healthy
environment:
PORT: "3001"
DB_HOST: postgres-freight-e2e
@@ -202,6 +229,10 @@ services:
FAYDA_ENABLED: "true"
FAYDA_CLIENT_ID: e2e-fayda-client
FAYDA_AUTHORIZATION_ENDPOINT: http://fayda-mock-e2e:4400/authorize
# Without this the payment client calls the real (unreachable)
# paymentcallback.triaplc.com and every unpaid hold defers instead of
# expiring — see payment-mock/server.js.
PAYMENT_API_URL: http://payment-mock-e2e:4500
FAYDA_TOKEN_ENDPOINT: http://fayda-mock-e2e:4400/token
FAYDA_USERINFO_ENDPOINT: http://fayda-mock-e2e:4400/userinfo
FAYDA_REDIRECT_URI: http://localhost:${E2E_PORTAL_PORT:-5373}/callback