Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 8 additions & 32 deletions tests/secret-providers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,12 +393,12 @@ describe("external secret-reference grammar", () => {

describe("secret command runner", () => {
it.runIf(process.platform === "win32")(
"observes a cold Node provider entry before its Windows helper settles",
"preserves a cold Node provider entry marker through Windows helper settlement",
async () => {
await inSandbox(async (directory) => {
const controller = new AbortController();
const providerReadyPath = join(directory, "provider-ready");
const pending = runSecretCommand(
const result = await runSecretCommand(
{
executable: process.execPath,
args: [fakeProviderPath],
Expand All @@ -409,37 +409,13 @@ describe("secret command runner", () => {
},
{ signal: controller.signal }
);
let commandSettled = false;
const observed = pending.then(
(result) => {
commandSettled = true;
return { status: "fulfilled" as const, result };
},
(error: unknown) => {
commandSettled = true;
return { status: "rejected" as const, error };
}
);
let settlementTimer: NodeJS.Timeout | undefined;

try {
await waitForProviderEntered(providerReadyPath, "the cold fake provider to enter through the Windows helper");
const outcome = await Promise.race([
observed,
new Promise<{ status: "pending" }>((resolve) => {
settlementTimer = setTimeout(() => resolve({ status: "pending" }), 2_000);
})
]);
if (outcome.status === "pending") {
throw new Error("The provider entered through the Windows helper but the helper did not settle within 2000ms");
}
if (outcome.status === "rejected") throw outcome.error;
expect(outcome.result.stdout.toString("utf8")).toBe("fixture-provider-secret");
} finally {
if (settlementTimer) clearTimeout(settlementTimer);
if (!commandSettled) controller.abort();
await observed;
}
// The fixture writes this marker synchronously before stdout and exit;
// runSecretCommand settles only after the contained helper has waited
// for that provider process. This proves the intended ordering without
// asserting a cold-start latency that the production contract does not promise.
expect(result.stdout.toString("utf8")).toBe("fixture-provider-secret");
await expect(readFile(providerReadyPath, "utf8")).resolves.toBe("provider-entered");
});
}
);
Expand Down