diff --git a/Cargo.toml b/Cargo.toml index ddffa900..75b4a9bc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "c2pa-python" -version = "0.5.0" +version = "0.5.1" edition = "2021" authors = ["Gavin Peacock bytes: assert manifest,["format"] == "image/jpeg" # There should be no validation status errors assert manifest.get("validation_status") == None + except Exception as e: + print("Failed to sign manifest store: " + str(e)) + exit(1) + +# Test signing the same source and destination file +def test_v2_sign_file_same(): + data_dir = "tests/fixtures/" + try: + def sign(data: bytes) -> bytes: + return sign_ps256(data, data_dir+"ps256.pem") + + certs = open(data_dir + "ps256.pub", "rb").read() + # Create a local signer from a certificate pem file + signer = create_signer(sign, SigningAlg.PS256, certs, "http://timestamp.digicert.com") + + builder = Builder(manifest_def) + + builder.add_resource_file("A.jpg", data_dir + "A.jpg") + + with tempfile.TemporaryDirectory() as output_dir: + path = output_dir + "/A.jpg" + # Copy the file from data_dir to output_dir + shutil.copy(data_dir + "A.jpg", path) + c2pa_data = builder.sign_file(signer, path, path) + assert len(c2pa_data) > 0 + + reader = Reader.from_file(path) + manifest = reader.get_active_manifest() + + # check custom title and format + assert manifest["title"]== "My Title" + assert manifest["format"] == "image/jpeg" + # There should be no validation status errors + assert manifest.get("validation_status") == None except Exception as e: print("Failed to sign manifest store: " + str(e)) exit(1) \ No newline at end of file diff --git a/tests/unit_tests.py b/tests/unit_tests.py index e72b1cab..964352a3 100644 --- a/tests/unit_tests.py +++ b/tests/unit_tests.py @@ -26,7 +26,7 @@ class TestC2paSdk(unittest.TestCase): def test_version(self): - self.assertIn("0.5.0", sdk_version()) + self.assertIn("0.5.1", sdk_version()) class TestReader(unittest.TestCase):