1# A private repo has an insights page in the private root, with its own2# exports next to it, which forge lake keeps fresh there without a build;3# the private server shows both to its readers only. Nothing of it is in4# www, the forge's insights or the mirror.5. "$(dirname "$0")/../lib.sh"6user dami7user cat8repo --private dami/secret "hidden thing"9repo dami/open10for r in secret open; do11 clone dami "dami/$r" "$T/w/$r"12 at "$T/w/$r" commit "first"13 ok push_as dami "$T/w/$r" origin main14done15ok forge lake16build17p=$FORGE_ROOT/.forge/private/www/dami/secret/insights18exists "$p/index.html"19has "$p/insights.json" '"scope":"dami/secret"'20has "$p/insights.json" '"pushes":1,'21for f in events builds reviews ci; do eq "$(head -c 4 "$p/$f.parquet")" PAR1; done2223# Another push: the next run puts the new numbers into the private pages.24at "$T/w/secret" commit "second"25ok push_as dami "$T/w/secret" origin main26ok forge lake27has "$p/insights.json" '"pushes":2,'28missing "$FORGE_WWW/dami/secret"29lacks "$FORGE_WWW/insights/insights.json" 'dami/secret'30if grep -rlq 'dami/secret' "$FORGE_WWW"; then fail "www names the private repo"; fi3132private_server33tok=$(ssh_as dami token --repo dami/secret 2>/dev/null)34cat_tok=$(ssh_as cat token 2>/dev/null)35eq "$(http -s -o /dev/null -w '%{http_code}' -H "Authorization: Bearer $tok" "$PRIV/dami/secret/insights/")" 20036http -s -H "Authorization: Bearer $tok" "$PRIV/dami/secret/insights/insights.json" >"$T/got"37ok cmp "$p/insights.json" "$T/got"38eq "$(http -s -o /dev/null -w '%{http_code}' -H "Authorization: Bearer $tok" "$PRIV/dami/secret/insights/ci.parquet")" 20039response "$PRIV/dami/nope/insights/insights.json" >"$T/missing"40for a in "" "$cat_tok"; do41 response "$PRIV/dami/secret/insights/insights.json" ${a:+-H "Authorization: Bearer $a"} >"$T/got"42 cmp -s "$T/missing" "$T/got" || fail "not the missing page's 404: ${a:-anonymous}"43done4445# The mirror (a stand-in rclone, its bucket a directory) gets none of it.46fake_rclone47ok forge mirror48find "$T/bucket" >"$T/bucket.list"49has "$T/bucket.list" '/dami/open/insights/insights\.json$'50lacks "$T/bucket.list" 'secret'