use qubit_redact::RedactionPolicy;
use qubit_redact::Redactor;
use qubit_redact::formats::http::UrlPathPolicy;
use super::support::redaction::redact_url;
#[test]
fn test_url_path_policy_default_is_preserve() {
assert_eq!(UrlPathPolicy::default(), UrlPathPolicy::Preserve);
assert_eq!(
RedactionPolicy::default().http().url_path_policy(),
UrlPathPolicy::Preserve,
);
}
#[test]
fn test_url_path_policy_strict_is_redact() {
assert_eq!(
RedactionPolicy::strict().http().url_path_policy(),
UrlPathPolicy::Redact,
);
assert_eq!(
Redactor::strict().policy().http().url_path_policy(),
UrlPathPolicy::Redact,
);
}
#[test]
fn test_url_path_policy_preserve_keeps_complete_path() {
let policy = RedactionPolicy::builder()
.http(|http| {
http.url_path(UrlPathPolicy::Preserve);
})
.expect("HTTP policy configuration should be valid")
.build()
.expect("HTTP redaction policy should be valid");
let redactor = Redactor::new(policy);
assert_eq!(
redact_url(&redactor, "https://example.test/public/path"),
"https://example.test/public/path",
);
assert_eq!(redactor.policy().http().url_path_policy(), UrlPathPolicy::Preserve);
}