diff options
author | dubiousjim <dubiousjim@gmail.com> | 2020-03-11 15:05:42 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-11 15:05:42 -0400 |
commit | 72c408ea9d8b4e4fab63ae06f558c778007bb4f1 (patch) | |
tree | 0e2d353eee60a371dd242488239bbb9309cbc92a /cli/js | |
parent | 2d1b39bef339edb19ae6be5fb2099e685cee93bb (diff) |
Stricter permissions for Deno.makeTemp* (#4318)
Diffstat (limited to 'cli/js')
-rw-r--r-- | cli/js/tests/make_temp_test.ts | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/cli/js/tests/make_temp_test.ts b/cli/js/tests/make_temp_test.ts index 9804a7043..70ba01084 100644 --- a/cli/js/tests/make_temp_test.ts +++ b/cli/js/tests/make_temp_test.ts @@ -26,6 +26,17 @@ unitTest({ perms: { write: true } }, function makeTempDirSyncSuccess(): void { assert(err instanceof Deno.errors.NotFound); }); +unitTest( + { perms: { read: true, write: true } }, + function makeTempDirSyncMode(): void { + const path = Deno.makeTempDirSync(); + const pathInfo = Deno.statSync(path); + if (Deno.build.os !== "win") { + assertEquals(pathInfo.mode! & 0o777, 0o700 & ~Deno.umask()); + } + } +); + unitTest(function makeTempDirSyncPerm(): void { // makeTempDirSync should require write permissions (for now). let err; @@ -66,6 +77,17 @@ unitTest( } ); +unitTest( + { perms: { read: true, write: true } }, + async function makeTempDirMode(): Promise<void> { + const path = await Deno.makeTempDir(); + const pathInfo = Deno.statSync(path); + if (Deno.build.os !== "win") { + assertEquals(pathInfo.mode! & 0o777, 0o700 & ~Deno.umask()); + } + } +); + unitTest({ perms: { write: true } }, function makeTempFileSyncSuccess(): void { const file1 = Deno.makeTempFileSync({ prefix: "hello", suffix: "world" }); const file2 = Deno.makeTempFileSync({ prefix: "hello", suffix: "world" }); @@ -92,6 +114,17 @@ unitTest({ perms: { write: true } }, function makeTempFileSyncSuccess(): void { assert(err instanceof Deno.errors.NotFound); }); +unitTest( + { perms: { read: true, write: true } }, + function makeTempFileSyncMode(): void { + const path = Deno.makeTempFileSync(); + const pathInfo = Deno.statSync(path); + if (Deno.build.os !== "win") { + assertEquals(pathInfo.mode! & 0o777, 0o600 & ~Deno.umask()); + } + } +); + unitTest(function makeTempFileSyncPerm(): void { // makeTempFileSync should require write permissions (for now). let err; @@ -132,3 +165,14 @@ unitTest( assert(err instanceof Deno.errors.NotFound); } ); + +unitTest( + { perms: { read: true, write: true } }, + async function makeTempFileMode(): Promise<void> { + const path = await Deno.makeTempFile(); + const pathInfo = Deno.statSync(path); + if (Deno.build.os !== "win") { + assertEquals(pathInfo.mode! & 0o777, 0o600 & ~Deno.umask()); + } + } +); |