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/tools/doi/fixture-curl.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 / tools / doi / fixture-curl.sh` 47 lines ยท 2179 bytes Raw Blame History 1 #!/bin/sh 2 # Offline curl stand-in: accepts the same argv as doi.sh gives curl, reads auth only 3 # from stdin, copies fixed fixture answers, and records requests without the bearer. 4 set +x 5 set -eu 6 F=$1; shift 7 printf '%s\n' '--- argv ---' "$@" >> "$F/argv.log" 8 method= url= output= payload= upload= config= 9 while [ "$#" -gt 0 ]; do 10 case "$1" in 11 --request) method=$2; shift 2;; 12 --url) url=$2; shift 2;; 13 --output) output=$2; shift 2;; 14 --data-binary) payload=$2; shift 2;; 15 --upload-file) upload=$2; shift 2;; 16 --config) config=$2; shift 2;; 17 --proto|--max-redirs|--proxy|--write-out|--header) shift 2;; 18 -q|--globoff|--silent|--show-error) shift;; 19 *) echo 'fixture-curl: unexpected option' >&2; exit 2;; 20 esac 21 done 22 [ "$config" = - ] || exit 2 23 IFS= read -r auth || exit 2 24 # Comparison stays in the shell, not argv, output or a file. 25 [ "$auth" = "header = \"Authorization: Bearer ${ZENODO_TOKEN:?}\"" ] || exit 2 26 unset auth 27 printf '%s %s auth=ok\n' "$method" "$url" >> "$F/requests.log" 28 case "$method $url" in 29 'POST https://sandbox.zenodo.org/api/deposit/depositions'|'POST https://zenodo.org/api/deposit/depositions') 30 kind=create; code=201 31 case "$payload" in @*) cp -- "${payload#@}" "$F/request-create.json";; *) exit 2;; esac;; 32 'PUT https://sandbox.zenodo.org/api/files/'*|'PUT https://zenodo.org/api/files/'*) 33 kind=upload; code=200 34 [ -f "$upload" ] || exit 2 35 cp -- "$upload" "$F/uploaded-${upload##*/}" 36 # A per-file acknowledgement allows PDF and source uploads in one fixture. 37 if [ -f "$F/upload-${upload##*/}.json" ]; then kind=upload-${upload##*/}; fi;; 38 'POST https://sandbox.zenodo.org/api/deposit/depositions/'*'/actions/publish'|'POST https://zenodo.org/api/deposit/depositions/'*'/actions/publish') 39 kind=publish; code=202 40 [ "$payload" = '{}' ] || exit 2;; 41 *) echo 'fixture-curl: unexpected request URL or method' >&2; exit 2;; 42 esac 43 # Test-only timing actions are confined to this offline transport, never the product engine. 44 if [ -f "$F/$kind.hook" ]; then sh "$F/$kind.hook"; fi 45 cp -- "$F/$kind.json" "$output" 46 if [ -f "$F/$kind.code" ]; then code=$(cat "$F/$kind.code"); fi 47 printf '%s' "$code"