use super::*;
use codex_protocol::approvals::NetworkPolicyAmendment;
use pretty_assertions::assert_eq;
#[test]
fn approval_resolution_rejects_denied_network_policy_amendment() {
let resolution = ApprovalResolution {
decision: ReviewDecision::NetworkPolicyAmendment {
network_policy_amendment: NetworkPolicyAmendment {
host: "denied.example.com".to_string(),
action: NetworkPolicyRuleAction::Deny,
},
},
source: ApprovalResolutionSource::User,
};
assert!(matches!(
resolution.into_tool_result(),
Err(ToolError::Rejected(rejection)) if rejection == "rejected by user"
));
}
#[test]
fn guardian_cwd_preserves_drive_shaped_local_posix_path() {
let native_cwd = AbsolutePathBuf::try_from(std::path::PathBuf::from("/C:/workspace"))
.expect("drive-shaped POSIX path should be absolute");
let cwd = PathUri::from_abs_path(&native_cwd);
assert_eq!(
guardian_cwd(codex_exec_server::LOCAL_ENVIRONMENT_ID, cwd)
.expect("local cwd should retain the host path convention"),
native_cwd
);
}
#[test]
fn guardian_cwd_rejects_foreign_remote_path() {
let cwd = PathUri::parse("file:///C:/workspace").expect("valid Windows path URI");
assert!(guardian_cwd(codex_exec_server::REMOTE_ENVIRONMENT_ID, cwd).is_err());
}