Skip to content

Commit

Permalink
check #3439
Browse files Browse the repository at this point in the history
  • Loading branch information
kt3k committed Jun 13, 2023
1 parent aea8515 commit 48fd7b7
Showing 1 changed file with 50 additions and 1 deletion.
51 changes: 50 additions & 1 deletion http/file_server_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ import { writeAll } from "../streams/write_all.ts";
import { TextLineStream } from "../streams/text_line_stream.ts";
import { serveDir, serveFile } from "./file_server.ts";
import { calculate } from "./etag.ts";
import { dirname, fromFileUrl, join, resolve, toFileUrl } from "../path/mod.ts";
import {
basename,
dirname,
fromFileUrl,
join,
resolve,
toFileUrl,
} from "../path/mod.ts";
import { isWindows } from "../_util/os.ts";
import { VERSION } from "../version.ts";
import { retry } from "../async/retry.ts";
Expand Down Expand Up @@ -1564,3 +1571,45 @@ Deno.test("file_server should resolve `path` correctly on Windows", {
await killFileServer();
}
});

Deno.test(
"file_server should resolve empty subdir correctly without asking for current directory read permission on Windows",
{
ignore: Deno.build.os !== "windows",
},
async () => {
const tempDir = Deno.makeTempDirSync({ dir: `${moduleDir}/testdata` });
const fileServer = new Deno.Command(Deno.execPath(), {
// specifying a path for `--allow-read` this is essential for this test
// otherwise it won't trigger the edge case
args: [
"run",
"--no-check",
"--no-prompt",
"--quiet",
`--allow-read=${moduleDir}/testdata`,
"--allow-net",
"file_server.ts",
moduleDir,
"--host",
"localhost",
"--port",
"4507",
],
cwd: moduleDir,
stdout: "null",
stderr: "null",
});
child = fileServer.spawn();
try {
const resp = await fetch(
`http://localhost:4507/testdata/${basename(tempDir)}`,
);
assertEquals(resp.status, 200);
await resp.text(); // Consuming the body so that the test doesn't leak resources
} finally {
await killFileServer();
Deno.removeSync(tempDir);
}
},
);

0 comments on commit 48fd7b7

Please sign in to comment.