mirror of
https://github.com/denoland/deno.git
synced 2025-03-04 01:44:26 -05:00
fix(runtime): negate partial condition for deny flags (#22866)
This commit is contained in:
parent
5b3658f448
commit
8e6044ecc3
1 changed files with 26 additions and 1 deletions
|
@ -312,7 +312,7 @@ impl<T: Descriptor + Hash> UnaryPermission<T> {
|
||||||
get_display_name: impl Fn() -> Option<String>,
|
get_display_name: impl Fn() -> Option<String>,
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
let (result, prompted, is_allow_all) = self
|
let (result, prompted, is_allow_all) = self
|
||||||
.query_desc(desc, AllowPartial::from(assert_non_partial))
|
.query_desc(desc, AllowPartial::from(!assert_non_partial))
|
||||||
.check2(
|
.check2(
|
||||||
T::flag_name(),
|
T::flag_name(),
|
||||||
api_name,
|
api_name,
|
||||||
|
@ -2858,6 +2858,31 @@ mod tests {
|
||||||
assert_eq!(perms.env.revoke(Some("HomE")), PermissionState::Prompt);
|
assert_eq!(perms.env.revoke(Some("HomE")), PermissionState::Prompt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_check_partial_denied() {
|
||||||
|
let mut perms = Permissions {
|
||||||
|
read: Permissions::new_read(
|
||||||
|
&Some(vec![]),
|
||||||
|
&Some(vec![PathBuf::from("/foo/bar")]),
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
.unwrap(),
|
||||||
|
write: Permissions::new_write(
|
||||||
|
&Some(vec![]),
|
||||||
|
&Some(vec![PathBuf::from("/foo/bar")]),
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
.unwrap(),
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
perms.read.check_partial(Path::new("/foo"), None).unwrap();
|
||||||
|
assert!(perms.read.check(Path::new("/foo"), None).is_err());
|
||||||
|
|
||||||
|
perms.write.check_partial(Path::new("/foo"), None).unwrap();
|
||||||
|
assert!(perms.write.check(Path::new("/foo"), None).is_err());
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_deserialize_child_permissions_arg() {
|
fn test_deserialize_child_permissions_arg() {
|
||||||
set_prompter(Box::new(TestPrompter));
|
set_prompter(Box::new(TestPrompter));
|
||||||
|
|
Loading…
Add table
Reference in a new issue