diff options
author | Dmitry Sharshakov <sh7dm@outlook.com> | 2019-02-08 23:59:38 +0300 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-02-08 15:59:38 -0500 |
commit | 9ab03389f047e5520c184b9fce4cd5fb2e4804bd (patch) | |
tree | c1b3295aa6788595e4b73d28aeba0b8fdc8f3205 /js/read_link_test.ts | |
parent | 3abaf9edb6877c328402b94fa0bcb6a9e0bbe86d (diff) |
Add --allow-read (#1689)
Co-authored-by: Greg Altman <g.s.altman@gmail.com>
Diffstat (limited to 'js/read_link_test.ts')
-rw-r--r-- | js/read_link_test.ts | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/js/read_link_test.ts b/js/read_link_test.ts index d4a2666b7..760ed1ea6 100644 --- a/js/read_link_test.ts +++ b/js/read_link_test.ts @@ -1,8 +1,8 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -import { test, testPerm, assert, assertEqual } from "./test_util.ts"; +import { testPerm, assert, assertEqual } from "./test_util.ts"; import * as deno from "deno"; -testPerm({ write: true }, function readlinkSyncSuccess() { +testPerm({ write: true, read: true }, function readlinkSyncSuccess() { const testDir = deno.makeTempDirSync(); const target = testDir + "/target"; const symlink = testDir + "/symln"; @@ -16,7 +16,19 @@ testPerm({ write: true }, function readlinkSyncSuccess() { } }); -test(function readlinkSyncNotFound() { +testPerm({ read: false }, async function readlinkSyncPerm() { + let caughtError = false; + try { + deno.readlinkSync("/symlink"); + } catch (e) { + caughtError = true; + assertEqual(e.kind, deno.ErrorKind.PermissionDenied); + assertEqual(e.name, "PermissionDenied"); + } + assert(caughtError); +}); + +testPerm({ read: true }, function readlinkSyncNotFound() { let caughtError = false; let data; try { @@ -29,7 +41,7 @@ test(function readlinkSyncNotFound() { assertEqual(data, undefined); }); -testPerm({ write: true }, async function readlinkSuccess() { +testPerm({ write: true, read: true }, async function readlinkSuccess() { const testDir = deno.makeTempDirSync(); const target = testDir + "/target"; const symlink = testDir + "/symln"; @@ -42,3 +54,15 @@ testPerm({ write: true }, async function readlinkSuccess() { assertEqual(targetPath, target); } }); + +testPerm({ read: false }, async function readlinkPerm() { + let caughtError = false; + try { + await deno.readlink("/symlink"); + } catch (e) { + caughtError = true; + assertEqual(e.kind, deno.ErrorKind.PermissionDenied); + assertEqual(e.name, "PermissionDenied"); + } + assert(caughtError); +}); |