mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
refactor(runtime): remove unneeded Deserialize trait for Permissions struct (#9362)
This commit is contained in:
parent
6abf126c2a
commit
9690ce5e87
1 changed files with 1 additions and 50 deletions
|
@ -68,7 +68,7 @@ pub struct UnaryPermission<T: Eq + Hash> {
|
||||||
pub denied_list: HashSet<T>,
|
pub denied_list: HashSet<T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
|
#[derive(Clone, Debug, Default, PartialEq)]
|
||||||
pub struct Permissions {
|
pub struct Permissions {
|
||||||
pub read: UnaryPermission<PathBuf>,
|
pub read: UnaryPermission<PathBuf>,
|
||||||
pub write: UnaryPermission<PathBuf>,
|
pub write: UnaryPermission<PathBuf>,
|
||||||
|
@ -749,7 +749,6 @@ fn format_host<T: AsRef<str>>(host: &(T, Option<u16>)) -> String {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use deno_core::serde_json;
|
|
||||||
|
|
||||||
// Creates vector of strings, Vec<String>
|
// Creates vector of strings, Vec<String>
|
||||||
macro_rules! svec {
|
macro_rules! svec {
|
||||||
|
@ -1064,54 +1063,6 @@ mod tests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_deserialize_perms() {
|
|
||||||
let json_perms = r#"
|
|
||||||
{
|
|
||||||
"read": {
|
|
||||||
"global_state": "Granted",
|
|
||||||
"granted_list": [],
|
|
||||||
"denied_list": []
|
|
||||||
},
|
|
||||||
"write": {
|
|
||||||
"global_state": "Granted",
|
|
||||||
"granted_list": [],
|
|
||||||
"denied_list": []
|
|
||||||
},
|
|
||||||
"net": {
|
|
||||||
"global_state": "Granted",
|
|
||||||
"granted_list": [],
|
|
||||||
"denied_list": []
|
|
||||||
},
|
|
||||||
"env": "Granted",
|
|
||||||
"run": "Granted",
|
|
||||||
"plugin": "Granted",
|
|
||||||
"hrtime": "Granted"
|
|
||||||
}
|
|
||||||
"#;
|
|
||||||
let perms0 = Permissions {
|
|
||||||
read: UnaryPermission {
|
|
||||||
global_state: PermissionState::Granted,
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
write: UnaryPermission {
|
|
||||||
global_state: PermissionState::Granted,
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
net: UnaryPermission {
|
|
||||||
global_state: PermissionState::Granted,
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
env: PermissionState::Granted,
|
|
||||||
run: PermissionState::Granted,
|
|
||||||
hrtime: PermissionState::Granted,
|
|
||||||
plugin: PermissionState::Granted,
|
|
||||||
};
|
|
||||||
let deserialized_perms: Permissions =
|
|
||||||
serde_json::from_str(json_perms).unwrap();
|
|
||||||
assert_eq!(perms0, deserialized_perms);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_query() {
|
fn test_query() {
|
||||||
let perms1 = Permissions {
|
let perms1 = Permissions {
|
||||||
|
|
Loading…
Reference in a new issue