use super::helpers::TestEnv;
#[test]
fn auths_sign_file_does_not_bind_ambient_git_head() {
let env = TestEnv::new();
env.init_identity();
std::fs::write(env.repo_path.join("seed.txt"), b"seed").unwrap();
env.git_cmd().args(["add", "."]).output().unwrap();
env.git_cmd()
.args(["commit", "-m", "seed"])
.output()
.unwrap();
std::fs::write(env.repo_path.join("artifact.txt"), b"payload").unwrap();
let output = env
.cmd("auths")
.args(["sign", "artifact.txt"])
.output()
.unwrap();
assert!(
output.status.success(),
"auths sign failed: {}",
String::from_utf8_lossy(&output.stderr)
);
let att_path = env.repo_path.join("artifact.txt.auths.json");
let json: serde_json::Value =
serde_json::from_str(&std::fs::read_to_string(&att_path).unwrap()).unwrap();
let commit_sha = json.get("commit_sha");
assert!(
commit_sha.is_none_or(|v| v.is_null()),
"a file attestation must not bind the ambient git HEAD, got commit_sha = {commit_sha:?}"
);
}