From 6cbb1374a081011da99c7ad3228609f0173102c5 Mon Sep 17 00:00:00 2001 From: Ohkubo KOHEI Date: Fri, 25 Apr 2025 16:10:25 +0900 Subject: [PATCH 1/2] update permissions samples on testing.md --- runtime/fundamentals/testing.md | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/runtime/fundamentals/testing.md b/runtime/fundamentals/testing.md index 8d0b722ed..37986c60e 100644 --- a/runtime/fundamentals/testing.md +++ b/runtime/fundamentals/testing.md @@ -48,7 +48,6 @@ Deno.test("async test", async () => { Deno.test({ name: "read file test", - permissions: { read: true }, fn: () => { const data = Deno.readTextFileSync("./somefile.txt"); assertEquals(data, "expected content"); @@ -97,7 +96,7 @@ deno test my_test.ts -- -e --foo --bar # Provide permission for deno to read from the filesystem, which is necessary # for the final test above to pass -deno test --allow-read my_test.ts +deno test --allow-read=. my_test.ts ``` ## Test Steps @@ -611,7 +610,7 @@ import getFileText from "./main.ts"; Deno.test({ name: "File reader gets text with permission", - permissions: { read: true }, + // no `permissions` means "inherit" fn: async () => { const result = await getFileText(); console.log(result); @@ -640,11 +639,9 @@ The permissions object supports detailed configuration: ```ts Deno.test({ name: "permission configuration example", + // permissions: { read: true } // Grant all read permissions and deny all others permissions: { - read: true, // Grant all read permissions - // OR read: ["./data", "./config"], // Grant read to specific paths only - write: false, // Explicitly deny write permissions net: ["example.com:443"], // Allow specific host:port combinations env: ["API_KEY"], // Allow access to specific env variables From be0ceca5ddb1f3a764aaa9ffc80220f1b452f4a4 Mon Sep 17 00:00:00 2001 From: Ohkubo KOHEI Date: Fri, 25 Apr 2025 16:23:36 +0900 Subject: [PATCH 2/2] Update testing.md --- runtime/fundamentals/testing.md | 1 + 1 file changed, 1 insertion(+) diff --git a/runtime/fundamentals/testing.md b/runtime/fundamentals/testing.md index 37986c60e..ec0b0c657 100644 --- a/runtime/fundamentals/testing.md +++ b/runtime/fundamentals/testing.md @@ -640,6 +640,7 @@ The permissions object supports detailed configuration: Deno.test({ name: "permission configuration example", // permissions: { read: true } // Grant all read permissions and deny all others + // OR permissions: { read: ["./data", "./config"], // Grant read to specific paths only write: false, // Explicitly deny write permissions