Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them.
Page: /drakestapleton/interplane-forge/blob/main/collab/tests/native-issues-store.sh
# interplane-forge
INTERPLANE Forge
Brought by drakestapleton
Sign in to star 0 stars 0 watching
About Files History Releases Proposed changes Issues For developers
branch `main` Branches Tags History
`interplane-forge / collab / tests / native-issues-store.sh`
224 lines ยท 12416 bytes Raw Blame History
1 #!/usr/bin/env bash
2 # Loopback check for the imported issue views in the signed-store build.
3 . patch/tests/lib.sh
4 set -e
5 trap 'printf "FAIL issue test at line %s, fixture %s\n" "$LINENO" "$T" >&2' ERR
6 trap 'set +e; stop; [ -n "${KEEP:-}" ] || rm -rf "$T"' EXIT
7 store="$T/data/issues/$OWNER/fixrepo"
8 for row in "`0123456789abcdef` open 3" "`01234fedcba98765` closed 4"; do
9 read -r id state number <<< "$row"
10 mkdir -p "$store/$id"
11 printf '%s\n' "$id" >> "$store/index"
12 printf 'Fixture issue %s' "$number" > "$store/$id/title"
13 printf 'Body with **Markdown** and a [relative link](README.md)\n' > "$store/$id/description"
14 printf '%s\n' "$state" > "$store/$id/status"
15 printf 'number %s\nlogin octo\nopened 2026-01-01T00:00:00Z\nclosed -\nreason -\n' "$number" > "$store/$id/gh"
16 printf 'bug\n' > "$store/$id/labels"
17 : > "$store/$id/thread"
18 printf '{"kind":"github-import","owner":"fixo","repo":"fixrepo","number":%s,"url":"https://github.com/fixo/fixrepo/issues/%s"}\n' "$number" "$number" > "$store/$id/source.json"
19 done
20 start
21 test "$(code GET "$R/issues")" = 200
22 grep -q 'Fixture issue 3' "$T/body"
23 ! grep -q 'Fixture issue 4' "$T/body"
24 echo 'PASS default issue list shows only open items'
25 test "$(code GET "$R/issues?state=all" -H 'Accept: application/json')" = 200
26 jq -e '.schema == "forge/issues/1" and (.issues | length == 2)' "$T/body" >/dev/null
27 echo 'PASS JSON issue list returns both states'
28 test "$(code GET "$R/issues/012345" -H 'Accept: application/json')" = 200
29 jq -e '.schema == "forge/issue/1" and .title == "Fixture issue 3" and .author == null and .imported.login == "octo" and .labels == ["bug"]' "$T/body" >/dev/null
30 echo 'PASS JSON detail resolves a unique prefix and preserves source attribution and labels'
31 test "$(code GET "$R/issues/`01234fedcba98765`")" = 200
32 grep -q 'Imported from GitHub' "$T/body"
33 grep -q 'Markdown' "$T/body"
34 echo 'PASS HTML issue detail renders provenance and Markdown'
35 test "$(code GET "$R/issues/01234")" = 404
36 test "$(code GET "$R/issues/ffffffff")" = 404
37 test "$(code POST "$R/issues/`0123456789abcdef`/compose")" = 404
38 test "$(code GET "/$OWNER/unknown/issues")" = 404
39 echo 'PASS ambiguous or missing issues, the retired preview endpoint, and unknown repositories are refused'
40 test "$(code GET "$R/patches" -H 'Accept: application/json')" = 200
41 jq -e '.schema == "forge/patch-list/1"' "$T/body" >/dev/null
42 echo 'PASS patch and issue routes coexist in the same build'
43
44 fixture="$store/`0123456789abcdef`"
45 printf 'comment 2026-01-01T00:00:00Z octo 4\nNote\ncomment 2026-01-01T00:00:00Z octo `9999999999999999999`\n' > "$fixture/thread"
46 sed -i 's/^number .*/number invalid/' "$fixture/gh"
47 test "$(code GET "$R/issues/`0123456789abcdef`" -H 'Accept: application/json')" = 200
48 jq -e '.imported.number == 0 and (.comments | length == 2) and .comments[1].body == "Note"' "$T/body" >/dev/null
49 echo 'PASS invalid import numbers and overlong thread lengths preserve valid records and valid JSON'
50 printf 'opened 2026-01-01T00Z\n' > "$fixture/gh"
51 test "$(code GET "$R/issues/`0123456789abcdef`")" = 200
52 ! grep -Fq '' "$T/body"
53 grep -Fq "<test" "$T/body"
54 echo 'PASS imported time text is escaped in the issue page'
55
56 test "$(code GET "$R/issues/new")" = 200
57 grep -q 'Sign in to open an issue' "$T/body"
58 test "$(code POST "$R/issues/new" --data 'title=Unsigned')" = 303
59 test "$(hdr location)" = /login
60 test "$(code POST "$R/issues/`0123456789abcdef`/comments" --data 'body=Unsigned')" = 303
61 test "$(wc -l < "$store/index")" = 2
62 echo 'PASS sign-in controls protect both write routes'
63
64 newkey writer
65 signin writer 10.4.20.1
66 writer=$DID
67 issue_cookie="Cookie: __Host-forge_session=$SES"
68 test "$(code GET "$R/issues/new" -H "$issue_cookie")" = 200
69 test "$(field csrf)" = "$TOK"
70 request=$(field request)
71 test "${#request}" = 32
72 test "$(code POST "$R/issues/new" -H "$issue_cookie" --data-urlencode "request=$request" --data-urlencode 'title=Missing CSRF')" = 403
73 test "$(code POST "$R/issues/new" -H "$issue_cookie" -H 'Origin: https://elsewhere.example' --data-urlencode "csrf=$TOK" --data-urlencode "request=$request" --data-urlencode 'title=Foreign origin')" = 403
74 test "$(code POST "$R/issues/new" -H "$issue_cookie" --data-urlencode "csrf=$TOK" --data-urlencode "request=$request" --data-urlencode $'title=first\nsecond')" = 400
75 test "$(code POST "$R/issues/new" -H "$issue_cookie" --data-urlencode "csrf=$TOK" --data-urlencode "request=$request" --data-urlencode 'title=Oversized' --data-urlencode "body=$(head -c 16001 /dev/zero | tr '\0' a)")" = 400
76 test "$(wc -l < "$store/index")" = 2
77 echo 'PASS missing CSRF, foreign origin, multiline title and oversized body refuse writes'
78
79 openissue() {
80 code POST "$R/issues/new" -H "$issue_cookie" --data-urlencode "csrf=$TOK" \
81 --data-urlencode "request=$request" --data-urlencode "title=$1" --data-urlencode $'body=This is **native**.\n\n\n\n[Unsafe](javascript:alert(1))'
82 }
83 test "$(openissue 'Native issue ')" = 303
84 issue=$(hdr location)
85 id=${issue##*/}
86 test "${#id}" = 16
87 test "$(openissue 'Native issue ')" = 303
88 test "$(hdr location)" = "$issue"
89 test "$(openissue 'Changed title')" = 409
90 test "$(wc -l < "$store/index")" = 3
91 test "$(code GET "$issue" -H "$issue_cookie")" = 200
92 grep -q 'Native issue <proof>' "$T/body"
93 grep -q 'native' "$T/body"
94 if grep -qE '