Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions tests/builder.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <gtest/gtest.h>
#include <string>
#include <filesystem>
#include <nlohmann/json.hpp>

using namespace std;
namespace fs = std::filesystem;
Expand Down Expand Up @@ -94,6 +95,7 @@ TEST_P(SimplePathSignTest, SignsFileTypes) {
fs::path manifest_path = current_dir / "../tests/fixtures/training.json";
fs::path certs_path = current_dir / "../tests/fixtures/es256_certs.pem";
fs::path asset_path = current_dir / "../tests/fixtures" / SimplePathSignTest::GetParam();
fs::path ingredient_path = current_dir / "../tests/fixtures/A.jpg";

fs::path output_path = current_dir / "../build/example" / SimplePathSignTest::GetParam();
std::filesystem::remove(output_path.c_str()); // remove the file if it exists
Expand All @@ -106,6 +108,14 @@ TEST_P(SimplePathSignTest, SignsFileTypes) {
auto signer = c2pa::Signer("Es256", certs, p_key, "http://timestamp.digicert.com");
auto builder = c2pa::Builder(manifest);

// Add an ingredient example.
string ingredient_json = c2pa::read_ingredient_file(ingredient_path, output_path.parent_path());
auto ingredient_json_obj = nlohmann::json::parse(ingredient_json);
std::string resource_id = ingredient_json_obj["thumbnail"]["identifier"];

builder.add_resource(resource_id, ingredient_path);
builder.add_ingredient(ingredient_json, ingredient_path);
Comment on lines +113 to +117
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question (cc @gpeacock): how come we don't add thumbnails as a resource implicitly?


std::vector<unsigned char> manifest_data;
ASSERT_NO_THROW(manifest_data = builder.sign(asset_path, output_path, signer));
ASSERT_FALSE(manifest_data.empty());
Expand Down
Loading