|
3 | 3 | from typing import cast
|
4 | 4 | import docker
|
5 | 5 | import pytest
|
| 6 | +import requests |
6 | 7 | import subprocess
|
7 | 8 | import testinfra
|
8 | 9 |
|
9 | 10 | all_in_one_image_tag = "supabase/all-in-one:testinfra"
|
10 | 11 | all_in_one_envs = {
|
11 | 12 | "POSTGRES_PASSWORD": "postgres",
|
12 | 13 | "JWT_SECRET": "super-secret-jwt-token-with-at-least-32-characters-long",
|
13 |
| - "ANON_KEY": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE", |
14 |
| - "SERVICE_ROLE_KEY": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q", |
| 14 | + "ANON_KEY": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiIsImlzcyI6InN1cGFiYXNlLWRlbW8iLCJpYXQiOjE2NDE3NjkyMDAsImV4cCI6MTc5OTUzNTYwMH0.F_rDxRTPE8OU83L_CNgEGXfmirMXmMMugT29Cvc8ygQ", |
| 15 | + "SERVICE_ROLE_KEY": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoic2VydmljZV9yb2xlIiwiaXNzIjoic3VwYWJhc2UtZGVtbyIsImlhdCI6MTY0MTc2OTIwMCwiZXhwIjoxNzk5NTM1NjAwfQ.5z-pJI1qwZg1LE5yavGLqum65WOnnaaI5eZ3V00pLww", |
15 | 16 | "ADMIN_API_KEY": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoic3VwYWJhc2VfYWRtaW4iLCJpc3MiOiJzdXBhYmFzZS1kZW1vIiwiaWF0IjoxNjQxNzY5MjAwLCJleHAiOjE3OTk1MzU2MDB9.Y9mSNVuTw2TdfryoaqM5wySvwQemGGWfSe9ixcklVfM",
|
16 | 17 | "DATA_VOLUME_MOUNTPOINT": "/data",
|
17 | 18 | "MACHINE_TYPE": "shared_cpu_1x_512m",
|
@@ -74,6 +75,29 @@ def get_health(container: Container) -> str:
|
74 | 75 | container.remove(v=True, force=True)
|
75 | 76 |
|
76 | 77 |
|
77 |
| -def test_postgrest_service(host): |
| 78 | +def test_postgrest_is_running(host): |
78 | 79 | postgrest = host.supervisor("services:postgrest")
|
79 | 80 | assert postgrest.is_running
|
| 81 | + |
| 82 | + |
| 83 | +def test_postgrest_responds_to_requests(): |
| 84 | + res = requests.get( |
| 85 | + "http://localhost:8000/rest/v1/", |
| 86 | + headers={ |
| 87 | + "apikey": all_in_one_envs["ANON_KEY"], |
| 88 | + "authorization": f"Bearer {all_in_one_envs['ANON_KEY']}", |
| 89 | + }, |
| 90 | + ) |
| 91 | + assert res.ok |
| 92 | + |
| 93 | + |
| 94 | +def test_postgrest_can_connect_to_db(): |
| 95 | + res = requests.get( |
| 96 | + "http://localhost:8000/rest/v1/buckets", |
| 97 | + headers={ |
| 98 | + "apikey": all_in_one_envs["SERVICE_ROLE_KEY"], |
| 99 | + "authorization": f"Bearer {all_in_one_envs['SERVICE_ROLE_KEY']}", |
| 100 | + "accept-profile": "storage", |
| 101 | + }, |
| 102 | + ) |
| 103 | + assert res.ok |
0 commit comments