quizterm/api-test/init.sh

35 lines
1.1 KiB
Bash
Raw Permalink Normal View History

2026-04-13 23:05:35 +02:00
#!/bin/sh
2026-04-15 21:02:13 +02:00
export API_KEY="X-api-key: test"
2026-04-13 23:05:35 +02:00
export URL=http://localhost:1234
echo $URL
echo "Rooms!"
for i in A B C D E F G
do
echo "{ \"id\": \"TM$i\", \"name\": \"Team $i\", \"pin_enc\": \"`echo "PIN$i" | sha256 -x`\" }" \
| curl --header "$API_KEY" --json @- $URL/api/room
done
echo
echo "questions!"
echo "[" > ship.json
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13
do
echo "{ \"index\": $i, \"text\": \"What question number is this? Hint (one more than previous question!)?\" }," >> ship.json
done
echo "{ \"index\": 14, \"text\": \"What question number is this? Hint (one more than previous question!)?\" }" >> ship.json
echo "]" >> ship.json
curl --header "$API_KEY" --json @- $URL/api/questions < ship.json
rm ship.json
echo
echo "answers!"
echo "[" > ship.json
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13
do
echo "{ \"index\": $i, \"text\": \"The answer to the question is, of course, $i! Keep counting!\" }," >> ship.json
done
echo "{ \"index\": 14, \"text\": \"The answer to the question is, of course, 14! Keep counting!\"} " >> ship.json
echo "]" >> ship.json
curl --header "$API_KEY" --json @- $URL/api/answers < ship.json
rm ship.json