#!/usr/bin/env bash # # Acceptance check for the local stack (S-B04, #110): a fresh `make local` must complete the whole # flow with NO manual seeding. Run against an already-up local stack (infra/docker-compose.local.yml) # via the host-published ports. It exercises, and thereby covers, the three bring-up gaps the slice # fixes: # # 1. zaaktype seeded + ACL wired -> a submitted registration opens a zaak (zaakUrl gets filled). # 2. diploma-eligibility DMN deployed -> providing documents completes WachtOpDocumenten, routes # through the DMN, and the case lands on Beoordelen (visible in the behandel werkbak). # 3. NRC abonnement registered -> the zaak shows up in the openbaar (public) register. # # Before the fix this fails at step 1 (ACL points at a placeholder zaaktype -> OpenZaak 400). set -euo pipefail DOM=${DOM:-http://localhost:8130} # domain BFF=${BFF:-http://localhost:8080} # bff (openbaar register) BSN=${BSN:-123456782} # A minimal, valid PDF, base64-encoded (the diploma upload). PDF_B64="$(printf '%%PDF-1.4\n1 0 obj<>endobj\ntrailer<>\n%%%%EOF\n' | base64 | tr -d '\n')" echo ">> 1. submit a registration (no manual seeding expected)" loc="$(curl -fsS -D - -o /dev/null -X POST "$DOM/registrations" \ -H 'Content-Type: application/json' -d "{\"bsn\":\"$BSN\"}" \ | sed -n 's/\r$//; s/^[Ll]ocation: //p' | head -1)" [ -n "$loc" ] || { echo "FAIL: POST /registrations returned no Location" >&2; exit 1; } id="${loc##*/}" echo " accepted: $id" echo ">> 2. poll until the ACL opens the zaak (proves the zaaktype is seeded + wired)" zaak="" for _ in $(seq 1 30); do zaak="$(curl -fsS "$DOM$loc" | python3 -c 'import sys,json;print(json.load(sys.stdin).get("zaakUrl") or "")' 2>/dev/null || true)" [ -n "$zaak" ] && break sleep 3 done [ -n "$zaak" ] || { echo "FAIL: zaak never opened — ACL zaaktype not wired (gap 1)" >&2; exit 1; } echo " zaak opened: $zaak" echo ">> 3. provide documents (proves the diploma-eligibility DMN is deployed)" code="$(curl -s -o /dev/null -w '%{http_code}' -X POST "$DOM/registrations/$id/documents" \ -H 'Content-Type: application/json' \ -d "{\"bsn\":\"$BSN\",\"contentBase64\":\"$PDF_B64\",\"fileName\":\"diploma.pdf\",\"contentType\":\"application/pdf\"}")" [ "$code" = "204" ] || { echo "FAIL: provide documents -> $code (DMN missing routes WachtOpDocumenten to a 404 — gap 2)" >&2; exit 1; } echo " documents accepted (204)" echo ">> 4. poll the werkbak until the registration awaits beoordeling (reached Beoordelen)" in_werkbak="" for _ in $(seq 1 20); do in_werkbak="$(curl -fsS "$DOM/behandel/werkbak" | python3 -c "import sys,json;print(any(r.get('registrationId')=='$id' for r in json.load(sys.stdin)))" 2>/dev/null || true)" [ "$in_werkbak" = "True" ] && break sleep 3 done [ "$in_werkbak" = "True" ] || { echo "FAIL: registration never reached the werkbak (gap 2)" >&2; exit 1; } echo " in the werkbak" echo ">> 5. poll the openbaar register until the reference is publicly visible (proves NRC abonnement)" public="" for _ in $(seq 1 30); do public="$(curl -fsS "$BFF/openbaar/register" | python3 -c "import sys,json;print(any(r.get('reference')=='$id' for r in json.load(sys.stdin)))" 2>/dev/null || true)" [ "$public" = "True" ] && break sleep 3 done [ "$public" = "True" ] || { echo "FAIL: reference never appeared in the openbaar register — NRC abonnement not registered (gap 3)" >&2; exit 1; } echo " visible in the openbaar register" echo "OK — a fresh local stack completed the flow with no manual seeding (zaaktype + DMN + abonnement)"