@@ -4,12 +4,14 @@ set -eou pipefail
44# 0. Create test table with RLS
55# supabase --workdir tests migrations up
66
7+ echo " Running PostgREST tests..."
8+
79# 1. Create todo as service role
810output=$( curl ' http://127.0.0.1:54321/rest/v1/todos' \
911 -H ' apikey: sb_secret_N7UND0UgjKTVK-Uodkm0Hg_xSvEMPvz' \
1012 -H ' Content-Type: application/json' \
1113 -H ' Prefer: return=representation' \
12- -d ' {"task": "New task", "done": false}'
14+ -d ' {"task": "New task", "done": false}' \
1315)
1416if [[ $( echo " $output " | jq -r ' length' ) != ' 1' ]]; then
1517 echo ' Creating todo as service role should succeed.' >&2
2123output=$( curl ' http://127.0.0.1:54321/rest/v1/todos' \
2224 -H ' apikey: sb_publishable_ACJWlzQHlZjBrEguHvfOxg_3BJgxAaH' \
2325 -H ' Content-Type: application/json' \
24- -d ' {"task": "New task", "done": false}'
26+ -d ' {"task": "New task", "done": false}' \
2527)
2628if [[ $( echo " $output " | jq -r ' .code' ) != ' 42501' ]]; then
2729 echo ' Creating todo as anon role should fail.' >&2
@@ -46,16 +48,16 @@ output=$(curl -X DELETE 'http://127.0.0.1:54321/rest/v1/todos?id=eq.1' \
4648 -H ' Content-Type: application/json' \
4749 -H ' Prefer: return=representation' \
4850)
49- if [[ $( echo " $output " | jq -r ' length' ) != ' 1 ' ]]; then
51+ if [[ $( echo " $output " | jq -r ' length' ) != ' 0 ' ]]; then
5052 echo ' Deleting todo as anon role should fail.' >&2
5153 echo " $output " | jq
5254 exit 1
5355fi
5456
5557# 5. Delete todo as authenticated role (custom jwt)
56- output=$( curl -X DELETE ' http://127.0.0.1:54321/rest/v1/todos?id=eq.1 ' \
58+ output=$( curl -X DELETE ' http://127.0.0.1:54321/rest/v1/todos?id=not. eq.0 ' \
5759 -H ' apikey: sb_publishable_ACJWlzQHlZjBrEguHvfOxg_3BJgxAaH' \
58- -H ' Authorization: Bearer eyJhbGciOiJFUzI1NiIsImtpZCI6ImI4MTI2OWYxLTIxZDgtNGYyZS1iNzE5LWMyMjQwYTg0MGQ5MCIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3NzAyNjE4NTcsImlhdCI6MTc3MDI2MDA1NywiaXNfYW5vbnltb3VzIjp0cnVlLCJyb2xlIjoiYXV0aGVudGljYXRlZCJ9.iYBqhBe9frFxmuatOzX5EtkX4h0-dFcC_d8dGeZImRA_LdVV1_fyP0MUJYm9ttR2ipL2zQ7WrjR7dbU2kBb9YQ ' \
60+ -H " Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU " \
5961 -H ' Content-Type: application/json' \
6062 -H ' Prefer: return=representation' \
6163)
0 commit comments