use gunnar_crypt::policy::{check_blob, Refusal};
#[test]
fn a_gitattributes_at_any_depth_is_plaintext_and_nothing_else_is() {
let text = b"*.bin -diff\n";
for path in [
".gitattributes",
"docs/.gitattributes",
"a/b/c/.gitattributes",
] {
assert_eq!(check_blob(path, false, text), Ok(()), "{path}");
}
for path in [
"docs/.gitattributes.bak",
"docs/x.gitattributes",
"docs/notes.txt",
] {
assert!(
matches!(
check_blob(path, false, text),
Err(Refusal::Plaintext { .. })
),
"{path} is no attributes file"
);
}
assert!(
matches!(
check_blob("docs/.gitattributes", true, text),
Err(Refusal::Symlink { .. })
),
"a symlink never"
);
assert!(
gunnar_crypt::GITATTRIBUTES_LINES
.iter()
.any(|l| l.starts_with(".gitattributes ")),
"the client keeps the depth-free line the server now matches"
);
}