Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions nvx-rs/src/host/sandbox/mount/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,7 @@ use std::fs;
use super::*;
use crate::ErrorKind;
use crate::host::python::fs::cwd;

fn policy(denied: &[&str], allowed: &[&str], writable: &[&str]) -> MountPolicy {
let owned = |paths: &[&str]| paths.iter().map(|&path| path.to_owned()).collect();
MountPolicy {
denied: owned(denied),
allowed: owned(allowed),
writable: owned(writable),
}
}
use crate::host::sandbox::tests::{native, policy};

fn parse(value: &str, policy: MountPolicy) -> Result<SandboxMount> {
SandboxMount::parse(value, policy, MountOwner::Vmm, MountKind::Directory)
Expand All @@ -25,10 +17,6 @@ fn message<T: std::fmt::Debug>(result: Result<T>) -> String {
error.to_string()
}

fn native(path: &str) -> String {
PurePath::native(path).as_str().to_owned()
}

#[test]
fn mount_parser_defaults_to_read_only_and_accepts_rw() {
let default = parse("/workspace,host-dir", MountPolicy::default()).unwrap();
Expand Down
7 changes: 5 additions & 2 deletions nvx-rs/src/host/sandbox/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ fn distro() -> SandboxLayer {
SandboxLayer::parse(DISTRO).unwrap()
}

fn policy(denied: &[&str], allowed: &[&str], writable: &[&str]) -> MountPolicy {
/// Returns the access policy of a share that hides `denied`, exposes `allowed` inside them again,
/// and lets the workload modify only `writable`. The share tests use it too.
pub(super) fn policy(denied: &[&str], allowed: &[&str], writable: &[&str]) -> MountPolicy {
let owned = |paths: &[&str]| paths.iter().map(|&path| path.to_owned()).collect();
MountPolicy {
denied: owned(denied),
Expand Down Expand Up @@ -47,7 +49,8 @@ fn message<T: std::fmt::Debug>(result: Result<T>) -> String {
result.unwrap_err().to_string()
}

fn native(path: &str) -> String {
/// Returns `str(pathlib.Path(path))` on this host. The share tests use it too.
pub(super) fn native(path: &str) -> String {
PurePath::native(path).as_str().to_owned()
}

Expand Down
Loading