diff --git a/hydra-gates/scripts/lib/test_or_abstraction_pdok.sh b/hydra-gates/scripts/lib/test_or_abstraction_pdok.sh new file mode 100755 index 00000000..a95ecd5d --- /dev/null +++ b/hydra-gates/scripts/lib/test_or_abstraction_pdok.sh @@ -0,0 +1,200 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: EUPL-1.2 +# +# test_or_abstraction_pdok.sh — self-test for rule 1 of +# scripts/lint-or-abstraction-anti-patterns.sh (shared-pdok-via-openconnector). +# +# WHY THIS EXISTS +# --------------- +# Until 2026-08-09 the rule was `grep -rl api.pdok.nl`. Measured across all 18 +# Conduction app repositories at origin/development it produced three findings, +# of which TWO were the opposite of a violation: +# +# * procest src/services/pdokService.js is the openconnector-routed shim; its +# only match was a docblock line saying direct calls are NOT permitted and +# citing this very rule by name. +# * openregister lib/Service/Geo/PdokGeocoder.php matched on a const holding +# the base URL that it hands to OpenConnector's CallService. It owns no +# HTTP client at all. +# +# The rule now reads code rather than prose, and distinguishes a file that +# dispatches through OpenConnector from one that carries its own transport. +# +# THE POINT OF THIS SUITE is the other direction. Narrowing a matcher is how a +# gate gets quietly neutered, so the FIRE assertions below are the ratchet: a +# real direct call must keep failing, and neither a comment naming +# "openconnector" nor an unrecognised HTTP client may buy silence. If a future +# edit widens the suppression, these go red. +# +# Run: bash scripts/lib/test_or_abstraction_pdok.sh (exit 0 = pass) +set -uo pipefail + +LIB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)" +GATE="${LIB_DIR}/../lint-or-abstraction-anti-patterns.sh" + +if [ ! -f "${GATE}" ]; then + echo "FAIL — gate script not found at ${GATE}; this suite cannot assert anything." + echo "Refusing to report passes for a subject that is absent." + exit 1 +fi + +FAILS=0 +WORK="$(mktemp -d)" +trap 'rm -rf "${WORK}"' EXIT + +mkdir -p "${WORK}/lib/Service" "${WORK}/src" "${WORK}/appinfo" +printf '\n\n fixtureapp\n\n' > "${WORK}/appinfo/info.xml" + +# Force BLOCK mode so the exit status carries the verdict. In WARN mode the +# script returns 0 whether or not anything matched — which is exactly how these +# findings stayed invisible — so a suite that read the byte in WARN mode would +# assert nothing. +run_gate() ( + cd "${WORK}" && HYDRA_OR_GATE_BLOCK_AFTER_EPOCH=0 bash "${GATE}" >"${WORK}/.out" 2>&1 + echo $? +) + +assert_rc() { #