mirror of
https://github.com/denoland/deno.git
synced 2025-08-02 18:12:39 +00:00
Check allow-net in fetch
This commit is contained in:
parent
1e709aa348
commit
1052f8d0c9
3 changed files with 25 additions and 6 deletions
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
|
||||
import { testPerm, assertEqual } from "./test_util.ts";
|
||||
import { test, testPerm, assert, assertEqual } from "./test_util.ts";
|
||||
import * as deno from "deno";
|
||||
|
||||
testPerm({ net: true }, async function fetchJsonSuccess() {
|
||||
|
@ -7,3 +7,15 @@ testPerm({ net: true }, async function fetchJsonSuccess() {
|
|||
const json = await response.json();
|
||||
assertEqual(json.name, "deno");
|
||||
});
|
||||
|
||||
test(async function fetchPerm() {
|
||||
let err;
|
||||
try {
|
||||
await fetch("http://localhost:4545/package.json");
|
||||
} catch (err_) {
|
||||
err = err_;
|
||||
}
|
||||
// TODO assert(err instanceof deno.PermissionDenied).
|
||||
assert(err);
|
||||
assertEqual(err.name, "deno.PermissionDenied");
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue