Skip to content
Open
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
7 changes: 6 additions & 1 deletion src/dns.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2325,6 +2325,11 @@ export async function dnsCommand(args = [], out = console.log, deps = {}) {
readManifest = async (path) => parseManifest(await defaultReadMaybe(path)),
uid = typeof process.getuid === "function" ? process.getuid() : 0,
escalate = escalateSelf,
// Injected for the same reason as everything above: the enable/disable
// decision tree reads the host's drop-ins only on linux/systemd-resolved,
// and a test running on any other OS must be able to say "linux" without
// lying about the machine it is on.
platform: platformImpl = detectPlatform,
} = deps;
const [sub, ...rest] = args;
const flag = (name, fallback) => {
Expand Down Expand Up @@ -2595,7 +2600,7 @@ export async function dnsCommand(args = [], out = console.log, deps = {}) {
}

if (sub === "enable" || sub === "disable") {
const platform = detectPlatform();
const platform = platformImpl();
if (!platform) {
out(`unsupported platform: ${process.platform}`);
return 1;
Expand Down
4 changes: 4 additions & 0 deletions test/dns-disable-restore.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,10 @@ let lastVerifyArgs = null;

function noSystem() {
return {
// The enable/disable tree reads host drop-ins only on linux +
// systemd-resolved; pinning the platform makes those paths deterministic
// on a Mac or Windows checkout instead of silently skipped.
platform: () => "linux",
tlds: async () => ["eggs", "hacker"],
safety: async () => ({ safe: true, upstreams: ["1.1.1.1"], why: "" }),
preflight: async () => ({ ok: true, blockers: [], conflicts: [], duplicates: [], holder: null }),
Expand Down
4 changes: 4 additions & 0 deletions test/dns-enable-rollback.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,10 @@ test("--dry-run still reports a preflight that would refuse", async () => {
/** Every system call `enable` makes, stubbed to a machine where nothing is wrong. */
function noSystem() {
return {
// The enable tree consults host drop-ins only on linux +
// systemd-resolved; pinning the platform keeps those paths testable from
// any OS the suite runs on.
platform: () => "linux",
tlds: async () => ["eggs", "hacker"],
safety: async () => ({ safe: true, upstreams: ["1.1.1.1"], why: "no bridge is running yet — this one will be ours" }),
preflight: async () => ({ ok: true, blockers: [], conflicts: [], holder: null }),
Expand Down