Harden archive and authenticated request regression tests
This commit is contained in:
parent
3499e57cfa
commit
296abe38ea
|
|
@ -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)),
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
Loading…
Reference in New Issue