-
Notifications
You must be signed in to change notification settings - Fork 111
fix: add missing remote url #1598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mauricefisher64
wants to merge
2
commits into
main
Choose a base branch
from
fix/missing_remote_url
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ | |
| // specific language governing permissions and limitations under | ||
| // each license. | ||
|
|
||
| use std::io::{self, Cursor}; | ||
| use std::io::{self, Cursor, Seek}; | ||
|
|
||
| use c2pa::{ | ||
| settings::Settings, validation_status, Builder, BuilderIntent, ManifestAssertionKind, Reader, | ||
|
|
@@ -79,6 +79,70 @@ fn test_builder_riff() -> Result<()> { | |
| Ok(()) | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_builder_sidecar_only_bmff_cawg() -> Result<()> { | ||
| Settings::from_toml(include_str!("../tests/fixtures/test_settings.toml"))?; | ||
| Settings::from_toml(include_str!( | ||
| "../tests/fixtures/test_settings_with_cawg_signing.toml" | ||
| ))?; // overlay cawg settings | ||
|
|
||
| let mut source = Cursor::new(include_bytes!("fixtures/video1.mp4")); | ||
| let format = "video/mp4"; | ||
| let mut dest = Cursor::new(Vec::new()); | ||
|
|
||
| let manifest_json = r#" | ||
| { | ||
| "assertions": [ | ||
| { | ||
| "label": "c2pa.metadata", | ||
| "kind": "Json", | ||
| "data": { | ||
| "@context": { "exif": "http://ns.adobe.com/exif/1.0/" }, | ||
| "exif:GPSLatitude": "39,21.102N" | ||
| } | ||
| }, | ||
| { | ||
| "label": "cawg.metadata", | ||
| "kind": "Json", | ||
| "data": { | ||
| "@context": { "cawg": "http://cawg.org/ns/1.0/" }, | ||
| "cawg:SomeField": "SomeValue" | ||
| } | ||
| }, | ||
| { | ||
| "label": "c2pa.assertion.metadata", | ||
| "data": { | ||
| "@context": { "custom": "http://custom.org/ns/1.0/" }, | ||
| "custom:Field": "CustomValue" | ||
| } | ||
| }, | ||
| { | ||
| "label": "org.myorg.metadata", | ||
| "data": { | ||
| "@context": { "myorg": "http://myorg.org/ns/1.0/" }, | ||
| "myorg:Field": "MyOrgValue" | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| "#; | ||
|
|
||
| let mut builder = Builder::from_json(manifest_json)?; | ||
| builder.set_intent(BuilderIntent::Edit); | ||
| builder.definition.claim_version = Some(2); // use v1 for this test | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't that's using v2? |
||
| builder.no_embed = true; | ||
| builder.remote_url = Some("http://somecompany.org".to_string()); | ||
| let c2pa_data = builder.sign(&Settings::signer()?, format, &mut source, &mut dest)?; | ||
|
|
||
| dest.rewind()?; | ||
| let reader1 = Reader::from_manifest_data_and_stream(&c2pa_data, format, &mut dest)?; | ||
| assert!(!reader1.is_embedded()); | ||
| assert_eq!(reader1.remote_url().unwrap(), "http://somecompany.org/"); | ||
| println!("reader1: {reader1}"); | ||
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_builder_sidecar_only() -> Result<()> { | ||
| Settings::from_toml(include_str!("../tests/fixtures/test_settings.toml"))?; | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs for
Reader::remote_urlis defined as:Here we are changing that definition but also the behavior that exists in other parts of the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that no remote_url is returned when using this path and Tania reported an error. What do you want here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current behavior is to ignore remote_url if the manifest is found as embedded first. Here we are always setting the remote_url. It's an unusual situation though because we aren't actually looking for an embedded manifest anyways.
If we are going to make this change here, we should probably make that change in the other constructors and change the reader docs to state that it's always returned regardless of how the manifest was obtained.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(For context, on the error, if it's the one I am thinking of( #1532): The reported issue is that in certain cases you can "keep" and outdated remote URL manifest. Even if our SDK does not look at it, it still could be found. For instance, even if our SDK does the right thing, you could still "find" URLs by using exiftool. More details in #1532).