Skip to content

Commit 0f90e21

Browse files
committed
Clean up test noise now that I know where I need to place updates
1 parent faf671b commit 0f90e21

File tree

6 files changed

+37
-17
lines changed

6 files changed

+37
-17
lines changed

c2pa_c_ffi/src/c_api.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,8 @@ pub unsafe extern "C" fn c2pa_free_string_array(ptr: *const *const c_char, count
463463

464464
// Run CAWG post-validation - this is async and requires a runtime.
465465
fn post_validate(result: Result<C2paReader, c2pa::Error>) -> Result<C2paReader, c2pa::Error> {
466-
if true {
466+
if false {
467+
// CONSIDER BEFORE MERGING ...
467468
todo!("Remove me?");
468469
}
469470

c2pa_c_ffi/src/json_api.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ use crate::{Error, Result, SignerInfo};
2424
pub fn read_file(path: &str, data_dir: Option<String>) -> Result<String> {
2525
let mut reader = Reader::from_file(path).map_err(Error::from_c2pa_error)?;
2626
let runtime = Runtime::new().map_err(|e| Error::Other(e.to_string()))?;
27-
if true {
27+
if false {
28+
// CONSIDER BEFORE MERGING ...
2829
todo!("Remove post_validate_async here?");
2930
}
3031
runtime

cli/src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,8 @@ fn verify_fragmented(init_pattern: &Path, frag_pattern: &Path) -> Result<Vec<Rea
574574

575575
// run cawg validation if supported
576576
fn validate_cawg(reader: &mut Reader) -> Result<()> {
577-
if true {
577+
if false {
578+
// CONSIDER BEFORE MERGING ...
578579
todo!("Remove me?");
579580
}
580581
#[cfg(not(target_os = "wasi"))]

sdk/examples/cawg_identity.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ mod cawg {
2929
crypto::raw_signature,
3030
identity::{
3131
builder::{AsyncIdentityAssertionBuilder, AsyncIdentityAssertionSigner},
32-
validator::CawgValidator,
3332
x509::AsyncX509CredentialHolder,
3433
},
3534
AsyncSigner, Builder, Reader, SigningAlg,

sdk/src/identity/x509/x509_credential_holder.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ mod tests {
8888
x509::{X509CredentialHolder, X509SignatureVerifier},
8989
IdentityAssertion,
9090
},
91-
status_tracker::StatusTracker,
91+
status_tracker::{LogKind, StatusTracker},
9292
Builder, Reader, SigningAlg,
9393
};
9494

@@ -134,7 +134,7 @@ mod tests {
134134
// Read back the Manifest that was generated.
135135
dest.rewind().unwrap();
136136

137-
let manifest_store = Reader::from_stream(format, &mut dest).unwrap();
137+
let manifest_store = Reader::from_stream_async(format, &mut dest).await.unwrap();
138138
assert_eq!(manifest_store.validation_status(), None);
139139

140140
let validation_results = manifest_store.validation_results().unwrap();
@@ -153,9 +153,9 @@ mod tests {
153153
let ia_success = ia_success_codes.next().unwrap();
154154
dbg!(&ia_success);
155155

156-
if true {
157-
panic!("Look for identity assertion success codes");
158-
}
156+
assert_eq!(ia_success.code(), "signingCredential.trusted");
157+
assert!(ia_success.url().unwrap().ends_with("cawg.identity"));
158+
assert_eq!(ia_success.kind(), &LogKind::Success);
159159

160160
let manifest = manifest_store.active_manifest().unwrap();
161161
let mut st = StatusTracker::default();

sdk/src/reader.rs

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,17 +136,19 @@ impl Reader {
136136
Store::from_stream_async(format, &mut stream, verify, &mut validation_log).await
137137
}?;
138138

139-
let /* mut */ result = Self::from_store(store, &validation_log)?;
139+
#[allow(unused_mut)] // TEMPORARY until I figure out the synchronous path.
140+
let mut result = Self::from_store(store, &validation_log)?;
140141
if _sync {
141142
// TO DO: Figure out how to handle synchronous validation with
142143
// identity assertions? Just report an error (needs async)?
143144
if false {
144145
todo!("Add identity assertion validation here");
145146
}
146147
} else {
147-
if true {
148-
todo!("Add identity assertion validation here");
149-
}
148+
use crate::identity::validator::CawgValidator;
149+
result
150+
.post_validate_internal_async(&CawgValidator {})
151+
.await?;
150152
}
151153

152154
Ok(result)
@@ -752,9 +754,24 @@ impl Reader {
752754
validator: &impl AsyncPostValidator
753755
))]
754756
pub fn post_validate(&mut self, validator: &impl PostValidator) -> Result<()> {
755-
if true {
756-
todo!("Remove me");
757+
if false {
758+
// CONSIDER BEFORE MERGING ...
759+
todo!("Remove me?");
760+
}
761+
762+
if _sync {
763+
self.post_validate_internal(validator)
764+
} else {
765+
self.post_validate_internal_async(validator).await
757766
}
767+
}
768+
769+
#[async_generic(async_signature(
770+
&mut self,
771+
validator: &impl AsyncPostValidator
772+
))]
773+
fn post_validate_internal(&mut self, validator: &impl PostValidator) -> Result<()> {
774+
// TEMPORARY: Make this available while I sort out new code path.
758775
let mut validation_log = StatusTracker::default();
759776
let mut validation_results = self.validation_results.take().unwrap_or_default();
760777
let mut assertion_values = HashMap::new();
@@ -1017,8 +1034,9 @@ pub mod tests {
10171034

10181035
#[test]
10191036
fn test_reader_post_validate() -> Result<()> {
1020-
if true {
1021-
todo!("Remove me");
1037+
if false {
1038+
// CONSIDER BEFORE MERGING ...
1039+
todo!("Remove me?");
10221040
}
10231041
use crate::{log_item, status_tracker::StatusTracker};
10241042

0 commit comments

Comments
 (0)