Skip to content

Commit ed3b111

Browse files
committed
fix: improve error logging in public API e2e tests
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
1 parent 0931e4d commit ed3b111

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

.github/scripts/public-api-e2e-tests.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,28 @@ api() {
6969
BODY="$(printf '%s' "$response" | sed '$d')"
7070
}
7171

72+
# Print a short, non-secret snippet of the last res on failure (never tokens).
73+
log_fail_body() {
74+
local snippet
75+
snippet="$(jq -c 'if type == "object" then del(.access_token, .refresh_token, .id_token, .client_secret) else . end' <<<"$BODY" 2>/dev/null || printf '%s' "$BODY")"
76+
snippet="${snippet:0:500}"
77+
printf ' body: %s\n' "$snippet"
78+
}
79+
7280
check() {
7381
local name=$1 expected=$2
7482
shift 2
7583
if [[ $HTTP_CODE != "$expected" ]]; then
7684
printf ' FAIL %s — expected HTTP %s, got %s\n' "$name" "$expected" "$HTTP_CODE"
77-
jq . <<<"$BODY" 2>/dev/null || printf '%s\n' "$BODY"
85+
log_fail_body
7886
FAIL=$((FAIL + 1))
7987
return
8088
fi
8189
local expr
8290
for expr in "$@"; do
8391
if ! jq -e "$expr" >/dev/null 2>&1 <<<"$BODY"; then
8492
printf ' FAIL %s (%s)\n' "$name" "$expr"
85-
jq . <<<"$BODY" 2>/dev/null || printf '%s\n' "$BODY"
93+
log_fail_body
8694
FAIL=$((FAIL + 1))
8795
return
8896
fi

0 commit comments

Comments
 (0)