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.
This commit is contained in:
Aarnav Tale
2026-05-23 19:59:03 -04:00
parent d4eee702e9
commit 0512565f8e
59 changed files with 1123 additions and 1573 deletions
+21 -16
View File
@@ -1,31 +1,36 @@
import { describe, expect, test } from "vitest";
import canonicals from "~/openapi-canonical-families.json";
import { gte } from "~/server/headscale/api/server-version";
import { getBootstrapClient, getRuntimeClient, HS_VERSIONS, Version } from "../setup/env";
function getCanonicalVersion(version: Version) {
const canonical = Object.entries(canonicals).find(([_, family]) =>
family.includes(version),
)?.[0] as Version | undefined;
if (!canonical) {
return version;
}
return canonical;
}
describe.for(HS_VERSIONS)("Headscale %s: Runtime Client", (version) => {
test("the runtime client is usable", async () => {
const bootstrapper = await getBootstrapClient(version);
const runtimeClient = bootstrapper.getRuntimeClient("test-api-key");
const runtimeClient = bootstrapper.client("test-api-key");
expect(runtimeClient).toBeDefined();
});
test("the runtime client has the correct canonical API version", async () => {
test("the server version reported by /version matches the running container", async () => {
const bootstrapper = await getBootstrapClient(version);
expect(bootstrapper.apiVersion).toBe(getCanonicalVersion(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 () => {