zig pds
0

Configure Feed

Select the types of activity you want to include in your feed.

zds / tools / smoke.sh
4.2 kB 102 lines
1#!/usr/bin/env sh 2set -eu 3 4root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) 5port="${ZDS_SMOKE_PORT:-2585}" 6db="${TMPDIR:-/tmp}/zds-smoke.sqlite3" 7blob_root="${TMPDIR:-/tmp}/zds-smoke-blobs" 8log="${TMPDIR:-/tmp}/zds-smoke.log" 9base="http://127.0.0.1:${port}" 10 11cleanup() { 12 if [ -n "${server_pid:-}" ]; then 13 kill "$server_pid" 2>/dev/null || true 14 wait "$server_pid" 2>/dev/null || true 15 fi 16} 17trap cleanup EXIT INT TERM 18 19cd "$root" 20rm -f "$db" "$db-wal" "$db-shm" "$log" 21rm -rf "$blob_root" 22mkdir -p "$blob_root" 23 24zig build 25zig build run -- \ 26 --host 127.0.0.1 \ 27 --port "$port" \ 28 --db "$db" \ 29 --blobstore-path "$blob_root" \ 30 --public-url "$base" \ 31 --server-did did:web:localhost \ 32 --handle-domains .test \ 33 >"$log" 2>&1 & 34server_pid=$! 35 36i=0 37while [ "$i" -lt 80 ]; do 38 if curl -fsS "$base/xrpc/_health" >/dev/null 2>&1; then 39 break 40 fi 41 i=$((i + 1)) 42 sleep 0.1 43done 44 45curl -fsS "$base/xrpc/_health" >/dev/null 46sqlite3 "$db" "insert into accounts (did, handle, email, password_hash, activated_at, email_confirmed_at) values ('did:plc:smoketest', 'smoke.test', 'smoke@test.com', 'password', unixepoch(), unixepoch())" 47sqlite3 "$db" "insert into oauth_requests (request_id, client_id, redirect_uri, scope, state, code_challenge, code_challenge_method, login_hint, expires_at) values ('smoke-oauth', 'https://client.example/oauth-client.json', 'https://client.example/callback', 'repo:*?action=create blob:*/*', 'state', 'challenge', 'S256', 'smoke.test', unixepoch() + 600)" 48 49resolved=$(curl -fsS "$base/xrpc/com.atproto.identity.resolveHandle?handle=smoke.test") 50printf '%s' "$resolved" | grep -q '"did":"did:plc:smoketest"' 51 52session=$(curl -fsS -X POST "$base/xrpc/com.atproto.server.createSession" \ 53 -H 'content-type: application/json' \ 54 --data '{"identifier":"smoke.test","password":"password"}') 55token=$(printf '%s' "$session" | sed -n 's/.*"accessJwt":"\([^"]*\)".*/\1/p') 56test -n "$token" 57 58create=$(curl -fsS -X POST "$base/xrpc/com.atproto.repo.createRecord" \ 59 -H "authorization: Bearer $token" \ 60 -H 'content-type: application/json' \ 61 --data '{"repo":"did:plc:smoketest","collection":"app.bsky.feed.post","rkey":"3smoketest","record":{"$type":"app.bsky.feed.post","text":"smoke","createdAt":"2026-05-22T00:00:00.000Z"}}') 62printf '%s' "$create" | grep -q '"uri":"at://did:plc:smoketest/app.bsky.feed.post/3smoketest"' 63 64records=$(curl -fsS "$base/xrpc/com.atproto.repo.listRecords?repo=did:plc:smoketest&collection=app.bsky.feed.post&limit=10") 65printf '%s' "$records" | grep -q '"text":"smoke"' 66 67latest=$(curl -fsS "$base/xrpc/com.atproto.sync.getLatestCommit?did=did:plc:smoketest") 68printf '%s' "$latest" | grep -q '"cid":"' 69printf '%s' "$latest" | grep -q '"rev":"' 70 71repo_car="${TMPDIR:-/tmp}/zds-smoke.car" 72code=$(curl -sS -o "$repo_car" -w '%{http_code}' "$base/xrpc/com.atproto.sync.getRepo?did=did:plc:smoketest") 73test "$code" = "200" 74test "$(wc -c < "$repo_car")" -gt 100 75 76blob_payload="${TMPDIR:-/tmp}/zds-smoke-blob.jpg" 77printf '\377\330\377\340zds-smoke' > "$blob_payload" 78blob=$(curl -fsS -X POST "$base/xrpc/com.atproto.repo.uploadBlob" \ 79 -H "authorization: Bearer $token" \ 80 -H 'content-type: image/jpeg' \ 81 --data-binary "@$blob_payload") 82printf '%s' "$blob" | grep -q '"blob":' 83printf '%s' "$blob" | grep -q '"mimeType":"image/jpeg"' 84 85large_blob_payload="${TMPDIR:-/tmp}/zds-smoke-large-blob.jpg" 86dd if=/dev/zero bs=1024 count=600 of="$large_blob_payload" 2>/dev/null 87large_blob=$(curl -fsS -X POST "$base/xrpc/com.atproto.repo.uploadBlob" \ 88 -H "authorization: Bearer $token" \ 89 -H 'content-type: image/jpeg' \ 90 --data-binary "@$large_blob_payload") 91printf '%s' "$large_blob" | grep -q '"blob":' 92printf '%s' "$large_blob" | grep -q '"size":614400' 93 94oauth_info=$(curl -fsS -H 'accept: application/json' "$base/oauth/authorize?request_uri=urn%3Aietf%3Aparams%3Aoauth%3Arequest_uri%3Asmoke-oauth") 95printf '%s' "$oauth_info" | grep -q '"login_hint":"smoke.test"' 96oauth_page="${TMPDIR:-/tmp}/zds-smoke-oauth.html" 97curl -fsS "$base/oauth/authorize?request_uri=urn%3Aietf%3Aparams%3Aoauth%3Arequest_uri%3Asmoke-oauth" > "$oauth_page" 98grep -q 'value="smoke.test"' "$oauth_page" 99grep -q 'Repository access' "$oauth_page" 100grep -q 'Blob access' "$oauth_page" 101 102echo "zds smoke ok"