commit ce6108f7665b79c56a5b260e6c49155e27a99cdb
parent 44f06015c405b889d59a94fa2bd361b1b0e44e96
Author: Gavin Peacock <gpeacock@adobe.com>
Date: Tue, 24 May 2022 12:29:04 -0700
Reduce fixtures size (#15)
* Reduce fixtures size
* More fixture size reduction
Diffstat:
16 files changed, 17 insertions(+), 37 deletions(-)
diff --git a/sdk/src/ingredient.rs b/sdk/src/ingredient.rs
@@ -598,8 +598,7 @@ mod tests {
//use serde_cbor::{ser::IoWrite, Serializer};
const MANIFEST_JPEG: &str = "C.jpg";
- const BAD_SIGNATURE_JPEG: &str = "CAICAI_BAD_SIG.jpg";
- const BAD_JUMBF_JPEG: &str = "bigjumbf.jpg";
+ const BAD_SIGNATURE_JPEG: &str = "E-sig-CA.jpg";
const PRERELEASE_JPEG: &str = "prerelease.jpg";
#[test]
@@ -667,6 +666,7 @@ mod tests {
}
#[test]
+ #[cfg(feature = "file_io")]
fn test_jpg_bad_signature() {
let ap = fixture_path(BAD_SIGNATURE_JPEG);
let ingredient = Ingredient::from_file(&ap).expect("from_file");
@@ -706,28 +706,9 @@ mod tests {
}
#[test]
- fn test_jpg_bad_jumbf() {
- let ap = fixture_path(BAD_JUMBF_JPEG);
- let ingredient = Ingredient::from_file(&ap).expect("from_file");
- ingredient.stats();
-
- println!("ingredient = {}", ingredient);
- assert_eq!(&ingredient.title, BAD_JUMBF_JPEG);
- assert_eq!(&ingredient.format, "image/jpeg");
- assert!(ingredient.thumbnail.is_some());
- assert!(ingredient.provenance.is_some());
- assert!(ingredient.manifest_data.is_none());
- assert!(ingredient.validation_status.is_some());
- assert_eq!(
- ingredient.validation_status.unwrap()[0].code(),
- validation_status::STATUS_PRERELEASE
- );
- }
-
- #[test]
fn test_jpg_nested() {
let ap = fixture_path("CIE-sig-CA.jpg");
- let ingredient = Ingredient::from_file(&ap).expect("new_from_file");
+ let ingredient = Ingredient::from_file(&ap).expect("from_file");
println!("ingredient = {}", ingredient);
assert_eq!(ingredient.validation_status, None);
}
diff --git a/sdk/src/manifest_store.rs b/sdk/src/manifest_store.rs
@@ -249,7 +249,7 @@ mod tests {
#[test]
fn manifest_report_image() {
- let image_bytes = include_bytes!("../tests/fixtures/CAICAI.jpg");
+ let image_bytes = include_bytes!("../tests/fixtures/CA.jpg");
let manifest_store =
ManifestStore::from_bytes("image/jpeg", image_bytes.to_vec(), true).unwrap();
diff --git a/sdk/src/manifest_store_report.rs b/sdk/src/manifest_store_report.rs
@@ -237,7 +237,7 @@ mod tests {
#[test]
fn manifest_store_report() {
- let path = fixture_path("CAICAI_BAD_SIG.jpg");
+ let path = fixture_path("CIE-sig-CA.jpg");
let report = ManifestStoreReport::from_file(&path).expect("load_from_asset");
println!("{}", report);
}
diff --git a/sdk/src/store.rs b/sdk/src/store.rs
@@ -1923,9 +1923,9 @@ pub mod tests {
assert!(!jumbf_bytes.is_empty());
// test adding to actual image
- let ap = fixture_path("bigjumbf.jpg");
+ let ap = fixture_path("prerelease.jpg");
let temp_dir = tempdir().expect("temp dir");
- let op = temp_dir_path(&temp_dir, "bigjumbf_test.jpg");
+ let op = temp_dir_path(&temp_dir, "replacement_test.jpg");
// grab jumbf from original
let original_jumbf = load_jumbf_from_file(&ap).unwrap();
@@ -2102,7 +2102,7 @@ pub mod tests {
#[test]
fn test_manifest_bad_sig() {
- let ap = fixture_path("CAICAI_BAD_SIG.jpg");
+ let ap = fixture_path("CE-sig-CA.jpg");
assert!(Store::load_from_asset(&ap, true, &mut OneShotStatusTracker::new()).is_err());
}
@@ -2122,7 +2122,7 @@ pub mod tests {
#[test]
fn test_bad_jumbf() {
// test bad jumbf
- let ap = fixture_path("bigjumbf.jpg");
+ let ap = fixture_path("prerelease.jpg");
let mut report = DetailedStatusTracker::new();
let _r = Store::load_from_asset(&ap, true, &mut report);
@@ -2136,7 +2136,7 @@ pub mod tests {
#[test]
fn test_detect_byte_change() {
// test bad jumbf
- let ap = fixture_path("bad_verify.jpeg");
+ let ap = fixture_path("XCA.jpg");
let mut report = DetailedStatusTracker::new();
Store::load_from_asset(&ap, true, &mut report).unwrap();
@@ -2173,7 +2173,7 @@ pub mod tests {
#[test]
fn test_old_manifest() {
- let ap = fixture_path("08manifest.jpg");
+ let ap = fixture_path("prerelease.jpg");
let mut report = DetailedStatusTracker::new();
let _r = Store::load_from_asset(&ap, true, &mut report);
@@ -2311,7 +2311,7 @@ pub mod tests {
#[test]
fn test_claim_decoding() {
// modify a required field label in the claim - causes failure to read claim from cbor
- let report = patch_and_report("CAICAI.jpg", b"claim_generator", b"claim_generatur");
+ let report = patch_and_report("C.jpg", b"claim_generator", b"claim_generatur");
assert!(!report.get_log().is_empty());
assert!(matches!(
report.get_log()[0].err_val,
@@ -2324,7 +2324,7 @@ pub mod tests {
fn test_modify_xmp() {
// modify the XMP (change xmp magic id value) - this should cause a data hash mismatch (OTGP)
let mut report = patch_and_report(
- "CAICAI.jpg",
+ "C.jpg",
b"W5M0MpCehiHzreSzNTczkc9d",
b"W5M0MpCehiHzreSzNTczkXXX",
);
@@ -2341,7 +2341,7 @@ pub mod tests {
#[test]
fn test_claim_modified() {
// replace the title that is inside the claim data - should cause signature to not match
- let mut report = patch_and_report("CAICAI.jpg", b"CAICAI.jpg", b"XXXCAI.jpg");
+ let mut report = patch_and_report("C.jpg", b"C.jpg", b"X.jpg");
assert!(!report.get_log().is_empty());
let errors = report_split_errors(report.get_log_mut());
@@ -2361,8 +2361,7 @@ pub mod tests {
#[test]
fn test_assertion_hash_mismatch() {
// modifies content of an action assertion - causes an assertion hashuri mismatch
- let mut report =
- patch_and_report("CAICAI.jpg", b"brightnesscontrast", b"brightnesscontraxx");
+ let mut report = patch_and_report("CA.jpg", b"brightnesscontrast", b"brightnesscontraxx");
let errors = report_split_errors(report.get_log_mut());
assert_eq!(
@@ -2379,7 +2378,7 @@ pub mod tests {
b"c2pa_manifest\xA3\x63url\x78\x4aself#jumbf=/c2pa/contentauth:urn:uuid:";
const REPLACE_BYTES: &[u8] =
b"c2pa_manifest\xA3\x63url\x78\x4aself#jumbf=/c2pa/contentauth:urn:uuix:";
- let mut report = patch_and_report("CAICAI.jpg", SEARCH_BYTES, REPLACE_BYTES);
+ let mut report = patch_and_report("CIE-sig-CA.jpg", SEARCH_BYTES, REPLACE_BYTES);
let errors = report_split_errors(report.get_log_mut());
assert_eq!(
errors[0].validation_status.as_deref(),
@@ -2410,7 +2409,7 @@ pub mod tests {
#[test]
fn test_display() {
- let ap = fixture_path("CAICAI_BAD_SIG.jpg");
+ let ap = fixture_path("CA.jpg");
let mut report = DetailedStatusTracker::new();
let store = Store::load_from_asset(&ap, true, &mut report).expect("load_from_asset");
println!("store = {}", store);
diff --git a/sdk/tests/fixtures/08manifest.jpg b/sdk/tests/fixtures/08manifest.jpg
Binary files differ.
diff --git a/sdk/tests/fixtures/CA.jpg b/sdk/tests/fixtures/CA.jpg
Binary files differ.
diff --git a/sdk/tests/fixtures/CAICAI.jpg b/sdk/tests/fixtures/CAICAI.jpg
Binary files differ.
diff --git a/sdk/tests/fixtures/CAICAI_BAD_SIG.jpg b/sdk/tests/fixtures/CAICAI_BAD_SIG.jpg
Binary files differ.
diff --git a/sdk/tests/fixtures/CAICAI_NO_XMP.jpg b/sdk/tests/fixtures/CAICAI_NO_XMP.jpg
Binary files differ.
diff --git a/sdk/tests/fixtures/CIE-sig-CA.jpg b/sdk/tests/fixtures/CIE-sig-CA.jpg
Binary files differ.
diff --git a/sdk/tests/fixtures/E-sig-CA.jpg b/sdk/tests/fixtures/E-sig-CA.jpg
Binary files differ.
diff --git a/sdk/tests/fixtures/IMG_0003.jpg b/sdk/tests/fixtures/IMG_0003.jpg
Binary files differ.
diff --git a/sdk/tests/fixtures/P1000827.jpg b/sdk/tests/fixtures/P1000827.jpg
Binary files differ.
diff --git a/sdk/tests/fixtures/XCA.jpg b/sdk/tests/fixtures/XCA.jpg
Binary files differ.
diff --git a/sdk/tests/fixtures/bad_verify.jpeg b/sdk/tests/fixtures/bad_verify.jpeg
Binary files differ.
diff --git a/sdk/tests/fixtures/bigjumbf.jpg b/sdk/tests/fixtures/bigjumbf.jpg
Binary files differ.