Skip to content

Commit d6ae34e

Browse files
committed
chore: refactor api url
1 parent 3d3e51c commit d6ae34e

File tree

5 files changed

+17
-17
lines changed

5 files changed

+17
-17
lines changed

tests/auth.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -eou pipefail
33

44
# 1. Create user with publishable key
5-
output=$(curl -sS 'http://127.0.0.1:54321/auth/v1/signup' \
5+
output=$(curl -sS "$API_URL/auth/v1/signup" \
66
-H "apikey: $PUBLISHABLE_KEY" \
77
-H 'Content-Type: application/json' \
88
-d '{"email":"user@example.com","password":"aSecurePassword123"}' \
@@ -15,7 +15,7 @@ fi
1515

1616
# 2. Delete user with secret key
1717
user_id=$(echo "$output" | jq -r '.user.id')
18-
output=$(curl -sS -X DELETE "http://127.0.0.1:54321/auth/v1/admin/users/$user_id" \
18+
output=$(curl -sS -X DELETE "$API_URL/auth/v1/admin/users/$user_id" \
1919
-H "apikey: $SECRET_KEY" \
2020
-H 'Content-Type: application/json' \
2121
)
@@ -26,7 +26,7 @@ if [[ "$output" != '{}' ]]; then
2626
fi
2727

2828
# 3. Create user with legacy anon key
29-
output=$(curl -sS 'http://127.0.0.1:54321/auth/v1/signup' \
29+
output=$(curl -sS "$API_URL/auth/v1/signup" \
3030
-H "Authorization: Bearer $ANON_KEY" \
3131
-H 'Content-Type: application/json' \
3232
-d '{"email":"user@example.com","password":"aSecurePassword123"}' \
@@ -39,7 +39,7 @@ fi
3939

4040
# 4. Delete user with legacy service role key
4141
user_id=$(echo "$output" | jq -r '.user.id')
42-
output=$(curl -sS -X DELETE "http://127.0.0.1:54321/auth/v1/admin/users/$user_id" \
42+
output=$(curl -sS -X DELETE "$API_URL/auth/v1/admin/users/$user_id" \
4343
-H "Authorization: Bearer $SERVICE_ROLE_KEY" \
4444
-H 'Content-Type: application/json' \
4545
)

tests/edge-runtime.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -eou pipefail
55
# supabase --workdir tests functions serve
66

77
# 1. POST request with publishable key
8-
output=$(curl -sS 'http://127.0.0.1:54321/functions/v1/hello-world' \
8+
output=$(curl -sS "$API_URL/functions/v1/hello-world" \
99
-H "apikey: $PUBLISHABLE_KEY" \
1010
-H 'Content-Type: application/json' \
1111
-d '{"name":"Functions"}' \
@@ -17,7 +17,7 @@ if [[ $(echo "$output" | jq -r '.message') != 'Hello Functions!' ]]; then
1717
fi
1818

1919
# 2. POST request with legacy key
20-
output=$(curl -sS 'http://127.0.0.1:54321/functions/v1/hello-world' \
20+
output=$(curl -sS "$API_URL/functions/v1/hello-world" \
2121
-H "Authorization: Bearer $ANON_KEY" \
2222
-H 'Content-Type: application/json' \
2323
-d '{"name":"Functions"}' \
@@ -29,7 +29,7 @@ if [[ $(echo "$output" | jq -r '.message') != 'Hello Functions!' ]]; then
2929
fi
3030

3131
# 3. POST request with secret key
32-
output=$(curl -sS 'http://127.0.0.1:54321/functions/v1/hello-world' \
32+
output=$(curl -sS "$API_URL/functions/v1/hello-world" \
3333
-H "apikey: $SECRET_KEY" \
3434
-H 'Content-Type: application/json' \
3535
-d '{"name":"Functions"}' \
@@ -41,7 +41,7 @@ if [[ $(echo "$output" | jq -r '.message') != 'Hello Functions!' ]]; then
4141
fi
4242

4343
# 4. POST request with service role key
44-
output=$(curl -sS 'http://127.0.0.1:54321/functions/v1/hello-world' \
44+
output=$(curl -sS "$API_URL/functions/v1/hello-world" \
4545
-H "Authorization: Bearer $SERVICE_ROLE_KEY" \
4646
-H 'Content-Type: application/json' \
4747
-d '{"name":"Functions"}' \

tests/postgrest.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -eou pipefail
55
# supabase --workdir tests migrations up
66

77
# 1. Create todo as service role
8-
output=$(curl -sS 'http://127.0.0.1:54321/rest/v1/todos' \
8+
output=$(curl -sS "$API_URL/rest/v1/todos" \
99
-H "apikey: $SECRET_KEY" \
1010
-H 'Content-Type: application/json' \
1111
-H 'Prefer: return=representation' \
@@ -18,7 +18,7 @@ if [[ $(echo "$output" | jq -r 'length') != '1' ]]; then
1818
fi
1919

2020
# 2. Create todo as anon role should fail
21-
output=$(curl -sS 'http://127.0.0.1:54321/rest/v1/todos' \
21+
output=$(curl -sS "$API_URL/rest/v1/todos" \
2222
-H "apikey: $PUBLISHABLE_KEY" \
2323
-H 'Content-Type: application/json' \
2424
-d '{"task": "New task", "done": false}' \
@@ -30,7 +30,7 @@ if [[ $(echo "$output" | jq -r '.code') != '42501' ]]; then
3030
fi
3131

3232
# 3. List todos as anon role
33-
output=$(curl -sS -G 'http://127.0.0.1:54321/rest/v1/todos' \
33+
output=$(curl -sS -G "$API_URL/rest/v1/todos" \
3434
-H "apikey: $PUBLISHABLE_KEY" \
3535
-H 'Content-Type: application/json' \
3636
)
@@ -41,7 +41,7 @@ if [[ $(echo "$output" | jq -r 'length') != '1' ]]; then
4141
fi
4242

4343
# 4. Delete todo as anon role should fail
44-
output=$(curl -sS -X DELETE 'http://127.0.0.1:54321/rest/v1/todos?id=eq.1' \
44+
output=$(curl -sS -X DELETE "$API_URL/rest/v1/todos?id=eq.1" \
4545
-H "apikey: $PUBLISHABLE_KEY" \
4646
-H 'Content-Type: application/json' \
4747
-H 'Prefer: return=representation' \
@@ -53,7 +53,7 @@ if [[ $(echo "$output" | jq -r 'length') != '0' ]]; then
5353
fi
5454

5555
# 5. Delete todo as authenticated role (custom jwt)
56-
output=$(curl -sS -X DELETE 'http://127.0.0.1:54321/rest/v1/todos?id=not.eq.0' \
56+
output=$(curl -sS -X DELETE "$API_URL/rest/v1/todos?id=not.eq.0" \
5757
-H "apikey: $PUBLISHABLE_KEY" \
5858
-H "Authorization: Bearer $SERVICE_ROLE_KEY" \
5959
-H 'Content-Type: application/json' \

tests/realtime.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ if [[ $(echo "$output" | jq -r '.payload.status') != 'ok' ]]; then
2222
fi
2323

2424
## 3. Broadcast with secret key
25-
curl -sSf 'http://127.0.0.1:54321/realtime/v1/api/broadcast' \
25+
curl -sSf "$API_URL/realtime/v1/api/broadcast" \
2626
-H "apikey: $SECRET_KEY" \
2727
-H 'Content-Type: application/json' \
2828
-d '{"messages":[{"topic":"room1","event":"my_event","payload":{"foo":"bar"},"private":true}]}'

tests/storage.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -eou pipefail
33

44
# 1. Create test bucket as service role
5-
output=$(curl -sS 'http://127.0.0.1:54321/storage/v1/bucket' \
5+
output=$(curl -sS "$API_URL/storage/v1/bucket" \
66
-H "apikey: $SECRET_KEY" \
77
-H 'Content-Type: application/json' \
88
-d '{"name":"test"}' \
@@ -14,7 +14,7 @@ if [[ $(echo "$output" | jq -r '.name') != 'test' ]]; then
1414
fi
1515

1616
# 2. Create test bucket as service role (legacy key)
17-
output=$(curl -sS -X DELETE 'http://127.0.0.1:54321/storage/v1/bucket/test' \
17+
output=$(curl -sS -X DELETE "$API_URL/storage/v1/bucket/test" \
1818
-H "apikey: $SERVICE_ROLE_KEY" \
1919
-H 'Content-Type: application/json' \
2020
)
@@ -25,7 +25,7 @@ if [[ $(echo "$output" | jq -r '.message') != 'Successfully deleted' ]]; then
2525
fi
2626

2727
# 3. Unauthenticated requests are rejected
28-
output=$(curl -sS 'http://127.0.0.1:54321/storage/v1/bucket' \
28+
output=$(curl -sS "$API_URL/storage/v1/bucket" \
2929
-H 'Content-Type: application/json' \
3030
-d '{"name":"test"}' \
3131
)

0 commit comments

Comments
 (0)