Skip to content

Commit f9f9e71

Browse files
committed
add partial denied
1 parent f6ddea8 commit f9f9e71

File tree

9 files changed

+45
-7
lines changed

9 files changed

+45
-7
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"envs": {
3+
"VAR1": "1",
4+
"VAR2": "2"
5+
},
6+
"args": "run --quiet -P main.ts",
7+
"output": "undefined\nundefined\n[Object: null prototype] {}\n"
8+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"permissions": {
3+
"default": {
4+
"env": {
5+
"ignore": true
6+
}
7+
}
8+
}
9+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
console.log(Deno.env.get("VAR1"));
2+
console.log(Deno.env.get("VAR2"));
3+
const object = Deno.env.toObject();
4+
console.log(object);
5+
if ("VAR1" in object) {
6+
throw "FAILED";
7+
}

tests/specs/run/permission_env_allow_and_deny/__test__.jsonc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"args": "run --allow-env --deny-env=FOOBAR main.ts",
3-
"output": "main.out",
4-
"exitCode": 1,
3+
"output": "",
54
"envs": {
65
"FOOBAR": "FOOBAR"
76
}

tests/specs/run/permission_env_allow_and_deny/main.out

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
console.log(Deno.env.toObject());
1+
const obj = Deno.env.toObject();
2+
if (obj["PATH"] == null) {
3+
throw "FAIL";
4+
}
5+
if ("FOOBAR" in obj) {
6+
throw "FAIL2";
7+
}

tests/unit/os_test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,19 @@ Deno.test({ permissions: { env: true } }, function envSuccess() {
1414
assertNotEquals(Deno.env.get("TEST_VAR"), env["TEST_VAR"]);
1515
});
1616

17+
Deno.test({
18+
permissions: {
19+
env: {
20+
allow: true,
21+
deny: ["PATH"],
22+
},
23+
},
24+
}, function envDenySuccess() {
25+
// should allow getting it and not contain the denied path
26+
const env = Deno.env.toObject();
27+
assertEquals(env["PATH"], undefined);
28+
});
29+
1730
Deno.test({ permissions: { env: true } }, function envNotFound() {
1831
const r = Deno.env.get("env_var_does_not_exist!");
1932
assertEquals(r, undefined);

0 commit comments

Comments
 (0)