48 lines
1.7 KiB
TypeScript
48 lines
1.7 KiB
TypeScript
import { sshCaptureBackendPlan } from "./src/ssh";
|
|
|
|
function assertCondition(condition: unknown, message: string, detail: unknown = {}): void {
|
|
if (!condition) throw new Error(`${message}: ${JSON.stringify(detail)}`);
|
|
}
|
|
|
|
const baseConfig = {
|
|
network: { publicHost: "74.48.78.17" },
|
|
} as Parameters<typeof sshCaptureBackendPlan>[0];
|
|
|
|
const runnerPlan = sshCaptureBackendPlan(baseConfig, {
|
|
KUBERNETES_SERVICE_HOST: "10.43.0.1",
|
|
});
|
|
|
|
assertCondition(
|
|
runnerPlan.backend === "remote-frontend-websocket" && runnerPlan.remoteHost === "74.48.78.17" && runnerPlan.reason === "runner-environment",
|
|
"ssh capture should use frontend websocket in runner environments",
|
|
runnerPlan,
|
|
);
|
|
|
|
const explicitHostPlan = sshCaptureBackendPlan(baseConfig, {
|
|
UNIDESK_MAIN_SERVER_IP: "http://74.48.78.17:18081/",
|
|
KUBERNETES_SERVICE_HOST: "10.43.0.1",
|
|
});
|
|
|
|
assertCondition(
|
|
explicitHostPlan.backend === "remote-frontend-websocket" && explicitHostPlan.remoteHost === "http://74.48.78.17:18081",
|
|
"ssh capture should prefer explicit main server host hints and trim trailing slash",
|
|
explicitHostPlan,
|
|
);
|
|
|
|
const localOnlyPlan = sshCaptureBackendPlan({ network: { publicHost: "127.0.0.1" } } as Parameters<typeof sshCaptureBackendPlan>[0], {});
|
|
|
|
assertCondition(
|
|
localOnlyPlan.backend === "local-backend-core-broker" && localOnlyPlan.remoteHost === null,
|
|
"ssh capture should keep local backend-core broker mode when no remote host is configured",
|
|
localOnlyPlan,
|
|
);
|
|
|
|
console.log(JSON.stringify({
|
|
ok: true,
|
|
checks: [
|
|
"runner environments use remote frontend websocket capture",
|
|
"explicit main server host hints are preferred and normalized",
|
|
"local-only environments keep local backend-core broker mode",
|
|
],
|
|
}));
|