2021-08-11 10:20:47 -04:00
|
|
|
import { assertEquals } from "../../../../test_util/std/testing/asserts.ts";
|
2021-04-25 17:38:59 -04:00
|
|
|
|
|
|
|
const permissions: Deno.PermissionName[] = [
|
|
|
|
"read",
|
|
|
|
"write",
|
|
|
|
"net",
|
|
|
|
"env",
|
|
|
|
"run",
|
2021-08-06 17:28:10 -04:00
|
|
|
"ffi",
|
2021-04-25 17:38:59 -04:00
|
|
|
"hrtime",
|
|
|
|
];
|
|
|
|
|
|
|
|
for (const name of permissions) {
|
|
|
|
Deno.test({
|
|
|
|
name: `${name} false`,
|
|
|
|
permissions: {
|
|
|
|
[name]: false,
|
|
|
|
},
|
|
|
|
async fn() {
|
|
|
|
const status = await Deno.permissions.query({ name });
|
|
|
|
assertEquals(status.state, "denied");
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
Deno.test({
|
|
|
|
name: `${name} true`,
|
|
|
|
permissions: {
|
|
|
|
[name]: true,
|
|
|
|
},
|
|
|
|
async fn() {
|
|
|
|
const status = await Deno.permissions.query({ name });
|
|
|
|
assertEquals(status.state, "granted");
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|