diff --git a/cawg_identity/src/tests/builder/simple_case.rs b/cawg_identity/src/tests/builder/simple_case.rs index 98c2df92c..f982adc33 100644 --- a/cawg_identity/src/tests/builder/simple_case.rs +++ b/cawg_identity/src/tests/builder/simple_case.rs @@ -14,7 +14,6 @@ use std::io::{Cursor, Seek}; use c2pa::{Builder, Reader, SigningAlg}; -use serde_json::json; #[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test; @@ -23,7 +22,10 @@ use crate::{ AsyncIdentityAssertionBuilder, AsyncIdentityAssertionSigner, IdentityAssertionBuilder, IdentityAssertionSigner, }, - tests::fixtures::{NaiveAsyncCredentialHolder, NaiveCredentialHolder, NaiveSignatureVerifier}, + tests::fixtures::{ + manifest_json, parent_json, NaiveAsyncCredentialHolder, NaiveCredentialHolder, + NaiveSignatureVerifier, + }, IdentityAssertion, ToCredentialSummary, }; @@ -141,53 +143,3 @@ async fn simple_case_async() { let nc_json = serde_json::to_string(&nc_summary).unwrap(); assert_eq!(nc_json, "{}"); } - -fn manifest_json() -> String { - json!({ - "vendor": "test", - "claim_generator_info": [ - { - "name": "c2pa_test", - "version": "1.0.0" - } - ], - "metadata": [ - { - "dateTime": "1985-04-12T23:20:50.52Z", - "my_custom_metadata": "my custom metatdata value" - } - ], - "title": "Test_Manifest", - "format": "image/tiff", - "instance_id": "1234", - "thumbnail": { - "format": "image/jpeg", - "identifier": "thumbnail.jpg" - }, - "ingredients": [ - { - "title": "Test", - "format": "image/jpeg", - "instance_id": "12345", - "relationship": "componentOf" - } - ], - "assertions": [ - { - "label": "org.test.assertion", - "data": "assertion" - } - ] - }) - .to_string() -} - -fn parent_json() -> String { - json!({ - "title": "Parent Test", - "format": "image/jpeg", - "instance_id": "12345", - "relationship": "parentOf" - }) - .to_string() -} diff --git a/cawg_identity/src/tests/fixtures/manifest_json.rs b/cawg_identity/src/tests/fixtures/manifest_json.rs new file mode 100644 index 000000000..957cd9a99 --- /dev/null +++ b/cawg_identity/src/tests/fixtures/manifest_json.rs @@ -0,0 +1,65 @@ +// Copyright 2025 Adobe. All rights reserved. +// This file is licensed to you under the Apache License, +// Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) +// or the MIT license (http://opensource.org/licenses/MIT), +// at your option. + +// Unless required by applicable law or agreed to in writing, +// this software is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or +// implied. See the LICENSE-MIT and LICENSE-APACHE files for the +// specific language governing permissions and limitations under +// each license. + +use serde_json::json; + +/// Boilerplate JSON to use when building manifests for test cases. +pub(crate) fn manifest_json() -> String { + json!({ + "vendor": "test", + "claim_generator_info": [ + { + "name": "c2pa_test", + "version": "1.0.0" + } + ], + "metadata": [ + { + "dateTime": "1985-04-12T23:20:50.52Z", + "my_custom_metadata": "my custom metatdata value" + } + ], + "title": "Test_Manifest", + "format": "image/tiff", + "instance_id": "1234", + "thumbnail": { + "format": "image/jpeg", + "identifier": "thumbnail.jpg" + }, + "ingredients": [ + { + "title": "Test", + "format": "image/jpeg", + "instance_id": "12345", + "relationship": "componentOf" + } + ], + "assertions": [ + { + "label": "org.test.assertion", + "data": "assertion" + } + ] + }) + .to_string() +} + +pub(crate) fn parent_json() -> String { + json!({ + "title": "Parent Test", + "format": "image/jpeg", + "instance_id": "12345", + "relationship": "parentOf" + }) + .to_string() +} diff --git a/cawg_identity/src/tests/fixtures/mod.rs b/cawg_identity/src/tests/fixtures/mod.rs index 431010546..969ab7fe9 100644 --- a/cawg_identity/src/tests/fixtures/mod.rs +++ b/cawg_identity/src/tests/fixtures/mod.rs @@ -13,6 +13,9 @@ #![allow(unused)] +mod manifest_json; +pub(crate) use manifest_json::{manifest_json, parent_json}; + mod naive_credential_holder; pub(crate) use naive_credential_holder::{ NaiveAsyncCredentialHolder, NaiveCredentialHolder, NaiveSignatureVerifier, diff --git a/cawg_identity/src/tests/x509.rs b/cawg_identity/src/tests/x509.rs index 4ea4076e1..fd1203d68 100644 --- a/cawg_identity/src/tests/x509.rs +++ b/cawg_identity/src/tests/x509.rs @@ -15,13 +15,12 @@ use std::io::{Cursor, Seek}; use c2pa::{Builder, Reader, SigningAlg}; use c2pa_crypto::raw_signature; -use serde_json::json; #[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test; use crate::{ builder::{AsyncIdentityAssertionBuilder, AsyncIdentityAssertionSigner}, - tests::fixtures::cert_chain_and_private_key_for_alg, + tests::fixtures::{cert_chain_and_private_key_for_alg, manifest_json, parent_json}, x509::{X509CredentialHolder, X509SignatureVerifier}, IdentityAssertion, }; @@ -97,53 +96,3 @@ async fn simple_case() { // TO DO: Not sure what to check from COSE_Sign1. } - -fn manifest_json() -> String { - json!({ - "vendor": "test", - "claim_generator_info": [ - { - "name": "c2pa_test", - "version": "1.0.0" - } - ], - "metadata": [ - { - "dateTime": "1985-04-12T23:20:50.52Z", - "my_custom_metadata": "my custom metatdata value" - } - ], - "title": "Test_Manifest", - "format": "image/tiff", - "instance_id": "1234", - "thumbnail": { - "format": "image/jpeg", - "identifier": "thumbnail.jpg" - }, - "ingredients": [ - { - "title": "Test", - "format": "image/jpeg", - "instance_id": "12345", - "relationship": "componentOf" - } - ], - "assertions": [ - { - "label": "org.test.assertion", - "data": "assertion" - } - ] - }) - .to_string() -} - -fn parent_json() -> String { - json!({ - "title": "Parent Test", - "format": "image/jpeg", - "instance_id": "12345", - "relationship": "parentOf" - }) - .to_string() -}