teqo/tests/unit/localHosts.unit.spec.ts
Francisco Solla 02f68894c3
Some checks failed
Agent PR Ready + auto-merge / ready-automerge (pull_request) Has been skipped
CI (PR) / docs-guards (pull_request) Successful in 6s
CI (PR) / plans-only-closes (pull_request) Successful in 6s
CI (PR) / scope (pull_request) Successful in 31s
CI (PR) / lint (pull_request) Successful in 40s
CI (PR) / format (pull_request) Successful in 48s
CI (PR) / typecheck (pull_request) Successful in 31s
CI (PR) / knip (pull_request) Successful in 32s
CI (PR) / cycles (pull_request) Successful in 33s
CI (PR) / unit (pull_request) Successful in 46s
CI (PR) / build (pull_request) Has been skipped
CI (PR) / int (pull_request) Failing after 1m5s
CI (PR) / e2e (pull_request) Failing after 2m47s
CI (PR) / checks (pull_request) Failing after 1s
fix(ci OPS50): guards de banco aceitam o gateway da bridge do runner (RFC1918) — postgres do services: fica no IP do gateway, não em localhost
2026-08-17 03:46:16 -03:00

28 lines
1 KiB
TypeScript

// @vitest-environment node
import { describe, expect, it } from 'vitest'
import { defaultGatewayHost, LOCAL_HOSTS } from '../../scripts/lib/cli.mjs'
describe('LOCAL_HOSTS (OPS50 — self-hosted runner reaches services via the bridge gateway)', () => {
it('still contains the canonical static hosts', () => {
for (const host of ['localhost', '127.0.0.1', '0.0.0.0', '::1', 'postgres']) {
expect(LOCAL_HOSTS.has(host)).toBe(true)
}
})
it('admits the machine default gateway when it is RFC1918 (Linux CI bridge)', () => {
const gateway = defaultGatewayHost()
if (gateway) {
// The Forgejo runner publishes the job's postgres service on the bridge
// gateway IP; assertLocalDatabase must accept it so seeds run in CI.
expect(LOCAL_HOSTS.has(gateway)).toBe(true)
}
})
it('never admits public or loopback hosts', () => {
expect(LOCAL_HOSTS.has('8.8.8.8')).toBe(false)
expect(LOCAL_HOSTS.has('127.0.0.2')).toBe(false)
expect(LOCAL_HOSTS.has('203.0.113.1')).toBe(false)
})
})