You've already forked tribes-supertest
63af948463
Drop provider account ids from runtime config and node-create CLI calls. Update sanitized Legion state handling for the providers field and keep helper tests portable on macOS temp paths.
127 lines
4.5 KiB
TypeScript
127 lines
4.5 KiB
TypeScript
import assert from "node:assert/strict"
|
|
import test from "node:test"
|
|
|
|
import { buildConfigSummary, resolveRuntimeConfig } from "../src/config.js"
|
|
|
|
test("resolveRuntimeConfig applies defaults and stable run metadata", () => {
|
|
const now = new Date("2026-04-09T12:34:56.000Z")
|
|
const config = resolveRuntimeConfig(
|
|
"single-node-init",
|
|
{
|
|
LEGION_UNLOCK_PASSWORD: "unlock-secret"
|
|
},
|
|
"/workspace/tribes-supertest",
|
|
now
|
|
)
|
|
|
|
assert.equal(config.runId, "2026-04-09t123456000z")
|
|
assert.equal(config.shortRunId, "20260409-0af3ea")
|
|
assert.equal(config.nodeNamePrefix, "st-20260409-0af3ea")
|
|
assert.equal(config.legion.repoDir, "/workspace/legion_kk")
|
|
assert.equal(config.legion.kexecImage, undefined)
|
|
assert.equal(
|
|
config.artifactRootDir,
|
|
"/workspace/tribes-supertest/.state/supertest/2026-04-09t123456000z-single-node-init"
|
|
)
|
|
assert.equal(config.bootstrapPasswordEnvName, "TRIBES_SUPERTEST_BOOTSTRAP_PASSWORD")
|
|
assert.equal(config.tribeDomain, "tribes-supertest-2026-04-09t123456000z.invalid")
|
|
assert.equal(config.legion.testCertificateMode, "acme")
|
|
assert.equal(config.waitOnFailure, false)
|
|
assert.equal(config.providers.manual.instance, "manual:x86_64:ubuntu-compatible")
|
|
assert.equal(config.providers.manual.passwordEnvName, "SUPERTEST_MANUAL_PASSWORD")
|
|
})
|
|
|
|
test("resolveRuntimeConfig supports explicit kexec image URL", () => {
|
|
const config = resolveRuntimeConfig(
|
|
"single-node-init",
|
|
{
|
|
LEGION_UNLOCK_PASSWORD: "unlock-secret",
|
|
SUPERTEST_KEXEC_IMAGE:
|
|
"https://mirror.tribe-one.org/tribes-1/guix-kexec-installer-x86_64-linux-latest.tar.gz"
|
|
},
|
|
"/workspace/tribes-supertest",
|
|
new Date("2026-04-09T12:34:56.000Z")
|
|
)
|
|
|
|
assert.equal(
|
|
config.legion.kexecImage,
|
|
"https://mirror.tribe-one.org/tribes-1/guix-kexec-installer-x86_64-linux-latest.tar.gz"
|
|
)
|
|
})
|
|
|
|
test("resolveRuntimeConfig supports test self-signed cert mode", () => {
|
|
const config = resolveRuntimeConfig(
|
|
"single-node-init",
|
|
{
|
|
LEGION_UNLOCK_PASSWORD: "unlock-secret",
|
|
SUPERTEST_CERT_MODE: "self-signed"
|
|
},
|
|
"/workspace/tribes-supertest",
|
|
new Date("2026-04-09T12:34:56.000Z")
|
|
)
|
|
|
|
assert.equal(config.legion.testCertificateMode, "self-signed")
|
|
})
|
|
|
|
test("resolveRuntimeConfig supports wait on failure mode", () => {
|
|
const config = resolveRuntimeConfig(
|
|
"single-node-init",
|
|
{
|
|
LEGION_UNLOCK_PASSWORD: "unlock-secret",
|
|
SUPERTEST_WAIT_ON_FAILURE: "1"
|
|
},
|
|
"/workspace/tribes-supertest",
|
|
new Date("2026-04-09T12:34:56.000Z")
|
|
)
|
|
|
|
assert.equal(config.waitOnFailure, true)
|
|
})
|
|
|
|
test("buildConfigSummary reports provider readiness without leaking secrets", () => {
|
|
const config = resolveRuntimeConfig(
|
|
"cross-provider-cluster-lifecycle",
|
|
{
|
|
LEGION_UNLOCK_PASSWORD: "unlock-secret",
|
|
HCLOUD_TOKEN: "hcloud-secret",
|
|
OVH_APP_KEY: "ovh-key",
|
|
OVH_APP_SECRET: "ovh-secret",
|
|
OVH_CONSUMER_KEY: "ovh-consumer",
|
|
SCW_ACCESS_KEY: "access",
|
|
SCW_SECRET_KEY: "secret",
|
|
SCW_DEFAULT_PROJECT_ID: "project",
|
|
SUPERTEST_MANUAL_HOST_IP: "203.0.113.10",
|
|
SUPERTEST_MANUAL_USERNAME: "ubuntu",
|
|
SUPERTEST_MANUAL_PASSWORD: "manual-secret"
|
|
},
|
|
"/workspace/tribes-supertest",
|
|
new Date("2026-04-09T12:34:56.000Z")
|
|
)
|
|
|
|
const summary = buildConfigSummary(config, {
|
|
LEGION_UNLOCK_PASSWORD: "unlock-secret",
|
|
HCLOUD_TOKEN: "hcloud-secret",
|
|
OVH_APP_KEY: "ovh-key",
|
|
OVH_APP_SECRET: "ovh-secret",
|
|
OVH_CONSUMER_KEY: "ovh-consumer",
|
|
SCW_ACCESS_KEY: "access",
|
|
SCW_SECRET_KEY: "secret",
|
|
SCW_DEFAULT_PROJECT_ID: "project",
|
|
SUPERTEST_MANUAL_HOST_IP: "203.0.113.10",
|
|
SUPERTEST_MANUAL_USERNAME: "ubuntu",
|
|
SUPERTEST_MANUAL_PASSWORD: "manual-secret"
|
|
})
|
|
|
|
assert.equal(summary.legion.unlockPasswordProvided, true)
|
|
assert.equal(summary.legion.testCertificateMode, "acme")
|
|
assert.equal(summary.providers.hetzner.configured, true)
|
|
assert.equal(summary.providers.ovh.configured, true)
|
|
assert.equal(summary.providers.ovh.endpoint, "ovh-eu")
|
|
assert.equal(summary.providers.scaleway.configured, true)
|
|
assert.equal(summary.providers.manual.configured, true)
|
|
assert.equal(summary.providers.manual.hostIp, "203.0.113.10")
|
|
assert.equal(summary.providers.manual.username, "ubuntu")
|
|
assert.equal(summary.providers.manual.passwordEnvName, "SUPERTEST_MANUAL_PASSWORD")
|
|
assert.equal("password" in (summary.providers.manual as Record<string, unknown>), false)
|
|
assert.equal("unlockPassword" in (summary.legion as Record<string, unknown>), false)
|
|
})
|