mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 20:38:55 +00:00
fix(unstable/worker): ensure import permissions are passed (#26101)
We only had integration tests for this and not an integration test. Closes #26074
This commit is contained in:
parent
06aadcd22b
commit
66929de3ba
@ -269,7 +269,13 @@ function serializePermissions(permissions) {
|
||||
if (typeof permissions == "object" && permissions != null) {
|
||||
const serializedPermissions = { __proto__: null };
|
||||
for (
|
||||
const key of new SafeArrayIterator(["read", "write", "run", "ffi"])
|
||||
const key of new SafeArrayIterator([
|
||||
"read",
|
||||
"write",
|
||||
"run",
|
||||
"ffi",
|
||||
"import",
|
||||
])
|
||||
) {
|
||||
if (ArrayIsArray(permissions[key])) {
|
||||
serializedPermissions[key] = ArrayPrototypeMap(
|
||||
|
13
tests/specs/permission/allow_import_worker/__test__.jsonc
Normal file
13
tests/specs/permission/allow_import_worker/__test__.jsonc
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"tests": {
|
||||
"allowed": {
|
||||
"args": "run -A --unstable-worker-options --quiet main.ts",
|
||||
"output": "1\n"
|
||||
},
|
||||
"denied": {
|
||||
"args": "run -A --unstable-worker-options --quiet main_denied.ts",
|
||||
"output": "denied.out",
|
||||
"exitCode": 1
|
||||
}
|
||||
}
|
||||
}
|
7
tests/specs/permission/allow_import_worker/denied.out
Normal file
7
tests/specs/permission/allow_import_worker/denied.out
Normal file
@ -0,0 +1,7 @@
|
||||
error: Uncaught (in worker "") (in promise) TypeError: JSR package manifest for '@std/assert' failed to load. Requires import access to "127.0.0.1:4250", run again with the --allow-import flag
|
||||
await import(specifier);
|
||||
^
|
||||
at async file:///[WILDLINE]
|
||||
error: Uncaught (in promise) Error: Unhandled error in child worker.
|
||||
at [WILDLINE]
|
||||
at [WILDLINE]
|
8
tests/specs/permission/allow_import_worker/main.ts
Normal file
8
tests/specs/permission/allow_import_worker/main.ts
Normal file
@ -0,0 +1,8 @@
|
||||
new Worker(import.meta.resolve("./worker.ts"), {
|
||||
type: "module",
|
||||
deno: {
|
||||
permissions: {
|
||||
import: ["127.0.0.1:4250"],
|
||||
},
|
||||
},
|
||||
});
|
@ -0,0 +1,8 @@
|
||||
new Worker(import.meta.resolve("./worker.ts"), {
|
||||
type: "module",
|
||||
deno: {
|
||||
permissions: {
|
||||
import: [],
|
||||
},
|
||||
},
|
||||
});
|
4
tests/specs/permission/allow_import_worker/worker.ts
Normal file
4
tests/specs/permission/allow_import_worker/worker.ts
Normal file
@ -0,0 +1,4 @@
|
||||
const specifier = "jsr:@std/assert/assert";
|
||||
await import(specifier);
|
||||
console.log(1);
|
||||
close();
|
Loading…
Reference in New Issue
Block a user