Skip to content

Commit 3a91e9f

Browse files
sij411claude
andcommitted
Redact raw API responses and fail loudly on follow in Sharkey provision
Replace raw JSON response echoes with safe ok/failed status messages to avoid logging unnecessary API internals. Make the follow request fail the script immediately on error instead of silently continuing with `|| true`, which would cause confusing downstream test failures. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 458220e commit 3a91e9f

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

test/smoke/sharkey/provision.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ ADMIN_RAW=$(curl -sf -X POST "$SHARKEY_URL/api/admin/accounts/create" \
1616
\"password\": \"adminpassword123\",
1717
\"setupPassword\": \"$SETUP_PASSWORD\"
1818
}" 2>&1) || true
19-
echo " admin creation response: ${ADMIN_RAW:0:200}"
19+
echo " admin creation: $(echo "$ADMIN_RAW" | jq -r 'if .token then "ok" elif .error then .error.message // .error else "unknown" end' 2>/dev/null || echo "non-JSON response")"
2020

2121
ADMIN_TOKEN=$(echo "$ADMIN_RAW" | jq -r '.token // empty' 2>/dev/null || true)
2222
if [ -z "$ADMIN_TOKEN" ]; then
@@ -41,7 +41,7 @@ TEST_RAW=$(curl -sf -X POST "$SHARKEY_URL/api/admin/accounts/create" \
4141
\"username\": \"testuser\",
4242
\"password\": \"testpassword123\"
4343
}" 2>&1) || true
44-
echo " testuser creation response: ${TEST_RAW:0:200}"
44+
echo " testuser creation: $(echo "$TEST_RAW" | jq -r 'if .token then "ok" elif .error then .error.message // .error else "unknown" end' 2>/dev/null || echo "non-JSON response")"
4545

4646
# Try to extract token directly from the creation response
4747
TEST_TOKEN=$(echo "$TEST_RAW" | jq -r '.token // empty' 2>/dev/null || true)
@@ -52,7 +52,7 @@ if [ -z "$TEST_TOKEN" ]; then
5252
SIGN_IN_RAW=$(curl -sf -X POST "$SHARKEY_URL/api/signin" \
5353
-H "Content-Type: application/json" \
5454
-d '{"username": "testuser", "password": "testpassword123"}' 2>&1) || true
55-
echo " signin response: ${SIGN_IN_RAW:0:200}"
55+
echo " signin: $([ -n "$(echo "$SIGN_IN_RAW" | jq -r '.i // empty' 2>/dev/null)" ] && echo "ok" || echo "failed")"
5656
TEST_TOKEN=$(echo "$SIGN_IN_RAW" | jq -r '.i // empty' 2>/dev/null || true)
5757
fi
5858

@@ -67,13 +67,13 @@ if [ -z "$TEST_TOKEN" ]; then
6767
RESET_RAW=$(curl -sf -X POST "$SHARKEY_URL/api/admin/reset-password" \
6868
-H "Content-Type: application/json" \
6969
-d "{\"i\": \"$ADMIN_TOKEN\", \"userId\": \"$TESTUSER_ID\"}" 2>&1) || true
70-
echo " reset-password response: ${RESET_RAW:0:200}"
70+
echo " reset-password: $([ -n "$(echo "$RESET_RAW" | jq -r '.password // empty' 2>/dev/null)" ] && echo "ok" || echo "failed")"
7171
NEW_PASS=$(echo "$RESET_RAW" | jq -r '.password // empty' 2>/dev/null || true)
7272
if [ -n "$NEW_PASS" ]; then
7373
SIGN_IN_RAW=$(curl -sf -X POST "$SHARKEY_URL/api/signin" \
7474
-H "Content-Type: application/json" \
7575
-d "{\"username\": \"testuser\", \"password\": \"$NEW_PASS\"}" 2>&1) || true
76-
echo " signin after reset response: ${SIGN_IN_RAW:0:200}"
76+
echo " signin after reset: $([ -n "$(echo "$SIGN_IN_RAW" | jq -r '.i // empty' 2>/dev/null)" ] && echo "ok" || echo "failed")"
7777
TEST_TOKEN=$(echo "$SIGN_IN_RAW" | jq -r '.i // empty' 2>/dev/null || true)
7878
fi
7979
fi
@@ -123,13 +123,13 @@ echo " Fedify user resolved: $FEDIFY_USER_ID"
123123

124124
echo "→ Creating follow relationship (testuser follows Fedify account)..."
125125
echo " Fedify user ID in Sharkey: $FEDIFY_USER_ID"
126-
FOLLOW_RAW=$(curl -s -X POST "$SHARKEY_URL/api/following/create" \
126+
curl -sSf -X POST "$SHARKEY_URL/api/following/create" \
127127
-H "Content-Type: application/json" \
128128
-d "{
129129
\"i\": \"$TEST_TOKEN\",
130130
\"userId\": \"$FEDIFY_USER_ID\"
131-
}" 2>&1) || true
132-
echo " follow response: ${FOLLOW_RAW:0:200}"
131+
}" >/dev/null
132+
echo " follow request succeeded"
133133

134134
echo "→ Writing test env..."
135135
cat > test/smoke/.env.test <<EOF

0 commit comments

Comments
 (0)