Refuse to boot without R2 credentials
`?? ""` on the access key and secret meant a deployment with no object storage configured started happily, and `POST /jobs` handed clients presigned URLs signed with an empty key. The first sign of trouble was a 403 from R2 - either in the client's uploader or, worse, inside a gateway that had downloaded R2's XML error document in place of a print. Nothing in that chain said "R2 is not configured". Reads both credentials through a `required()` that throws, naming the variable, mirroring auth/verifier.ts and auth/edge_secret.ts. The endpoint is read with `||` rather than `??`, because the committed template ships `R2_ENDPOINT=` empty and `??` only catches null - so an empty value was taken as a real endpoint and the account-id derivation never ran. That is the trap auth/edge_secret.ts documents, and it caught this line too, in the first draft of it. A test covers the derivation. Each boot-failure test fills every other variable so the one under test is the only thing missing; otherwise whichever variable is read first wins and the assertion passes for the wrong reason. e2e-edge.sh gains dummy values, since it boots the backend. It presigns nothing, so they only have to exist.
This commit is contained in:
@@ -39,7 +39,14 @@ BASE="http://localhost:$PORT"
|
||||
DATABASE_URL="${DATABASE_URL:-postgres://continuum:continuum@localhost:5432/continuum}"
|
||||
VALKEY_URL="${VALKEY_URL:-redis://localhost:6379}"
|
||||
EDGE_JWT_SECRET="${EDGE_JWT_SECRET:-e2e-edge-secret}"
|
||||
# The backend refuses to boot without object-storage credentials, which is
|
||||
# deliberate - see src/s3/index.ts. Nothing in this test presigns or uploads
|
||||
# anything, so these only have to exist.
|
||||
R2_ACCESS_KEY_ID="${R2_ACCESS_KEY_ID:-e2e}"
|
||||
R2_SECRET_ACCESS_KEY="${R2_SECRET_ACCESS_KEY:-e2e}"
|
||||
R2_ENDPOINT="${R2_ENDPOINT:-http://localhost:9000}"
|
||||
export DATABASE_URL VALKEY_URL EDGE_JWT_SECRET PORT
|
||||
export R2_ACCESS_KEY_ID R2_SECRET_ACCESS_KEY R2_ENDPOINT
|
||||
|
||||
WORK="$(mktemp -d)"
|
||||
BACKEND_PID=""
|
||||
@@ -196,6 +203,11 @@ env -C "$PROXY_DIR" \
|
||||
CONTINUUM_FARM_ID="$FARM_ID" \
|
||||
CONTINUUM_GATEWAY_TOKEN="$TOKEN" \
|
||||
CONTINUUM_UPLINK_URL="ws://localhost:$PORT/ws/edge/v1" \
|
||||
`# Deliberately absent, not an oversight: what is under test is the config` \
|
||||
`# the gateway writes and the camera_stream it advertises, both of which` \
|
||||
`# happen without go2rtc. Spawning the real one would bind :1984 and dial` \
|
||||
`# the printers on the LAN, so the test would depend on hardware it does` \
|
||||
`# not need. The supervisor logs a spawn failure every 5s; that is expected.` \
|
||||
CONTINUUM_GO2RTC_BIN=/nonexistent-go2rtc \
|
||||
CONTINUUM_GO2RTC_CONFIG="$WORK/go2rtc.yaml" \
|
||||
CONTINUUM_STREAM_BASE_URL="$STREAM_BASE_URL" \
|
||||
|
||||
Reference in New Issue
Block a user