summaryrefslogtreecommitdiff
path: root/cli/tests/unit/process_test.ts
diff options
context:
space:
mode:
authorLeo K <crowlkats@toaxl.com>2021-09-13 19:26:23 +0200
committerGitHub <noreply@github.com>2021-09-13 19:26:23 +0200
commita655a0f3e4201840eda94938fc8d6222c2b94a99 (patch)
tree9b065e3e2e4fcfd7f59ef004e2cd2bc2b6c785de /cli/tests/unit/process_test.ts
parent274ff6c469656bfe527fa644c24dfecc79e90ce4 (diff)
feat(unstable): allow specifing gid and uid for subprocess (#11586)
Diffstat (limited to 'cli/tests/unit/process_test.ts')
-rw-r--r--cli/tests/unit/process_test.ts56
1 files changed, 56 insertions, 0 deletions
diff --git a/cli/tests/unit/process_test.ts b/cli/tests/unit/process_test.ts
index 371521e33..9f8e9cd9f 100644
--- a/cli/tests/unit/process_test.ts
+++ b/cli/tests/unit/process_test.ts
@@ -537,3 +537,59 @@ unitTest(
p.close();
},
);
+
+unitTest(
+ { perms: { run: true, read: true }, ignore: Deno.build.os === "windows" },
+ async function uid(): Promise<void> {
+ const p = Deno.run({
+ cmd: [
+ "id",
+ "-u",
+ ],
+ stdout: "piped",
+ });
+
+ const currentUid = new TextDecoder().decode(await p.output());
+ p.close();
+
+ if (currentUid !== "0") {
+ assertThrows(() => {
+ Deno.run({
+ cmd: [
+ "echo",
+ "fhqwhgads",
+ ],
+ uid: 0,
+ });
+ }, Deno.errors.PermissionDenied);
+ }
+ },
+);
+
+unitTest(
+ { perms: { run: true, read: true }, ignore: Deno.build.os === "windows" },
+ async function gid(): Promise<void> {
+ const p = Deno.run({
+ cmd: [
+ "id",
+ "-g",
+ ],
+ stdout: "piped",
+ });
+
+ const currentGid = new TextDecoder().decode(await p.output());
+ p.close();
+
+ if (currentGid !== "0") {
+ assertThrows(() => {
+ Deno.run({
+ cmd: [
+ "echo",
+ "fhqwhgads",
+ ],
+ gid: 0,
+ });
+ }, Deno.errors.PermissionDenied);
+ }
+ },
+);