interplane.Get Omega
Read in your language

interplane-forge

INTERPLANE Forge

Brought by drakestapleton

branch main Branches Tags History

interplane-forge / dl / tests / check.sh

318 lines · 21122 bytes Raw Blame History
1#!/usr/bin/env bash
2# dl/tests/check.sh: ForgeDownloads unit checks (HOST level, no socket).
3# Builds the test driver (dl/tests/fstub.om + dl/*.om + dl/tests/tmain.om) with the pinned omc, then
4# drives dlroute (one process per request; extra PATHs share one process, as in the server) against the real cuda-crack storage (read only) and a
5# fixture bare repo in /tmp (tags, delegate-namespace tags, release-assets/). Every positive check
6# has a negative control. Driver transcripts go to dl/evidence/. Runs on core 14 only.
7# STATUS 0 from the driver means "not mine": forged then answers 404.
8set -u
9export LC_ALL=C # "$W"/dl/*.om must sort by byte: dl.om before dljson.om (see run.sh)
10W=$(cd "$(dirname "$0")/../.." && pwd)
11O=${OMEGA_MV:-$HOME/work/flux/omega-mv}
12T=/tmp/forge-dltest
13EV=$W/dl/evidence
14# the storage of the cuda-crack checks: FORGE_TEST_RSTORE (default the read-only frozen copy kept after
15# the Radicle removal of 2026-11-14; ~/.radicle no longer exists)
16STORE=${FORGE_TEST_RSTORE:-$HOME/radicle-storage-frozen/storage}/
17CC=z631r2JJiVT8it4tST7RK24hpowi
18NID=z6MkfZDue1TbaNFi3ZzcD9uiTeduPLC52ucdFVuLKZwexxhK
19FXR=zDLfixture1
20# CORES: the caller's pool (a bay or a gate run passes its own cores; ticket t_7c02d686). Default 14 as
21# before.
22RUN="taskset -c ${CORES:-14} nice -n 10"
23pass=0; fail=0
24ok() { pass=$((pass+1)); echo "PASS $*"; }
25bad() { fail=$((fail+1)); echo "FAIL $*"; }
26chk() { if [ "$1" = "$2" ]; then ok "$3 ($1)"; else bad "$3: got '$1' want '$2'"; fi; }
27has() { if grep -qF -- "$2" "$1"; then ok "$3"; else bad "$3: missing '$2'"; fi; }
28hasnt(){ if grep -qF -- "$2" "$1"; then bad "$3: unexpected '$2'"; else ok "$3"; fi; }
29fld() { sed -n "s/^$2 //p" "$1" | head -n1; }
30
31rm -rf "$T"; mkdir -p "$T" "$EV"
32rm -f "$EV"/driver-*.txt
33echo "omc sha256: $(sha256sum "$O/seed/out/omc" | cut -c1-64) omega-mv $(git -C "$O" rev-parse HEAD)"
34{ printf 'om2\n'; cat "$O/seed/net/http.om" "$O/seed/net/notls.om" "$O/om/tls/sha2.om" \
35 "$W/dl/tests/fstub.om" "$W/nodes/head.om" "$W"/dl/*.om "$W/dl/tests/tmain.om"; } > "$T/all.om"
36$RUN "$O/seed/out/omc" < "$T/all.om" > "$T/dltest"; rc=$?
37chk "$rc" 0 "omc build of the driver"
38chmod +x "$T/dltest"
39echo "dl.om sha256: $(sha256sum "$W/dl/dl.om" | cut -c1-64) driver sha256: $(sha256sum "$T/dltest" | cut -c1-64)"
40
41# req NAME STORE METHOD PATH BASE INM QUERY [PATH2 ...]: transcript in $EV/driver-NAME.txt
42req() {
43 local n=$1; shift
44 { echo "\$ dltest $2 $3 $4 inm=$5 q=$6 ${*:7}"; $RUN "$T/dltest" "$1" "$T/allow" "${@:2}"; echo "[exit $?]"; } > "$EV/driver-$n.txt"
45 R=$EV/driver-$n.txt
46}
47# sreq: req under strace (execve only); $X = the exec trace
48sreq() {
49 local n=$1; shift
50 X=$T/strace-$n.txt
51 { echo "\$ strace -f -e trace=execve dltest $2 $3 $4"; $RUN strace -f -qq -e trace=execve -o "$X" "$T/dltest" "$1" "$T/allow" "${@:2}"; echo "[exit $?]"; } > "$EV/driver-$n.txt"
52 R=$EV/driver-$n.txt
53}
54all() { sed -n "s/^$2 //p" "$1" | tr '\n' ' '; }
55nexec() { grep 'execve(' "$1" | grep -cF -- "\"$2\","; }
56
57# ---------- fixture repo (never under ~/.radicle) ----------
58mkdir -p "$T/store" "$T/fx/release-assets"
59git init -q --bare "$T/store/$FXR"
60cd "$T/fx" && git init -q -b main . && git config user.name fixture && git config user.email fixture@invalid
61printf 'fixture\n' > README
62printf 'tool v1\n' > release-assets/tool-linux.txt
63head -c 300000 /dev/urandom > release-assets/blob.bin
64cp release-assets/blob.bin "$T/blob.orig"; cp release-assets/tool-linux.txt "$T/tool.orig"
65mk() { GIT_AUTHOR_DATE="$1" GIT_COMMITTER_DATE="$1" git commit -q -am "$2" 2>/dev/null || GIT_AUTHOR_DATE="$1" GIT_COMMITTER_DATE="$1" git commit -q -m "$2"; }
66git add -A; mk 2026-01-01T00:00:00Z one
67GIT_COMMITTER_DATE=2026-01-02T00:00:00Z git tag -a v1.0.0 -m "First release" -m "Notes line <b>bold</b> & more"
68git tag v0.9.0
69printf 'two\n' >> README; printf 'tool v2\n' >> release-assets/tool-linux.txt; mk 2026-02-01T00:00:00Z two
70GIT_COMMITTER_DATE=2026-02-02T00:00:00Z git tag -a v1.1.0-rc1 -m "Release candidate"
71printf 'twob\n' >> README; mk 2026-02-15T00:00:00Z twob
72C2B=$(git rev-parse HEAD)
73printf 'three\n' >> README; mk 2026-03-01T00:00:00Z three
74git tag 'weird%tag'
75git push -q "$T/store/$FXR" main --tags
76C1=$(git rev-parse v1.0.0^{commit}); C3=$(git rev-parse HEAD)
77G="git --git-dir=$T/store/$FXR"
78$G update-ref "refs/namespaces/$NID/refs/tags/v2.0.0-beta1" "$C3"
79$G update-ref "refs/namespaces/$NID/refs/tags/v1.0.0" "$($G rev-parse refs/tags/v1.0.0)"
80$G update-ref -d refs/tags/weird%tag 2>/dev/null; $G update-ref "refs/tags/weird%tag" "$C3"
81DANG=$(echo dangling | $G commit-tree "$C1^{tree}")
82cd "$W"
83printf 'cuda-crack %s\ndlfix %s\n' "$CC" "$FXR" > "$T/allow"
84CCG="git --git-dir=$STORE$CC"
85MAIN=$($CCG rev-parse refs/heads/main)
86OLDCC=$($CCG rev-list --skip=3 -n1 "$MAIN")
87echo "cuda-crack main = $MAIN old=$OLDCC; fixture C1=$C1 C2B=$C2B C3=$C3 dangling=$DANG"
88
89# ---------- archives: cuda-crack main ----------
90req cc-main-zip "$STORE" GET /drakestapleton/cuda-crack/archive/refs/heads/main.zip /forge/ - -
91chk "$(fld $R STATUS)" 200 "zip status"
92chk "$(fld $R CT)" application/zip "zip content type"
93chk "$(fld $R CD)" "attachment; filename=cuda-crack-main.zip" "zip disposition"
94chk "$(fld $R ETAG)" "\"$MAIN\"" "zip etag = commit"
95ZF=$(fld $R FILE)
96$CCG archive --format=zip --prefix=cuda-crack-main/ "$MAIN" > "$T/ref.zip"
97cmp -s "$ZF" "$T/ref.zip"; chk $? 0 "zip byte-identical to git archive --prefix=cuda-crack-main/"
98unzip -tq "$ZF" > /dev/null; chk $? 0 "unzip -t"
99req cc-main-tgz "$STORE" GET /drakestapleton/cuda-crack/archive/refs/heads/main.tar.gz / - -
100chk "$(fld $R STATUS)" 200 "tar.gz status"
101chk "$(fld $R CT)" application/gzip "tar.gz content type"
102chk "$(fld $R CD)" "attachment; filename=cuda-crack-main.tar.gz" "tar.gz disposition"
103TF=$(fld $R FILE)
104$CCG archive --format=tar.gz --prefix=cuda-crack-main/ "$MAIN" > "$T/ref.tgz"
105cmp -s "$TF" "$T/ref.tgz"; chk $? 0 "tar.gz byte-identical to git archive"
106tar -tzf "$TF" > /dev/null; chk $? 0 "tar -tzf"
107# negative control for cmp: a different prefix gives different bytes
108$CCG archive --format=zip --prefix=other/ "$MAIN" > "$T/other.zip"
109cmp -s "$ZF" "$T/other.zip"; chk $? 1 "NEG: other prefix differs"
110# conditional + cache hit
111I1=$(stat -c %i "$ZF")
112req cc-304 "$STORE" GET /drakestapleton/cuda-crack/archive/refs/heads/main.zip /forge/ "\"$MAIN\"" -
113chk "$(fld $R STATUS)" 304 "If-None-Match matching etag -> 304"
114chk "$(fld $R FILE)" "" "304 has no file"
115req cc-304neg "$STORE" GET /drakestapleton/cuda-crack/archive/refs/heads/main.zip /forge/ '"0000000000000000000000000000000000000000"' -
116chk "$(fld $R STATUS)" 200 "NEG: other etag -> 200"
117chk "$(stat -c %i "$ZF")" "$I1" "cache hit reuses the file (same inode)"
118req cc-head "$STORE" HEAD /drakestapleton/cuda-crack/archive/refs/heads/main.zip /forge/ - -
119chk "$(fld $R STATUS)" 200 "HEAD status"
120req cc-sha "$STORE" GET "/drakestapleton/cuda-crack/archive/$MAIN.zip" / - -
121chk "$(fld $R STATUS)" 302 "archive/<sha40 of a head>.zip redirects"
122chk "$(fld $R LOC)" /drakestapleton/cuda-crack/archive/refs/heads/main.zip "to the branch archive"
123chk "$(fld $R FILE)" "" "a sha URL builds nothing"
124req cc-sha-f "$STORE" GET "/drakestapleton/cuda-crack/archive/${MAIN:0:7}.tar.gz" /forge/ - -
125chk "$(fld $R LOC)" /forge/drakestapleton/cuda-crack/archive/refs/heads/main.tar.gz "sha7 redirect under /forge/"
126$CCG merge-base --is-ancestor "$OLDCC" "$MAIN"; chk $? 0 "control: old commit $OLDCC is reachable from main"
127n0=$(ls "$T/data/archives/$CC" | wc -l)
128req cc-old "$STORE" GET "/drakestapleton/cuda-crack/archive/$OLDCC.zip" / - -
129chk "$(fld $R STATUS)" 404 "NEG: reachable old commit that no head or tag points at -> 404"
130chk "$(ls "$T/data/archives/$CC" | wc -l)" "$n0" "NEG: nothing built for it"
131req cc-bare "$STORE" GET /drakestapleton/cuda-crack/archive/main.tar.gz / - -
132chk "$(fld $R STATUS)" 200 "archive/<branch>.tar.gz"
133cmp -s "$(fld $R FILE)" "$T/ref.tgz"; chk $? 0 "archive/main.tar.gz same bytes as refs/heads/main"
134# negatives
135req neg-badref "$STORE" GET /drakestapleton/cuda-crack/archive/refs/heads/nope.zip / - -
136chk "$(fld $R STATUS)" 404 "NEG: unknown branch -> 404"
137req neg-dotdot "$STORE" GET /drakestapleton/cuda-crack/archive/refs/heads/a..b.zip / - -
138chk "$(fld $R STATUS)" 400 "NEG: '..' in ref -> 400"
139req neg-trav "$STORE" GET /drakestapleton/cuda-crack/archive/refs/heads/../../../etc/passwd.zip / - -
140chk "$(fld $R STATUS)" 400 "NEG: traversal ref -> 400"
141req neg-pct "$STORE" GET /drakestapleton/cuda-crack/archive/%2e%2e%2fx.zip / - -
142chk "$(fld $R STATUS)" 400 "NEG: percent-encoded traversal -> 400"
143req neg-dash "$STORE" GET /drakestapleton/cuda-crack/archive/--output=x.zip / - -
144chk "$(fld $R STATUS)" 400 "NEG: leading '-' (option injection) -> 400"
145req neg-upstream "$STORE" GET "/drakestapleton/cuda-crack/archive/main@{u}.zip" / - -
146chk "$(fld $R STATUS)" 400 "NEG: '@{' revision syntax -> 400"
147req neg-ext "$STORE" GET /drakestapleton/cuda-crack/archive/refs/heads/main.rar / - -
148chk "$(fld $R STATUS)" 404 "NEG: unknown archive format -> 404"
149req neg-post "$STORE" POST /drakestapleton/cuda-crack/archive/refs/heads/main.zip / - -
150chk "$(fld $R STATUS)" 405 "NEG: POST -> 405"
151req neg-notlisted "$STORE" GET /drakestapleton/z3gqcJUoA1n9HaHKufZs5FCSGazv5/archive/refs/heads/main.zip / - -
152chk "$(fld $R STATUS)" 0 "NEG: non-allow-listed RID -> not served (server 404)"
153req neg-pearl "$STORE" GET /drakestapleton/omega-pearl/releases / - -
154chk "$(fld $R STATUS)" 0 "NEG: non-allow-listed repo name -> not served (server 404)"
155req neg-owner "$STORE" GET /someoneelse/cuda-crack/archive/refs/heads/main.zip / - -
156chk "$(fld $R STATUS)" 0 "NEG: wrong owner -> not served"
157req neg-other "$STORE" GET /drakestapleton/cuda-crack/tree/main / - -
158chk "$(fld $R STATUS)" 0 "NEG: non-download route is not mine"
159ls "$T/data/archives/$CC" | grep -q '^\.tmp-'; chk $? 1 "no temp files left behind"
160
161# ---------- releases on a repo with no tags ----------
162req cc-rel "$STORE" GET /drakestapleton/cuda-crack/releases /forge/ - -
163chk "$(fld $R STATUS)" 200 "releases page without tags"
164has "$R" 'class="empty"' "empty releases message"
165req cc-latest "$STORE" GET /drakestapleton/cuda-crack/releases/latest /forge/ - -
166chk "$(fld $R STATUS)" 404 "NEG: latest without releases -> 404"
167
168# ---------- releases on the fixture ----------
169F="$T/store/"
170t0=$(date +%s%N)
171sreq fx-rel "$F" GET /drakestapleton/dlfix/releases /forge/ - -
172ms=$(( ($(date +%s%N) - t0) / 1000000 ))
173chk "$(fld $R STATUS)" 200 "fixture releases page"
174chk "$(nexec "$X" archive)" 0 "cold releases page: no git archive child (strace execve)"
175[ "$(grep -c 'for-each-ref' "$X")" -ge 1 ]; chk $? 0 "control: strace saw the page's git for-each-ref"
176[ "$ms" -lt 2000 ]; chk $? 0 "cold releases page under strace in ${ms} ms (< 2000)"
177chk "$(find "$T/data/archives/$FXR" -type f 2>/dev/null | wc -l)" 0 "cold releases page left no file in the cache"
178chk "$(grep -c 'checksum computed on first download' "$R")" 8 "8 archive rows say checksum computed on first download"
179chk "$(fld $R TITLE)" "Releases: dlfix" "releases title"
180has "$R" '<!-- repo header tab 4 -->' "repo header with the Releases tab"
181has "$R" 'href="/forge/drakestapleton/dlfix/releases/tag/v1.0.0"' "release link under /forge/"
182order=$(grep -o 'releases/tag/[^"]*">' "$R" | sed 's/releases\/tag\///; s/">//' | tr '\n' ' ')
183chk "$order" "v2.0.0-beta1 v1.1.0-rc1 v1.0.0 v0.9.0 " "newest first, root+namespace tags deduplicated"
184hasnt "$R" 'weird' "NEG: tag with refused characters is not listed"
185has "$R" 'Notes line &lt;b&gt;bold&lt;/b&gt; &amp; more' "annotated tag notes, escaped"
186hasnt "$R" '<b>bold' "NEG: raw HTML from tag notes"
187chk "$(grep -c 'label">latest' "$R")" 1 "exactly one latest label"
188grep -A1 'releases/tag/v1.0.0"' "$R" | grep -q 'label">latest'; chk $? 0 "latest = newest non-prerelease (v1.0.0)"
189chk "$(grep -c 'pre-release' "$R")" 2 "two pre-releases marked"
190sreq fx-cold-dl "$F" GET /drakestapleton/dlfix/archive/refs/tags/v1.0.0.zip / - -
191chk "$(nexec "$X" archive)" 1 "NEG: a cold download does exec git archive (the trace detects it)"
192req fx-dl2 "$F" GET /drakestapleton/dlfix/archive/refs/tags/v1.0.0.tar.gz / - - \
193 /drakestapleton/dlfix/archive/refs/tags/v1.1.0-rc1.zip
194req fx-dl3 "$F" GET /drakestapleton/dlfix/archive/refs/tags/v2.0.0-beta1.zip / - -
195chk "$(all $R STATUS)" "200 " "beta1 zip built"
196req fx-rel "$F" GET /drakestapleton/dlfix/releases /forge/ - -
197chk "$(grep -c 'checksum computed on first download' "$R")" 4 "after 4 downloads, 4 rows still unbuilt"
198for spec in "zip 1.0.0 v1.0.0" "tar.gz 1.0.0 v1.0.0" "zip 1.1.0-rc1 v1.1.0-rc1" "zip 2.0.0-beta1 $C3"; do
199 set -- $spec
200 want=$($G archive --format=$1 --prefix=dlfix-$2/ "$3^{commit}" | sha256sum | cut -c1-64)
201 has "$R" "<code>$want</code>" "Omega SHA-256 of dlfix-$2.$1 equals sha256sum"
202done
203for sc in "$T"/data/archives/$FXR/*.sha256; do
204 f=${sc%.sha256}; chk "$(cat "$sc")" "$(sha256sum "$f" | cut -c1-64)" "sidecar digest of $(basename "$f")"
205done
206hasnt "$R" '<code>0000000000000000000000000000000000000000000000000000000000000000</code>' "NEG: no zero digest"
207req fx-rel-root "$F" GET /drakestapleton/dlfix/releases / - -
208has "$R" 'href="/drakestapleton/dlfix/archive/refs/tags/v1.0.0.zip"' "archive link under base /"
209hasnt "$R" '/forge/' "NEG: no /forge/ link under base /"
210req fx-page2 "$F" GET /drakestapleton/dlfix/releases / - page=2
211chk "$(fld $R STATUS)" 404 "NEG: page past the end -> 404"
212req fx-latest "$F" GET /drakestapleton/dlfix/releases/latest /forge/ - -
213chk "$(fld $R STATUS)" 302 "latest redirects"
214chk "$(fld $R LOC)" /forge/drakestapleton/dlfix/releases/tag/v1.0.0 "latest Location base-prefixed (/forge/)"
215req fx-latest-root "$F" GET /drakestapleton/dlfix/releases/latest / - -
216chk "$(fld $R LOC)" /drakestapleton/dlfix/releases/tag/v1.0.0 "latest Location base-prefixed (/)"
217sreq fx-tag "$F" GET /drakestapleton/dlfix/releases/tag/v1.0.0 /forge/ - -
218chk "$(fld $R STATUS)" 200 "release tag page"
219has "$R" 'href="/forge/drakestapleton/dlfix/releases/download/v1.0.0/blob.bin"' "asset link"
220chk "$(nexec "$X" cat-file)" 0 "cold release page: no git cat-file (asset) child"
221chk "$(find "$T/data/archives/$FXR" -name '*.blob' | wc -l)" 0 "cold release page built no asset"
222chk "$(grep -c 'checksum computed on first download' "$R")" 2 "both assets say checksum computed on first download"
223req fx-tag404 "$F" GET /drakestapleton/dlfix/releases/tag/v9.9.9 / - -
224chk "$(fld $R STATUS)" 404 "NEG: unknown release tag -> 404"
225req fx-tagbad "$F" GET /drakestapleton/dlfix/releases/tag/weird%tag / - -
226chk "$(fld $R STATUS)" 400 "NEG: refused tag name -> 400"
227BLOB=$($G rev-parse "v1.0.0:release-assets/blob.bin")
228req fx-asset "$F" GET /drakestapleton/dlfix/releases/download/v1.0.0/blob.bin /forge/ - -
229chk "$(fld $R STATUS)" 200 "asset download"
230chk "$(fld $R CT)" application/octet-stream "asset content type"
231chk "$(fld $R CD)" "attachment; filename=blob.bin" "asset disposition"
232chk "$(fld $R ETAG)" "\"$BLOB\"" "asset etag = blob id"
233cmp -s "$(fld $R FILE)" "$T/blob.orig"; chk $? 0 "asset byte-identical to the committed file"
234req fx-tag2 "$F" GET /drakestapleton/dlfix/releases/tag/v1.0.0 /forge/ - -
235has "$R" "<code>$(sha256sum "$T/blob.orig" | cut -c1-64)</code>" "asset blob.bin SHA-256 (Omega) equals sha256sum after download"
236has "$R" '<td>300000</td>' "asset size"
237hasnt "$R" "<code>$(sha256sum "$T/tool.orig" | cut -c1-64)</code>" "NEG: tool-linux.txt not downloaded, no digest yet"
238req fx-tool "$F" GET /drakestapleton/dlfix/releases/download/v1.0.0/tool-linux.txt / - - \
239 /drakestapleton/dlfix/releases/tag/v1.0.0
240has "$R" "<code>$(sha256sum "$T/tool.orig" | cut -c1-64)</code>" "asset tool-linux.txt SHA-256 equals sha256sum after download"
241req fx-asset304 "$F" GET /drakestapleton/dlfix/releases/download/v1.0.0/blob.bin / "W/\"$BLOB\"" -
242chk "$(fld $R STATUS)" 304 "asset If-None-Match -> 304"
243req fx-asset404 "$F" GET /drakestapleton/dlfix/releases/download/v1.0.0/nope.bin / - -
244chk "$(fld $R STATUS)" 404 "NEG: missing asset -> 404"
245req fx-asset-v0 "$F" GET /drakestapleton/dlfix/releases/download/v1.1.0-rc1/README / - -
246chk "$(fld $R STATUS)" 404 "NEG: file outside release-assets/ -> 404"
247req fx-asset-hidden "$F" GET /drakestapleton/dlfix/releases/download/v1.0.0/.git / - -
248chk "$(fld $R STATUS)" 400 "NEG: dot asset name -> 400"
249req fx-asset-pct "$F" GET /drakestapleton/dlfix/releases/download/v1.0.0/..%2fREADME / - -
250chk "$(fld $R STATUS)" 400 "NEG: encoded traversal in asset -> 400"
251req fx-tag-tgz "$F" GET /drakestapleton/dlfix/archive/refs/tags/v1.0.0.tar.gz / - -
252$G archive --format=tar.gz --prefix=dlfix-1.0.0/ "v1.0.0^{commit}" > "$T/fx.tgz"
253cmp -s "$(fld $R FILE)" "$T/fx.tgz"; chk $? 0 "tag tar.gz byte-identical (prefix dlfix-1.0.0/)"
254req fx-ns "$F" GET /drakestapleton/dlfix/archive/refs/tags/v2.0.0-beta1.zip / - -
255chk "$(fld $R STATUS)" 200 "delegate-namespace tag archive"
256req fx-short "$F" GET "/drakestapleton/dlfix/archive/${C1:0:7}.zip" / - -
257chk "$(fld $R STATUS)" 302 "archive/<sha7 of a release tag>.zip redirects"
258chk "$(fld $R LOC)" /drakestapleton/dlfix/archive/refs/tags/v1.0.0.zip "to the (peeled, annotated) tag archive"
259req fx-head "$F" GET "/drakestapleton/dlfix/archive/$C3.tar.gz" / - -
260chk "$(fld $R LOC)" /drakestapleton/dlfix/archive/refs/heads/main.tar.gz "a head beats a tag at the same commit"
261git --git-dir="$T/store/$FXR" merge-base --is-ancestor "$C2B" main; chk $? 0 "control: C2B is reachable from main"
262req fx-c2b "$F" GET "/drakestapleton/dlfix/archive/$C2B.zip" / - -
263chk "$(fld $R STATUS)" 404 "NEG: reachable untagged commit -> 404"
264req fx-c2b7 "$F" GET "/drakestapleton/dlfix/archive/${C2B:0:7}.tar.gz" / - -
265chk "$(fld $R STATUS)" 404 "NEG: same as sha7 -> 404"
266req fx-dangling "$F" GET "/drakestapleton/dlfix/archive/$DANG.zip" / - -
267chk "$(fld $R STATUS)" 404 "NEG: unreachable commit -> 404"
268req fx-nohex "$F" GET "/drakestapleton/dlfix/archive/deadbee.zip" / - -
269chk "$(fld $R STATUS)" 404 "NEG: unknown hex -> 404"
270
271# ---------- cold-build cap: 2 per 60 s, site-wide (one process = one server) ----------
272n1=$(find "$T/data/archives/$FXR" -type f ! -name '*.sha256' | wc -l)
273req cap3 "$F" GET /drakestapleton/dlfix/archive/refs/tags/v1.1.0-rc1.tar.gz / - - \
274 /drakestapleton/dlfix/archive/refs/tags/v2.0.0-beta1.tar.gz \
275 /drakestapleton/dlfix/archive/refs/tags/v0.9.0.zip \
276 /drakestapleton/dlfix/archive/refs/tags/v1.0.0.zip \
277 /drakestapleton/dlfix/releases/download/v1.1.0-rc1/tool-linux.txt
278chk "$(all $R STATUS)" "200 200 503 200 503 " "cold builds 1,2 ok; 3rd cold -> 503; a cache hit still 200; a cold asset -> 503"
279ra=$(all $R RETRY | cut -d' ' -f3)
280[ "$ra" -ge 1 ] && [ "$ra" -le 60 ]; chk $? 0 "503 carries Retry-After $ra (1..60 s)"
281chk "$(all $R RETRY | cut -d' ' -f1,2,4)" "0 0 0" "NEG: no Retry-After on 200s"
282chk "$(find "$T/data/archives/$FXR" -type f ! -name '*.sha256' | wc -l)" "$((n1+2))" "only the 2 allowed builds added files"
283req cap-fresh "$F" GET /drakestapleton/dlfix/archive/refs/tags/v0.9.0.zip / - -
284chk "$(all $R STATUS)" "200 " "NEG: a fresh server (empty window) builds it"
285TOOL2=$($G rev-parse "v1.1.0-rc1:release-assets/tool-linux.txt")
286req fx-blobf "$F" BLOBF "/drakestapleton/dlfix/$TOOL2" / - -
287chk "$(fld $R STATUS)" 0 "dlblobf (browse /raw/ entry) returns 0"
288cmp -s "$(fld $R FILE)" <($G cat-file blob "$TOOL2"); chk $? 0 "dlblobf file = the blob's bytes"
289chk "$(fld $R FILE)" "$T/data/archives/$FXR/$TOOL2.blob" "dlblobf uses the shared blob cache"
290req fx-blobf-bad "$F" BLOBF "/drakestapleton/dlfix/..%2f..%2f..%2fetc%2fpasswd000000000000000" / - -
291chk "$(fld $R FILE)" "" "NEG: dlblobf refuses a non-hex id (no file)"
292req fx-blobf-short "$F" BLOBF "/drakestapleton/dlfix/abc" / - -
293chk "$(fld $R FILE)" "" "NEG: dlblobf refuses a short id"
294req cc-clone "$STORE" CLONE /drakestapleton/cuda-crack /forge/ - -
295has "$R" "No public Git URL yet: Interplane does not serve Git clones yet." "clone panel: no public Git URL yet"
296hasnt "$R" "rad" "NEG: clone panel has no rad command or rad: id"
297hasnt "$R" "Radicle" "NEG: clone panel has no Radicle wording"
298hasnt "$R" "git clone" "NEG: clone panel offers no git clone URL"
299has "$R" 'href="/forge/drakestapleton/cuda-crack/archive/refs/heads/main.zip"' "clone panel: zip link"
300
301# ---------- LRU eviction (cap 5 GiB = 5368709120 bytes) ----------
302A=$T/data/archives
303OLD=$TF # cuda-crack main tar.gz, created before the sparse file
304sleep 1.1; truncate -s 5G "$A/$FXR/zzsparse.bin"; sleep 1.1
305req ev-hit "$STORE" GET /drakestapleton/cuda-crack/archive/refs/heads/main.zip / - - # touches ZF
306sleep 1.1
307req ev-gen "$F" GET /drakestapleton/dlfix/archive/refs/heads/main.tar.gz / - - # new file -> evict
308chk "$(fld $R STATUS)" 200 "generation that crosses the cap"
309NEWF=$(fld $R FILE)
310[ -e "$A/$FXR/zzsparse.bin" ]; chk $? 1 "oversize old file evicted"
311[ -e "$OLD" ]; chk $? 1 "untouched file older than it evicted (LRU)"
312[ -e "$ZF" ]; chk $? 0 "NEG: recently hit file kept"
313[ -e "$NEWF" ]; chk $? 0 "NEG: new file kept"
314tot=$(find "$A" -type f -printf '%s\n' | awk '{s+=$1} END {print s+0}')
315[ "$tot" -le 5368709120 ]; chk $? 0 "cache total $tot <= 5368709120"
316
317echo "RESULT pass=$pass fail=$fail"
318[ "$fail" -eq 0 ]