diff options
author | Simon Menke <simon.menke@gmail.com> | 2019-03-04 17:04:19 +0100 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-03-04 11:04:19 -0500 |
commit | 77d7ad61f39641b79a60a99da2f939cbc1d8fe39 (patch) | |
tree | 3bc46c49b0007fb83c435d6cf417dd0f844d947c /js/permissions_test.ts | |
parent | 048a8a77753881936d7c6b32f4534ee364eb42ad (diff) |
Allow inspection and revocation of permissions (#1875)
Diffstat (limited to 'js/permissions_test.ts')
-rw-r--r-- | js/permissions_test.ts | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/js/permissions_test.ts b/js/permissions_test.ts new file mode 100644 index 000000000..f4245c03b --- /dev/null +++ b/js/permissions_test.ts @@ -0,0 +1,22 @@ +// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. +import { testPerm, assert, assertEqual } from "./test_util.ts"; +import { Permission } from "deno"; + +const knownPermissions: Permission[] = ["run", "read", "write", "net", "env"]; + +for (let grant of knownPermissions) { + testPerm({ [grant]: true }, function envGranted() { + const perms = Deno.permissions(); + assert(perms !== null); + for (const perm in perms) { + assertEqual(perms[perm], perm === grant); + } + + Deno.revokePermission(grant); + + const revoked = Deno.permissions(); + for (const perm in revoked) { + assertEqual(revoked[perm], false); + } + }); +} |