c2pa-rs

A fork of https://github.com/contentauth/c2pa-rs/
git clone git://archive.git.mtrnord.blog/mtrnords-photography-manager/c2pa-rs.git
Log | Files | Refs | README

commit d402e9a855d6e5366000eea2f841119258c2c5ad
parent 436b29e1c3d6341cd2f38d815998b910ae9c6890
Author: Gavin  Peacock <gpeacock@adobe.com>
Date:   Thu,  6 Oct 2022 13:03:10 -0700

Add test_embed_with_ingredient_err (#134)


Diffstat:
Msdk/src/manifest.rs | 33++++++++++++++++++++++++++++++++-
Msdk/tests/fixtures/XCA.jpg | 0
2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/sdk/src/manifest.rs b/sdk/src/manifest.rs @@ -813,7 +813,7 @@ pub(crate) mod tests { utils::test::{ fixture_path, temp_dir_path, temp_fixture_path, temp_signer, TEST_SMALL_JPEG, }, - Ingredient, + validation_status, Ingredient, }; // example of random data structure as an assertion @@ -1163,6 +1163,37 @@ pub(crate) mod tests { ); } + #[cfg(feature = "file_io")] + #[actix::test] + /// Verify that an ingredient with error is reported on the ingredient and not on the manifest_store + async fn test_embed_with_ingredient_error() { + let temp_dir = tempdir().expect("temp dir"); + let output = temp_fixture_path(&temp_dir, TEST_SMALL_JPEG); + + let signer = temp_signer(); + + let mut manifest = test_manifest(); + let ingredient = + Ingredient::from_file(fixture_path("XCA.jpg")).expect("getting ingredient"); + assert!(ingredient.validation_status().is_some()); + assert_eq!( + ingredient.validation_status().unwrap()[0].code(), + validation_status::ASSERTION_DATAHASH_MISMATCH + ); + manifest.add_ingredient(ingredient); + manifest.embed(&output, &output, &signer).expect("embed"); + let manifest_store = crate::ManifestStore::from_file(&output).expect("from_file"); + println!("{}", manifest_store); + let manifest = manifest_store.get_active().unwrap(); + let ingredient_status = manifest.ingredients()[0].validation_status(); + assert_eq!( + ingredient_status.unwrap()[0].code(), + validation_status::ASSERTION_DATAHASH_MISMATCH + ); + assert_eq!(manifest.title().unwrap(), TEST_SMALL_JPEG); + assert!(manifest_store.validation_status().is_none()) + } + #[cfg(all(feature = "file_io", feature = "xmp_write"))] #[test] fn test_embed_sidecar_with_parent_manifest() { diff --git a/sdk/tests/fixtures/XCA.jpg b/sdk/tests/fixtures/XCA.jpg Binary files differ.