Harden archive and authenticated request regression tests

This commit is contained in:
Dandaedre 2026-09-17 02:05:24 +02:00
parent 3499e57cfa
commit 296abe38ea
Signed by: Dandaedre
GPG Key ID: 440C6592E8A26D99
2 changed files with 22 additions and 0 deletions

View File

@ -266,6 +266,12 @@ mod tests {
assert!(bytes.len() < 64 * 1024);
};
let headers = String::from_utf8_lossy(&bytes[..header_end]).to_string();
assert!(
headers
.lines()
.any(|line| line.eq_ignore_ascii_case("authorization: token test-token")),
"authenticated Gitea request lacked the configured token"
);
let first = headers.lines().next().unwrap().to_owned();
assert!(
first.starts_with(&format!("{} {} ", reply.method, reply.path)),

View File

@ -313,6 +313,22 @@ mod tests {
)
.unwrap();
verify_archive(&artifacts[0].path, &artifacts[0]).unwrap();
let mut tar = Vec::new();
GzDecoder::new(File::open(&artifacts[0].path).unwrap())
.read_to_end(&mut tar)
.unwrap();
tar.extend_from_slice(&[1; 512]);
let extra = temp.path().join("extra.tgz");
let mut gzip = flate2::write::GzEncoder::new(
File::create(&extra).unwrap(),
flate2::Compression::default(),
);
gzip.write_all(&tar).unwrap();
gzip.finish().unwrap();
assert!(verify_archive(&extra, &artifacts[0])
.unwrap_err()
.to_string()
.contains("unexpected members"));
let project = SelectedPackage {
name: "demo".into(),
version: "0.1.0".into(),