2019-03-04 11:04:19 -05:00
|
|
|
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
2019-03-06 20:48:46 -05:00
|
|
|
import { testPerm, assert, assertEquals } from "./test_util.ts";
|
2019-03-04 11:04:19 -05:00
|
|
|
|
2019-03-07 21:56:56 -05:00
|
|
|
const knownPermissions: Deno.Permission[] = [
|
|
|
|
"run",
|
|
|
|
"read",
|
|
|
|
"write",
|
|
|
|
"net",
|
2019-04-08 16:22:40 -04:00
|
|
|
"env",
|
2019-05-23 12:28:29 -04:00
|
|
|
"hrtime"
|
2019-03-07 21:56:56 -05:00
|
|
|
];
|
2019-03-04 11:04:19 -05:00
|
|
|
|
|
|
|
for (let grant of knownPermissions) {
|
2019-04-21 16:40:10 -04:00
|
|
|
testPerm({ [grant]: true }, function envGranted(): void {
|
2019-03-04 11:04:19 -05:00
|
|
|
const perms = Deno.permissions();
|
|
|
|
assert(perms !== null);
|
|
|
|
for (const perm in perms) {
|
2019-03-06 20:48:46 -05:00
|
|
|
assertEquals(perms[perm], perm === grant);
|
2019-03-04 11:04:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
Deno.revokePermission(grant);
|
|
|
|
|
|
|
|
const revoked = Deno.permissions();
|
|
|
|
for (const perm in revoked) {
|
2019-03-06 20:48:46 -05:00
|
|
|
assertEquals(revoked[perm], false);
|
2019-03-04 11:04:19 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|