diff options
Diffstat (limited to 'cli/tests/integration/run_tests.rs')
-rw-r--r-- | cli/tests/integration/run_tests.rs | 70 |
1 files changed, 50 insertions, 20 deletions
diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs index 9720f2577..e83932011 100644 --- a/cli/tests/integration/run_tests.rs +++ b/cli/tests/integration/run_tests.rs @@ -601,7 +601,7 @@ fn _090_run_permissions_request() { .with_pty(|mut console| { console.expect(concat!( "┌ ⚠️ Deno requests run access to \"ls\".\r\n", - "├ Requested by `Deno.permissions.query()` API.\r\n", + "├ Requested by `Deno.permissions.request()` 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)", )); @@ -609,7 +609,7 @@ fn _090_run_permissions_request() { console.expect("Granted run access to \"ls\"."); console.expect(concat!( "┌ ⚠️ Deno requests run access to \"cat\".\r\n", - "├ Requested by `Deno.permissions.query()` API.\r\n", + "├ Requested by `Deno.permissions.request()` 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)", )); @@ -628,7 +628,7 @@ fn _090_run_permissions_request_sync() { .with_pty(|mut console| { console.expect(concat!( "┌ ⚠️ Deno requests run access to \"ls\".\r\n", - "├ Requested by `Deno.permissions.query()` API.\r\n", + "├ Requested by `Deno.permissions.request()` 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)", )); @@ -636,7 +636,7 @@ fn _090_run_permissions_request_sync() { console.expect("Granted run access to \"ls\"."); console.expect(concat!( "┌ ⚠️ Deno requests run access to \"cat\".\r\n", - "├ Requested by `Deno.permissions.query()` API.\r\n", + "├ Requested by `Deno.permissions.request()` 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)", )); @@ -656,7 +656,7 @@ fn permissions_prompt_allow_all() { // "run" permissions console.expect(concat!( "┌ ⚠️ Deno requests run access to \"FOO\".\r\n", - "├ Requested by `Deno.permissions.query()` API.\r\n", + "├ Requested by `Deno.permissions.request()` 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)", )); @@ -665,7 +665,7 @@ fn permissions_prompt_allow_all() { // "read" permissions console.expect(concat!( "┌ ⚠️ Deno requests read access to \"FOO\".\r\n", - "├ Requested by `Deno.permissions.query()` API.\r\n", + "├ Requested by `Deno.permissions.request()` 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)", )); @@ -674,7 +674,7 @@ fn permissions_prompt_allow_all() { // "write" permissions console.expect(concat!( "┌ ⚠️ Deno requests write access to \"FOO\".\r\n", - "├ Requested by `Deno.permissions.query()` API.\r\n", + "├ Requested by `Deno.permissions.request()` 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)", )); @@ -682,8 +682,8 @@ fn permissions_prompt_allow_all() { console.expect("✅ Granted all write access."); // "net" permissions console.expect(concat!( - "┌ ⚠️ Deno requests network access to \"foo\".\r\n", - "├ Requested by `Deno.permissions.query()` API.\r\n", + "┌ ⚠️ Deno requests net access to \"foo\".\r\n", + "├ Requested by `Deno.permissions.request()` 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)", )); @@ -692,7 +692,7 @@ fn permissions_prompt_allow_all() { // "env" permissions console.expect(concat!( "┌ ⚠️ Deno requests env access to \"FOO\".\r\n", - "├ Requested by `Deno.permissions.query()` API.\r\n", + "├ Requested by `Deno.permissions.request()` 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)", )); @@ -701,7 +701,7 @@ fn permissions_prompt_allow_all() { // "sys" permissions console.expect(concat!( "┌ ⚠️ Deno requests sys access to \"loadavg\".\r\n", - "├ Requested by `Deno.permissions.query()` API.\r\n", + "├ Requested by `Deno.permissions.request()` 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)", )); @@ -710,7 +710,7 @@ fn permissions_prompt_allow_all() { // "ffi" permissions console.expect(concat!( "┌ ⚠️ Deno requests ffi access to \"FOO\".\r\n", - "├ Requested by `Deno.permissions.query()` API.\r\n", + "├ Requested by `Deno.permissions.request()` 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)", )); @@ -766,7 +766,7 @@ fn permissions_prompt_allow_all_lowercase_a() { // "run" permissions console.expect(concat!( "┌ ⚠️ Deno requests run access to \"FOO\".\r\n", - "├ Requested by `Deno.permissions.query()` API.\r\n", + "├ Requested by `Deno.permissions.request()` 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)", )); @@ -775,6 +775,36 @@ fn permissions_prompt_allow_all_lowercase_a() { }); } +itest!(deny_all_permission_args { + args: "run --deny-env --deny-read --deny-write --deny-ffi --deny-run --deny-sys --deny-net --deny-hrtime run/deny_all_permission_args.js", + output: "run/deny_all_permission_args.out", +}); + +itest!(deny_some_permission_args { + args: "run --allow-env --deny-env=FOO --allow-read --deny-read=/foo --allow-write --deny-write=/foo --allow-ffi --deny-ffi=/foo --allow-run --deny-run=foo --allow-sys --deny-sys=hostname --allow-net --deny-net=127.0.0.1 --allow-hrtime --deny-hrtime run/deny_some_permission_args.js", + output: "run/deny_some_permission_args.out", +}); + +#[test] +fn permissions_cache() { + TestContext::default() + .new_command() + .args_vec(["run", "--quiet", "run/permissions_cache.ts"]) + .with_pty(|mut console| { + console.expect(concat!( + "prompt\r\n", + "┌ ⚠️ Deno requests read access to \"foo\".\r\n", + "├ Requested by `Deno.permissions.request()` 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)", + )); + console.write_line_raw("y"); + console.expect("✅ Granted read access to \"foo\"."); + console.expect("granted"); + console.expect("prompt"); + }); +} + 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", @@ -2541,14 +2571,14 @@ mod permissions { .with_pty(|mut console| { console.expect(concat!( "┌ ⚠️ Deno requests read access to \"foo\".\r\n", - "├ Requested by `Deno.permissions.query()` API.\r\n", + "├ Requested by `Deno.permissions.request()` 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)", )); console.write_line_raw("y"); console.expect(concat!( "┌ ⚠️ Deno requests read access to \"bar\".\r\n", - "├ Requested by `Deno.permissions.query()` API.\r\n", + "├ Requested by `Deno.permissions.request()` 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)", )); @@ -2567,14 +2597,14 @@ mod permissions { .with_pty(|mut console| { console.expect(concat!( "┌ ⚠️ Deno requests read access to \"foo\".\r\n", - "├ Requested by `Deno.permissions.query()` API.\r\n", + "├ Requested by `Deno.permissions.request()` 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)", )); console.write_line_raw("y"); console.expect(concat!( "┌ ⚠️ Deno requests read access to \"bar\".\r\n", - "├ Requested by `Deno.permissions.query()` API.\r\n", + "├ Requested by `Deno.permissions.request()` 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)", )); @@ -2593,7 +2623,7 @@ mod permissions { .with_pty(|mut console| { console.expect(concat!( "┌ ⚠️ Deno requests read access.\r\n", - "├ Requested by `Deno.permissions.query()` API.\r\n", + "├ Requested by `Deno.permissions.request()` 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)", )); @@ -2615,7 +2645,7 @@ mod permissions { .with_pty(|mut console| { console.expect(concat!( "┌ ⚠️ Deno requests read access.\r\n", - "├ Requested by `Deno.permissions.query()` API.\r\n", + "├ Requested by `Deno.permissions.request()` 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)", )); @@ -2756,7 +2786,7 @@ fn issue9750() { console.write_line_raw("yy"); console.expect(concat!( "┌ ⚠️ Deno requests env access.\r\n", - "├ Requested by `Deno.permissions.query()` API.\r\n", + "├ Requested by `Deno.permissions.request()` 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)", )); |