Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions tests/windows-symlink-capability.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import fs from "node:fs";
/**
* Only symbolic-link fixture creation is optional on non-admin Windows
* workstations without Developer Mode. Production link rejection is unchanged.
* Our Windows CI must exercise the real symlink case, never waive it.
* Audited GitHub Actions Windows CI must exercise the real symlink case, never
* waive it. The local job runner also sets CI=true but is a workstation, so only
* GITHUB_ACTIONS (never an arbitrary CI flag) makes the privilege mandatory.
*/
export function tryFileSymlink(t, target, link) {
try {
Expand All @@ -16,7 +18,7 @@ export function tryFileSymlink(t, target, link) {
) {
throw error;
}
if (process.env.CI === "true") {
if (process.env.GITHUB_ACTIONS === "true") {
throw new Error("WINDOWS_CI_SYMLINK_PRIVILEGE_REQUIRED", {
cause: error,
});
Expand Down
16 changes: 11 additions & 5 deletions tests/windows-symlink-capability.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,24 @@ test("Windows symlink fixtures diagnose non-admin privilege without weakening CI
error.code = "EPERM";
throw error;
});
const prior = process.env.CI;
const prior = process.env.GITHUB_ACTIONS;
const priorCi = process.env.CI;
try {
delete process.env.CI;
assert.equal(tryFileSymlink(t, "target.txt", "link.txt"), false);
delete process.env.GITHUB_ACTIONS;
// The local job runner exports CI=true; that alone must not make a
// non-admin workstation fail, it is not the audited CI.
process.env.CI = "true";
assert.equal(tryFileSymlink(t, "target.txt", "link.txt"), false);
process.env.GITHUB_ACTIONS = "true";
assert.throws(
() => tryFileSymlink(t, "target.txt", "link.txt"),
/WINDOWS_CI_SYMLINK_PRIVILEGE_REQUIRED/,
);
} finally {
if (prior === undefined) delete process.env.CI;
else process.env.CI = prior;
if (prior === undefined) delete process.env.GITHUB_ACTIONS;
else process.env.GITHUB_ACTIONS = prior;
if (priorCi === undefined) delete process.env.CI;
else process.env.CI = priorCi;
}
});

Expand Down