use solid_pod_rs::error::PodError;
use solid_pod_rs::wac::{parse_turtle_acl_with_limit, MAX_ACL_BYTES};
use solid_pod_rs::{DotfileAllowlist, is_path_allowed};
use solid_pod_rs::security::dotfile::DEFAULT_ALLOWED;
#[test]
fn pod_error_payload_too_large_variant_exists() {
let err = PodError::PayloadTooLarge("test".into());
let msg = err.to_string();
assert!(
msg.contains("payload too large"),
"PayloadTooLarge Display should contain 'payload too large', got: {msg}"
);
}
#[test]
fn parse_turtle_acl_with_limit_exists_and_rejects_oversized() {
let big = "x".repeat(200);
let result = parse_turtle_acl_with_limit(&big, 100);
assert!(result.is_err(), "oversized input must be rejected");
let err = result.unwrap_err();
match &err {
PodError::PayloadTooLarge(msg) => {
assert!(
msg.contains("100"),
"error message should mention the limit: {msg}"
);
}
other => panic!("expected PayloadTooLarge, got: {other:?}"),
}
}
#[test]
fn dotfile_allowlist_with_defaults_includes_account() {
let al = DotfileAllowlist::with_defaults();
let entries = al.entries();
assert!(
entries.iter().any(|e| e == ".account"),
"with_defaults() must include .account, got: {entries:?}"
);
}
#[test]
fn default_allowed_constant_includes_account() {
assert!(
DEFAULT_ALLOWED.contains(&".account"),
"DEFAULT_ALLOWED must include .account"
);
}
#[test]
fn max_acl_bytes_is_one_mib() {
assert_eq!(MAX_ACL_BYTES, 1_048_576, "MAX_ACL_BYTES must be 1 MiB");
}
#[test]
fn is_path_allowed_function_exists() {
assert!(is_path_allowed("/foo/bar.ttl").is_ok());
assert!(is_path_allowed("/.env").is_err());
}