feat(hololake): render bounded release front door config

This commit is contained in:
冰朔 2026-08-13 19:16:15 +08:00
commit 461517c25f
6 changed files with 131 additions and 0 deletions

View file

@ -0,0 +1,22 @@
import assert from 'node:assert/strict'
import test from 'node:test'
import { renderFrontDoorSnippet } from '../server/release-broadcast/render-front-door.mjs'
test('front-door renderer refuses an unassigned or privileged loopback port', () => {
assert.throws(() => renderFrontDoorSnippet(null), /PORT_REQUIRED/)
assert.throws(() => renderFrontDoorSnippet(443), /PORT_REQUIRED|PORT_INVALID/)
assert.throws(() => renderFrontDoorSnippet('not-a-port'), /PORT_REQUIRED/)
})
test('rendered proxy preserves the public path and strips request authority', () => {
const snippet = renderFrontDoorSnippet(23940)
assert.match(snippet, /location \^~ \/hololake\/releases\//)
assert.match(snippet, /proxy_pass http:\/\/127\.0\.0\.1:23940;/)
assert.doesNotMatch(snippet, /proxy_pass http:\/\/127\.0\.0\.1:23940\//)
assert.match(snippet, /limit_except GET HEAD \{ deny all; \}/)
assert.match(snippet, /proxy_pass_request_body off;/)
assert.match(snippet, /proxy_set_header Authorization "";/)
assert.match(snippet, /proxy_set_header Cookie "";/)
assert.match(snippet, /proxy_set_header X-Forwarded-For "";/)
})