diff options
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/integration/run_tests.rs | 56 | ||||
-rw-r--r-- | cli/tests/testdata/run/permissions_prompt_allow_all.ts | 20 | ||||
-rw-r--r-- | cli/tests/testdata/run/permissions_prompt_allow_all_2.ts | 8 |
3 files changed, 84 insertions, 0 deletions
diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs index d42136f84..10ff6d2e0 100644 --- a/cli/tests/integration/run_tests.rs +++ b/cli/tests/integration/run_tests.rs @@ -591,6 +591,62 @@ fn _090_run_permissions_request_sync() { ]); } +#[test] +fn permissions_prompt_allow_all() { + let args = "run --quiet run/permissions_prompt_allow_all.ts"; + use util::PtyData::*; + util::test_pty2(args, vec![ + // "run" permissions + Output("┌ ⚠️ Deno requests run access to \"FOO\".\r\n├ Requested by `Deno.permissions.query()` API\r\n ├ Run again with --allow-run to bypass this prompt.\r\n└ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all run permissions) >"), + Input("a\n"), + Output("✅ Granted all run access.\r\n"), + // "read" permissions + Output("┌ ⚠️ Deno requests read access to \"FOO\".\r\n├ Requested by `Deno.permissions.query()` API\r\n ├ Run again with --allow-read to bypass this prompt.\r\n└ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all read permissions) >"), + Input("a\n"), + Output("✅ Granted all read access.\r\n"), + // "write" permissions + Output("┌ ⚠️ Deno requests write access to \"FOO\".\r\n├ Requested by `Deno.permissions.query()` API\r\n ├ Run again with --allow-write to bypass this prompt.\r\n└ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all write permissions) >"), + Input("a\n"), + Output("✅ Granted all write access.\r\n"), + // "net" permissions + Output("┌ ⚠️ Deno requests net access to \"FOO\".\r\n├ Requested by `Deno.permissions.query()` API\r\n ├ Run again with --allow-net to bypass this prompt.\r\n└ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all net permissions) >"), + Input("a\n"), + Output("✅ Granted all net access.\r\n"), + // "env" permissions + Output("┌ ⚠️ Deno requests env access to \"FOO\".\r\n├ Requested by `Deno.permissions.query()` API\r\n ├ Run again with --allow-env to bypass this prompt.\r\n└ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all env permissions) >"), + Input("a\n"), + Output("✅ Granted all env access.\r\n"), + // "sys" permissions + Output("┌ ⚠️ Deno requests sys access to \"loadavg\".\r\n├ Requested by `Deno.permissions.query()` API\r\n ├ Run again with --allow-sys to bypass this prompt.\r\n└ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all sys permissions) >"), + Input("a\n"), + Output("✅ Granted all sys access.\r\n"), + // "ffi" permissions + Output("┌ ⚠️ Deno requests ffi access to \"FOO\".\r\n├ Requested by `Deno.permissions.query()` API\r\n ├ Run again with --allow-ffi to bypass this prompt.\r\n└ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all ffi permissions) >"), + Input("a\n"), + Output("✅ Granted all ffi access.\r\n") + ]); +} + +#[test] +fn permissions_prompt_allow_all_2() { + let args = "run --quiet run/permissions_prompt_allow_all_2.ts"; + use util::PtyData::*; + util::test_pty2(args, vec![ + // "env" permissions + Output("┌ ⚠️ Deno requests env access to \"FOO\".\r\n├ Run again with --allow-env to bypass this prompt.\r\n└ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all env permissions) >"), + Input("d\n"), + Output("✅ Granted all env access.\r\n"), + // "sys" permissions + Output("┌ ⚠️ Deno requests sys access to \"FOO\".\r\n├ Run again with --allow-sys to bypass this prompt.\r\n└ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all sys permissions) >"), + Input("d\n"), + Output("✅ Granted all sys access.\r\n"), + // "read" permissions + Output("┌ ⚠️ Deno requests read access to \"FOO\".\r\n├ Run again with --allow-read to bypass this prompt.\r\n└ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all read permissions) >"), + Input("d\n"), + Output("✅ Granted all read access.\r\n"), + ]); +} + itest!(_091_use_define_for_class_fields { args: "run --check run/091_use_define_for_class_fields.ts", output: "run/091_use_define_for_class_fields.ts.out", diff --git a/cli/tests/testdata/run/permissions_prompt_allow_all.ts b/cli/tests/testdata/run/permissions_prompt_allow_all.ts new file mode 100644 index 000000000..8aa7d040e --- /dev/null +++ b/cli/tests/testdata/run/permissions_prompt_allow_all.ts @@ -0,0 +1,20 @@ +Deno.permissions.requestSync({ name: "run", command: "FOO" }); +Deno.permissions.requestSync({ name: "run", command: "BAR" }); + +Deno.permissions.requestSync({ name: "read", path: "FOO" }); +Deno.permissions.requestSync({ name: "read", path: "BAR" }); + +Deno.permissions.requestSync({ name: "write", path: "FOO" }); +Deno.permissions.requestSync({ name: "write", path: "BAR" }); + +Deno.permissions.requestSync({ name: "net", host: "FOO" }); +Deno.permissions.requestSync({ name: "net", host: "BAR" }); + +Deno.permissions.requestSync({ name: "env", variable: "FOO" }); +Deno.permissions.requestSync({ name: "env", variable: "BAR" }); + +Deno.permissions.requestSync({ name: "sys", kind: "loadavg" }); +Deno.permissions.requestSync({ name: "sys", kind: "hostname" }); + +Deno.permissions.requestSync({ name: "ffi", path: "FOO" }); +Deno.permissions.requestSync({ name: "ffi", path: "BAR" }); diff --git a/cli/tests/testdata/run/permissions_prompt_allow_all_2.ts b/cli/tests/testdata/run/permissions_prompt_allow_all_2.ts new file mode 100644 index 000000000..f42b35753 --- /dev/null +++ b/cli/tests/testdata/run/permissions_prompt_allow_all_2.ts @@ -0,0 +1,8 @@ +Deno.env.get("FOO"); +Deno.env.get("BAR"); + +Deno.loadavg(); +Deno.hostname(); + +Deno.cwd(); +Deno.lstatSync(new URL("../", import.meta.url)); |