summaryrefslogtreecommitdiffstats
path: root/vendor/zip/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:24 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:24 +0000
commit023939b627b7dc93b01471f7d41fb8553ddb4ffa (patch)
tree60fc59477c605c72b0a1051409062ddecc43f877 /vendor/zip/tests
parentAdding debian version 1.72.1+dfsg1-1. (diff)
downloadrustc-023939b627b7dc93b01471f7d41fb8553ddb4ffa.tar.xz
rustc-023939b627b7dc93b01471f7d41fb8553ddb4ffa.zip
Merging upstream version 1.73.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/zip/tests')
-rw-r--r--vendor/zip/tests/issue_234.rs2
-rw-r--r--vendor/zip/tests/zip_crypto.rs17
2 files changed, 18 insertions, 1 deletions
diff --git a/vendor/zip/tests/issue_234.rs b/vendor/zip/tests/issue_234.rs
index bd01d1d08..f8c1d2c81 100644
--- a/vendor/zip/tests/issue_234.rs
+++ b/vendor/zip/tests/issue_234.rs
@@ -26,6 +26,6 @@ fn invalid_header() {
let archive = zip::ZipArchive::new(reader);
match archive {
Err(ZipError::InvalidArchive(_)) => {}
- value => panic!("Unexpected value: {:?}", value),
+ value => panic!("Unexpected value: {value:?}"),
}
}
diff --git a/vendor/zip/tests/zip_crypto.rs b/vendor/zip/tests/zip_crypto.rs
index 6c4d6b811..d831c1e62 100644
--- a/vendor/zip/tests/zip_crypto.rs
+++ b/vendor/zip/tests/zip_crypto.rs
@@ -21,6 +21,23 @@ use std::io::Cursor;
use std::io::Read;
#[test]
+fn encrypting_file() {
+ use zip::unstable::write::FileOptionsExt;
+ use std::io::{Read, Write};
+ let mut buf = vec![0; 2048];
+ let mut archive = zip::write::ZipWriter::new(std::io::Cursor::new(&mut buf));
+ archive.start_file("name", zip::write::FileOptions::default().with_deprecated_encryption(b"password")).unwrap();
+ archive.write_all(b"test").unwrap();
+ archive.finish().unwrap();
+ drop(archive);
+ let mut archive = zip::ZipArchive::new(std::io::Cursor::new(&mut buf)).unwrap();
+ let mut file = archive.by_index_decrypt(0, b"password").unwrap().unwrap();
+ let mut buf = Vec::new();
+ file.read_to_end(&mut buf).unwrap();
+ assert_eq!(buf, b"test");
+
+}
+#[test]
fn encrypted_file() {
let zip_file_bytes = &mut Cursor::new(vec![
0x50, 0x4b, 0x03, 0x04, 0x14, 0x00, 0x01, 0x00, 0x00, 0x00, 0x54, 0xbd, 0xb5, 0x50, 0x2f,