diff --git a/src/gitea.rs b/src/gitea.rs index 2ad75c1..af51723 100644 --- a/src/gitea.rs +++ b/src/gitea.rs @@ -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)), diff --git a/src/verify.rs b/src/verify.rs index 598ec31..7542916 100644 --- a/src/verify.rs +++ b/src/verify.rs @@ -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(),