Files
headplane/tests/integration/api/versions.test.ts
T
Aarnav Tale 0512565f8e feat: replace openapi hashing system with /version
Apparently I didn't use my brain cells and rely on the /version
endpoint that Headscale has exposed since 0.26 (our lowest supported
version). Switching to that significantly simplifies the API surface.
2026-05-25 11:51:02 -04:00

42 lines
1.8 KiB
TypeScript

import { describe, expect, test } from "vitest";
import { gte } from "~/server/headscale/api/server-version";
import { getBootstrapClient, getRuntimeClient, HS_VERSIONS, Version } from "../setup/env";
describe.for(HS_VERSIONS)("Headscale %s: Runtime Client", (version) => {
test("the runtime client is usable", async () => {
const bootstrapper = await getBootstrapClient(version);
const runtimeClient = bootstrapper.client("test-api-key");
expect(runtimeClient).toBeDefined();
});
test("the server version reported by /version matches the running container", async () => {
const bootstrapper = await getBootstrapClient(version);
expect(bootstrapper.version.unknown).toBe(false);
const reported = `${bootstrapper.version.major}.${bootstrapper.version.minor}.${bootstrapper.version.patch}`;
expect(reported).toBe(version);
});
test("capabilities are derived correctly from the detected version", async (context) => {
const bootstrapper = await getBootstrapClient(version);
const v = bootstrapper.version;
expect(bootstrapper.capabilities.preAuthKeysHaveStableIds).toBe(gte(v, "0.28.0"));
expect(bootstrapper.capabilities.nodeTagsAreFlat).toBe(gte(v, "0.28.0"));
expect(bootstrapper.capabilities.nodeOwnerIsImmutable).toBe(gte(v, "0.28.0"));
expect(bootstrapper.capabilities.policyErrorsUseModernFormat).toBe(gte(v, "0.27.0"));
// The known version table only has 0.26+; if a future version is added
// before this test is updated, surface that explicitly rather than passing.
const known: Version[] = ["0.26.1", "0.27.0", "0.27.1", "0.28.0"];
if (!known.includes(version)) {
context.skip();
}
});
test("the health check endpoint works", async () => {
const client = await getRuntimeClient(version);
const health = await client.isHealthy();
expect(health).toBe(true);
});
});