diff options
author | Kevin (Kun) "Kassimo" Qian <kevinkassimo@gmail.com> | 2019-05-09 09:20:34 -0700 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-05-09 12:20:34 -0400 |
commit | d9cdc6788b1ed89d7f3b2daf9da7e4a9f664e424 (patch) | |
tree | 8b007590b9bf39c7292355dd5b0f3a41b5d1c0a5 /tools/complex_permissions_test.py | |
parent | 2edee3367dc9003b721cf87ca57e820c7acf7b25 (diff) |
fix: support relative path for whitelisting (#2317)
Using `std::fs::canonicalize` to expand path to full existing path, such that
later attempt to loop-pop and compare path segment would work.
Diffstat (limited to 'tools/complex_permissions_test.py')
-rwxr-xr-x | tools/complex_permissions_test.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tools/complex_permissions_test.py b/tools/complex_permissions_test.py index 98eeac013..8fdc99d8b 100755 --- a/tools/complex_permissions_test.py +++ b/tools/complex_permissions_test.py @@ -92,6 +92,10 @@ class Prompt(object): self.test_outside_test_and_js_dir, test_type) wrap_test(test_name_base + "_inside_tests_and_js_dir", self.test_inside_test_and_js_dir, test_type) + wrap_test(test_name_base + "_relative", self.test_relative, + test_type) + wrap_test(test_name_base + "_no_prefix", self.test_no_prefix, + test_type) wrap_test(test_name_base + "_allow_localhost_4545", self.test_allow_localhost_4545) wrap_test(test_name_base + "_allow_deno_land", @@ -179,6 +183,30 @@ class Prompt(object): assert not PROMPT_PATTERN in stderr assert not PERMISSION_DENIED_PATTERN in stderr + def test_relative(self, test_type): + # Save and restore curdir + saved_curdir = os.getcwd() + os.chdir(root_path) + code, _stdout, stderr = self.run( + ["--no-prompt", "--allow-" + test_type + "=" + "./tests"], + [test_type, "tests/subdir/config.json"], b'') + assert code == 0 + assert not PROMPT_PATTERN in stderr + assert not PERMISSION_DENIED_PATTERN in stderr + os.chdir(saved_curdir) + + def test_no_prefix(self, test_type): + # Save and restore curdir + saved_curdir = os.getcwd() + os.chdir(root_path) + code, _stdout, stderr = self.run( + ["--no-prompt", "--allow-" + test_type + "=" + "tests"], + [test_type, "tests/subdir/config.json"], b'') + assert code == 0 + assert not PROMPT_PATTERN in stderr + assert not PERMISSION_DENIED_PATTERN in stderr + os.chdir(saved_curdir) + def complex_permissions_test(deno_exe): p = Prompt(deno_exe, ["read", "write", "net"]) |