Repository navigation
Expand file tree
/
Copy pathedge-runtime.sh
More file actions
executable file
·53 lines (48 loc) · 1.59 KB
/
Copy pathedge-runtime.sh
File metadata and controls
executable file
·53 lines (48 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
set -eou pipefail
# 0. Serve Edge Functions
# supabase --workdir tests functions serve
# 1. POST request with publishable key
output=$(curl -sS "$API_URL/functions/v1/hello-world" \
-H "apikey: $PUBLISHABLE_KEY" \
-H 'Content-Type: application/json' \
-d '{"name":"Functions"}' \
)
if [[ $(echo "$output" | jq -r '.message') != 'Hello Functions!' ]]; then
echo 'Edge Function request with publishable key should succeed.' >&2
echo "$output" | jq
exit 1
fi
# 2. POST request with legacy key
output=$(curl -sS "$API_URL/functions/v1/hello-world" \
-H "Authorization: Bearer $ANON_KEY" \
-H 'Content-Type: application/json' \
-d '{"name":"Functions"}' \
)
if [[ $(echo "$output" | jq -r '.message') != 'Hello Functions!' ]]; then
echo 'Edge Function request with anon key should succeed.' >&2
echo "$output" | jq
exit 1
fi
# 3. POST request with secret key
output=$(curl -sS "$API_URL/functions/v1/hello-world" \
-H "apikey: $SECRET_KEY" \
-H 'Content-Type: application/json' \
-d '{"name":"Functions"}' \
)
if [[ $(echo "$output" | jq -r '.message') != 'Hello Functions!' ]]; then
echo 'Edge Function request with secret key should succeed.' >&2
echo "$output" | jq
exit 1
fi
# 4. POST request with service role key
output=$(curl -sS "$API_URL/functions/v1/hello-world" \
-H "Authorization: Bearer $SERVICE_ROLE_KEY" \
-H 'Content-Type: application/json' \
-d '{"name":"Functions"}' \
)
if [[ $(echo "$output" | jq -r '.message') != 'Hello Functions!' ]]; then
echo 'Edge Function request with service role key should succeed.' >&2
echo "$output" | jq
exit 1
fi